rspec/rules/S2188/java/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

58 lines
1.3 KiB
Plaintext

== Why is this an issue?
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
[source,java]
----
public class MyClassTest extends MyAbstractTestCase {
private MyClass myClass;
@Override
protected void setUp() throws Exception { // Noncompliant
myClass = new MyClass();
}
----
=== Compliant solution
[source,java]
----
public class MyClassTest extends MyAbstractTestCase {
private MyClass myClass;
@Override
protected void setUp() throws Exception {
super.setUp();
myClass = new MyClass();
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Add a "super.[setUp()|tearDown()]" call to this method.
'''
== Comments And Links
(visible only on this page)
=== on 24 Nov 2014, 19:27:21 Nicolas Peru wrote:
\[~ann.campbell.2]This is not relevant since junit 4 might be worth mentionning that it only concerns Junit 3 way of writing tests.
=== on 1 Dec 2014, 17:22:33 Ann Campbell wrote:
done [~nicolas.peru]
endif::env-github,rspecator-view[]