This question already has an answer here:
Is it good practice to have multiple test cases in one test or should I always create one test for single test case in every situation even if it is redundant? Why?
This question already has an answer here: Is it good practice to have multiple test cases in one test or should I always create one test for single test case in every situation even if it is redundant? Why? |
|||||
marked as duplicate by gnat, MainMa, MichaelT, GlenH7, Kilian Foth Jan 1 at 14:02This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. |
|||||
|
The common approach is to put each independent test in its own test method. The main reason for this is to make the list of passing/failing tests as self-documenting as possible. Ideally you should be able to look at which test failed and have a good idea what is wrong with the code from that alone. If single test methods test multiple things, this is not possible. Sometimes it happens that two tests have identical setup; in this case it is recommended to factor out the common code into a helper method. |
|||
|