What is the difference between testing on the basis of the properties and mutation?

My context for this question is in Python.

Hypotheses testing library (ie, based on the properties of the test): https://hypothesis.readthedocs.io/en/latest/

Mutation testing library: https://github.com/sixty-north/cosmic-ray

+5
source share
1 answer

These are very different animals, but both will improve the value and quality of your tests. Both tools make the expression "My code coverage is N%" more meaningful.


Hypothesis will help you to generate all sorts of test inputs in a particular area for the test function.

Usually, when you need to test a function, you provide several example values, trying to cover all cases of use and extreme cases caused by code coverage reports - this is the so-called "sample testing". The hypothesis, on the other hand, implements based on the properties tested, generating a whole bunch of different input and input combinations that identify different common errors such as division by zero, None , 0, errors in each run, etc. And help find the hidden errors.

Mutational tests - all of this comes to change your code under the control on the fly during the execution of your tests with a modified version of your code.

It really helps to check if your tests really check out what they have to test in order to understand the value of your tests. Mutation testing will really shine if you already have a rich test code base and good code coverage.


What helped me get these concepts were these Python podcasts:

+5
source

All Articles