I have three JUnit test classes that all had some common code, including identical setup() methods. So, I factored this code out into its own class that extends TestCase and now have the three earlier JUnit test classes extend this new class. The new super class contains no tests itself.
However, in our build, JUnit runs all the JUnit test classes, including the new super class with no tests. It gives this error:
junit.framework.AssertionFailedError: No tests found in com.acme.ControllerTest
I could get rid of this error by creating some simple test that does nothing in ControllerTest. But is there a cleaner way of fixing this?
This works for me
JUnit 3
The output I get is
JUnit 4
For JUnit4 you do not even need to make the base class abstract. You can just use the following
I would strongly recommend using JUnit 4. Using annotations means that you break some of this inheritance dependency which can get confusing.