jeudi 27 juillet 2017

Does the value of unit tests decrease with the complexity of the unit test?

I'm at the point where I should write a unit test for the complex algorithm that my function does perform. The function takes two mandatory arguments at invocation. Based on the combination of both arguments the function does return something.

function ReturnDesiredParagraphStyle(currParagraphStyle, nextParagraphStyle) 
{
    // logic
}

Now the problem is, to test any combination of inputs and the correctness of the desired output of the function I have to write a complex logic within the unit test, because there are so many possible inputs (approximately 50 for each argument). The complex logic would be a loop with the purpose that I do not have to type each combination of inputs manually in the unit test.

I do understand that most of the time to write this unit-test will provide an layer of safety, but doesen't it lead the concept of unit testing a bit ad absurdum (because the logic in the unit test will be so complex and nothing tests the logic in the unit test)?

Aucun commentaire:

Enregistrer un commentaire