mardi 24 janvier 2017

Should you do an assert statement inside a loop?

When we have multiple values for which we would like to test a given method should we loop through the values in a single test?

Or is it incorrect has in case of failure it might be harder to identify the cause?

Something like this:

testSomething(){
    List myValues = {'value1', 'value2', 'value3', ...}

    for(value: myValues){
        assertTrue(Something(Value))
    }
}

Aucun commentaire:

Enregistrer un commentaire