I am using JUnit 3 and have a situation where often I have to test that an object is created correctly. My idea was to write a class MyTestBase as shown below and then extend from that for the situation specific unit tests.
However in the example I've given, MyTests does not run the 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 error. The tests in my base class weren't named correctly.
You have said "MyTests does not run the tests in MyTestBase.". I tried it and all tests were called including the ones in MyTestBase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With