Theres an interesting rant on why JUnit wasn’t suitable for this guy ‘Mike’s tests, with the primary reason as I understand it that he creates X number of dynamically created tests and runs out of memory.
Whilst agreeing with him – if you aren’t writing unit tests, xUnit may not be the right tool … I think he would have been better served with something along the lines of (in python):
class DynamicTests(unittest.TestCase):expectedCount=1000def countTests(self):return self.expectedCountdef runTest(self):for int in range(self.expectedCount):do_whatever_to_test_this_case
The point being that the xUnit framework imposes No Requirement that a test case _be_ an instance – it uses a composite pattern, and any element can be a test case, a container for tests, or both. If you need to write many related tests that (for example) need to store no local state, require the same temporary resources, then leverage the nature of the composite.