concept runTest() in category junit

appears as: runTest()
JUnit Recipes: Practical Methods for Programmer Testing

This is an excerpt from Manning's book JUnit Recipes: Practical Methods for Programmer Testing.

One drawback to this approach is that although each test operates on different data, all the tests in your suite will have the same name. This can make it difficult to determine exactly which test is failing from JUnit’s output alone. One simple solution is to add the test input into the failure messages for each assertion in the test. This would work, but it is better to have meaningful names. You can achieve this by overriding runTest() and placing your test code directly inside that method. This way you sidestep JUnit’s default behavior, which is to invoke a method whose name matches the name of the test case.[26] If you override runTest(), you can pass a more meaningful name as a parameter to the constructor of your test case class. For a complete example, refer to solution A.2, “Parameterized Test Case overriding runTest().”

Once you are more comfortable with the fundamentals of writing JUnit tests, you might run into more complex problems with JUnit, many of which center around a class loading problem within JUnit itself. Beyond that, if you override runTest() in your tests you should be aware of the problems that can cause.

You have written a test by overriding the method runTest(), rather than letting JUnit identify your test methods. Now JUnit sets up your test fixture only once before all the tests, rather than once before each test.