Quick background: I've been hunting down a Maven / Surefire test-running problem for days now, and I've narrowed it down to a small number suspect of tests. The behavior I'm seeing is insane. I start with mvn clean test
: 250 tests run, 0 skipped. Now, I move the suspect test into src/test/java
and try again: 146 tests run, 0 skipped! The output of Maven gives no clue that other tests aren't being run, even with the -X
flag.
That brings me to my question: the reason I call the test 'suspect' is that the whole class is decorated with @Ignore, so I would imagine that including it in my test sources should have no effect at all. Then it occurred to me -- those classes have @BeforeClass/@AfterClass methods that manage a dummy Zookeeper server. It's resulted in wonky behavior before, which is why we have the tests @Ignored.
If JUnit is running the before/after code but ignoring the tests, I have no idea what might happen (but it'd probably be super bad). Is this happening? Is this supposed to happen? If so, how am I supposed to say "for reference, here's a test that should work but needs fixing" when it includes @BeforeClass / @AfterClass? Also of substantial interest: what the hell is this doing to Surefire / Maven, that it causes unrelated tests to fall off the face of the Earth?
mvn clean test
does not run@BeforeClass
in an@Ignore
class. TheSkipped
counter is increasing by only one regardless of the number of @Test methods in the @Ignore class. (Maven 2.2.1, jUnit 4.9) You should attach some code and version numbers. Are you using a custom test runner? – Fernery