DRY vs DAMP in unit tests

Looping through endpoints isn’t bad thing …. or is it?

Tl:Dr — DRY for production code, sometimes ok in test code, but DAMP is preferrable.


Which view is failing & passing? Dunno because the message is ambiguous..
Loops through a list of endpoints. Can be 3, 9 or even 20 for all we know ..
A long list of dictionarys contaning our endpoints & expected status codes..
A test that loops through a list of views via GET request.


Separated test case for all views using DAMP approach.

So when is DRY acceptable in unit tests?

Loops through all 4xx status codes and checks errors return true
Line 2 perfectly tells you which status code had failed.

Questions? disagree?


Full-Stack Engineer, at one time also officially labelled “Professional Badass”.