TestingΒΆ
The goal of testing is to be able to validate the code, and to make changes without the fear of breaking everything: In addition to creating a code which produces correct results, the tests documents the newly written code use. There are several types of testing.
unit testing: validate at the finest granulometry (function/method) that the code produces the expected result. Usually the tests are written before the function. It forces the code to be easily testable.
integration testing: validate the interactions between different modules.
performance/stress testing: validate the code performance as a function of the problem size.
acceptance/functional testing: from a user perspective, validate that the code meets the expected requirements.
This sections focuses first on the testing technicalities, more specifically on the pytest library.
Then, some examples will illustrate the different test layers described above.
To gauge how much testing is crucial, this conference on sqlite is interesting even though it uses C and not python. In an other style, and related to the topic of artificial intelligence for coding agents, this interview about Mammouth AI gives some interesting perspectives.