I use JUnit 3 and have a situation where often I have to check the correctness of the creation of an object. My idea was to write the MyTestBase class as shown below, and then move on from this to the specific concrete unit tests.
However, in the example I gave, MyTests does not run tests in MyTestBase .
public class MyTestBase extends TestCase { protected String foo; public void testFooNotNull() { assertNotNull(foo); } public void testFooValue() { assertEquals("bar", foo); } } public class MyTests extends MyTestBase { public void setUp() { this.foo = "bar"; } public void testSomethingElse() { assertTrue(true); } }
What am I doing wrong?
Update Apologies. Stupid mistake. The tests in my base class were not named correctly.
java unit-testing junit junit3
John oxley
source share