Summary and Setup
This is a Byte-Sized RSE lesson on code review, part of the Byte-Sized RSE Series.
Learning Objectives
At the end of this lesson, learners should be able to:
- Describe what unit testing is and explain why it matters for software quality.
- Examine example code and identify where and how unit tests could be applied.
- Write a simple unit test for a function and integrate it into their project.
- Recognise common error/exception conditions in code and write tests that handle/expect such errors.
- Evaluate a test suite in terms of coverage.
Setup
- Shell with Git version control tool installed and the ability to navigate filesystem and run commands from within a shell
- Python version 3.8 or above installed
- Understanding of Python syntax to be able to read code examples
- Pip Python package installer
- Visual Studio Code installed (ideally the latest version)
Shell with Git
On macOS and Linux, some version of a shell (e.g. bash)
with Git will be available by default and no installation is needed.
If you do not have a bash shell installed on your system and require assistance with the installation, you can take a look at the instructions provided by Software Carpentry for installing shell and Git.
Python
Python version 3.8 or above is required. Type python -v
at your shell prompt and press enter to see what version of Python is
installed on your system. If you do not have Python installed on your
system and require assistance with the installation, you can take a look
at the
instructions provided by Software Carpentry for installing Python in
preparation for undertaking their Python lesson.
Pip
Pip Python package should come together with your Python
distribution. Try typing pip at the command line and you
should see some usage instructions for the command appear if it is
installed.
VS Code
The hands-on part of this topic will be conducted using Visual Studio Code (VS Code), a widely used IDE. Please [download the appropriate version of Visual Studio Code][vs-code] for your operating system (Windows, macOS, or Linux) and system architecture (e.g., 64-bit, ARM).
Alternative setup
Alternatively, if you are unable to install these tools, you can undertake the activity entirely in a web browser but you will need to register for a free account with a third-party web application called replit.