What are the best practices to organize your unit tests in classes?
I see different possibilities:
1) One would be to write one "container" class for each function you want test and then subclass that to group in each subclass all tests that are similar in some way - e.g. one subclass contains all tests where we make make sure the functions throws errors correctly and one class that contains all tests where we make sure that the function does what it's supposed to.
2) A different one would be to group tests for different functions in one class: Suppose we want to test the functions
mysearch. Instead of having as previously 2 (sub)classes per function (i.e. 4 in total,
Test_mysearch_OK), now we have only 2 classes in total (
TestAllOK), one containing all tests to check for each function that errors are thrown correctly and one containing all tests that everything works as intended, again for each function
(So we have the same tests as in 1), but just arranged differently in classes.)
3) I could come up with even more ways to group tests in classes, but I'll stop here.
(In part 1 of my question I received general advice how to organize my suite of testing functions, but now I'm interested in this more specific query.)