Automated testing - Preventing yourself and others from breaking your functioning code
In this lesson we discuss the basics of automated testing.
We start discussing why automated testing is important. We then show how to set up automated testing in your projects in a few programming languages, so that you can run a test suite conveniently on your own computer. We will continue by showing how to have GitHub (or GitLab) run the test suite automatically (typically whenever someone pushes to the repository), and tell us when there was a problem.
If time allows, we might do that in a collaborative fashion, running the test suite on a pull request to inform the code review process.
Writing tests can be challenging sometimes, so we will discuss typical problems in test design, mentioning also Test Driven Development, and practice designing and writing tests.
The goals of the module is to make the learners feel comfortable with setting up a test suite of automated tests, feel familiar with the automation options on Software forges (e.g. GitHub and GitLab), and make them aware of the typical challenges in writing automated tests.
Prerequisites
You need pytest (as part of Anaconda or Miniconda or Virtual Environment).
(Optional) To work on exercises in other languages than Python, please follow the instructions under “Language-specific instructions” in the Test design episode to install the recommended testing frameworks.
Basic understanding of Git.
You need a GitHub or a Gitlab account for the “automated testing” and “full-cycle collaborative workflow” (but the rest works fine just locally).
If you wish to follow in the terminal and are new to the command line, we recorded a short shell crash course.
15 min |
|
25 min |
|
30 min |
|
30 min |
|
5 min |
The lesson
About