jeudi 3 septembre 2015

Which is worse design: sharing data between tests, or multiple asserts per test?

Let's say I'm testing my code and I have designed 5 functions to to 5 different things. The data function_a() returns is passed to function_b()... ect all the way to function_e(). See below.

var1 = function_a()
var2 = function_b(var1)
...
var5 = function_e(var4)

So all of these functions are fairly interdependent and reliant on the data from the previous function.

How do I test this properly? Five assertions in a single test seems like a code smell to me, but according to the accepted answer here passing data between separate tests (which would be necessary here I think) is a bit of a code smell.

Aucun commentaire:

Enregistrer un commentaire