When a JUnit4 test class is a subtype of a JUnit3 TestCase, then implementation of RSPEC-2187 raises a FP, saying that the test class does not contain unit tests... while it's an obvious FP.
Required files to reproduce:
import org.junit.Test; public class ReproducerTest extends AbstractJUnit4Test { // FP HERE @Test public void shouldFoo() { assertTrue(1 + 1 == 2); } }
import org.junit.Rule; import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.junit.runners.model.Statement; @RunWith(JUnit4.class) public abstract class AbstractJUnit4Test extends AbstractJUnit3TestCase { @Rule public TestRule rule = (base, description) -> new Statement() { @Override public void evaluate() throws Throwable { String name = description.getMethodName(); setName(name.startsWith("test") ? name : "test" + name); setUp(); try { base.evaluate(); } finally { tearDown(); } } }; }
import junit.framework.TestCase; public abstract class AbstractJUnit3TestCase extends TestCase { @Override protected void setUp() throws Exception { System.out.println("setUp"); } @Override protected void tearDown() throws Exception { System.out.println("tearDown"); } }
- relates to
-
RSPEC-2187 TestCases should contain tests
- Active