31 lines
764 B
Plaintext
31 lines
764 B
Plaintext
Overriding a parent class method prevents that method from being called unless an explicit ``++super++`` call is made in the overriding method. In some cases not calling the ``++super++`` method is acceptable, but not with ``++setUp++`` and ``++tearDown++`` in a JUnit 3 ``++TestCase++``.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
public class MyClassTest extends MyAbstractTestCase {
|
|
|
|
private MyClass myClass;
|
|
@Override
|
|
protected void setUp() throws Exception { // Noncompliant
|
|
myClass = new MyClass();
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
public class MyClassTest extends MyAbstractTestCase {
|
|
|
|
private MyClass myClass;
|
|
@Override
|
|
protected void setUp() throws Exception {
|
|
super.setUp();
|
|
myClass = new MyClass();
|
|
}
|
|
----
|
|
|
|
|