mardi 20 septembre 2016

The number of unit testing combinations is overwhelming

I'm new to unit testing (recent grad now in the real world). I'm baffled at how long it takes to write tests.

Let's take a basic example. I write a function like:

def add(a, b)
    return a + b

and I want to test it for inputs of integers and floats. For example, a test case name may be test_add_negative_integer_to_negative_integer.


Assumption
Testing edge cases at the boundaries is representative of all other cases.
Edges/Boundaries
Numerical types = {integer, float}
Numerical values = {negative, zero, positive}
Number of test cases
Combinations with repetition (Assuming parameter order is not important).

C[3 + 2 - 1, 2] * C[2 + 2 - 1, 1] = 18 test cases to meet the assumption condition.
Adding another value to to the numerical types set yields 36 different test cases.

Am I doing something wrong?

Aucun commentaire:

Enregistrer un commentaire