I have switched to JUnit4.4 from JUnit3.8. I run my tests using ant, all my tests run successfully but test utility classes fail with \"No runnable methods\" error. The patt
In your test class if wrote import org.junit.jupiter.api.Test; delete it and write import org.junit.Test; In this case it worked me as well.
Ant now comes with the skipNonTests
attribute which was designed to do exactly what you seem to be looking for. No need to change your base classes to abstract or add annotations to them.
What about adding an empty test method to these classes?
public void avoidAnnoyingErrorMessageWhenRunningTestsInAnt() {
assertTrue(true); // do nothing;
}
My specific case has the following scenario. Our tests
public class VenueResourceContainerTest extends BaseTixContainerTest
all extend
BaseTixContainerTest
and JUnit was trying to run BaseTixContainerTest. Poor BaseTixContainerTest was just trying to setup the container, setup the client, order some pizza and relax... man.
As mentioned previously, you can annotate the class with
@Ignore
But that caused JUnit to report that test as skipped (as opposed to completely ignored).
Tests run: 4, Failures: 0, Errors: 0, Skipped: 1
That kind of irritated me.
So I made BaseTixContainerTest abstract, and now JUnit truly ignores it.
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
Assuming you're in control of the pattern used to find test classes, I'd suggest changing it to match *Test
rather than *Test*
. That way TestHelper
won't get matched, but FooTest
will.