This is an archived version of the course and is no longer updated. Please find the latest version of the course on the main webpage.

Exercise 4

Software Testing

Exercises

We assume that you have attended/watched the live lecture on Software Testing and now have a good idea about what Test Driven Development (TDD) is about.

While the lecture focussed on the pytest library, Python also provides a Unit Testing framework unittest out of the box. Conveniently, pytest is compatible with and can run unittests. Choose what suits your needs.

Task 1

Obtain the skeleton code from the live lectures here. Then try to reproduce whatever Ivan did during the live demo with pytest, and try to understand what he did. Because trying things out yourself is always different from just watching someone else code on the screen!

Task 2

Choose from some of these exercises, and write unit tests (with pytest) to check the correctness of the functions in the following exercises. And if you still have your solutions, test them!

  • Exercises 1a and/or 2a in Module 2
  • Exercises 4 and/or 9 in Module 2
  • Task #2 in Module 14 (the test cases are conveniently provided!)