Lab Session 5: Testing#

Friday 03-01-2023, 9AM-11AM & 12AM-2PM

Instructor: Facundo Sapienza

During Lab04 we turned the Erasthostenes.ipynb (located in this same folder lab04 in the site repository) into a project with its own installable modules, well writen notebook documentation and conda environment. In this follow up lab, we are going to be adding some tests to the code.

Tip

We are going to continue working with this project for the rest of the semester. For this reason, we encourage you to finish the labs regarding the Eratosthenes notebook at some point. You can also compare the state of your repository with the one available in facusapienza21-eratosthenes under the tag Lab04.

Today’s lab we are going to continue working in the tutorial on Testing, which you will find in the course website.

1. Simple Testing#

Design some unit, integration and regression tests for your Eratosthenes project. As we discussed in class, the first ones are the more easy to make, but still there are some things you need to think about

  1. How to test code involving floting point number?

  2. How to test code that produces figures?

  3. How to test code that runs simulations or compute performance benchmarkings?

2. Using PyTest#

The first part in the lecture Workflow and Automation includes examples of how to run the tests from previous section automatically all at once by using pytest. Follow these steps in order to reproduce the results of your tests but now using pytest.

3. Continuous Integration for testing#

The last section in the Workflow and Automation section in the lecture has a tuturial about how to automatically test your code everytime you push a new commit to GitHub. This is the first example of Continuous Integration (CI) you will explore in this course. Follow these steps in order to automatize your new tests!