maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michal Borowiecki (JIRA)" <>
Subject [jira] Commented: (SUREFIRE-482) Surefire tries to run JUnit4 tests that contain no @Test annotations
Date Thu, 11 Dec 2008 14:41:19 GMT


Michal Borowiecki commented on SUREFIRE-482:

This is an issue for me too.

"Naming a class *Test without making it abstract and without putting any @Test annotation"
does not seam unusual to me.

Mock object are one case.
Another one is starting a new project and creating a test class not having implemented any
test methods yet. Having to make it abstract is an unnecessary nuisance. What is worse, you
then have to remember to make it non-abstract again once you have written the first test.
Another case is wanting to temporarily disabling tests by annotating them with @Ignore. It
is inconsistent that you can do it UNLESS there are no more methods with @Test annotation
left in the class in which case the exception is raised.

In the end even if these cases were unusual they are not in any way an error and should not
be reported as such and should not break a build.

I hope someone is convinced one day that this should be fixed :)

> Surefire tries to run JUnit4 tests that contain no @Test annotations
> --------------------------------------------------------------------
>                 Key: SUREFIRE-482
>                 URL:
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Junit 4.x support
>    Affects Versions: 2.4.2
>            Reporter: Mark Hobson
>         Attachments:
> Similar to SUREFIRE-346 but for JUnit4, Surefire tries to run classes that contain no
@Test annotations as tests, resulting in the exception:
> java.lang.Exception: No runnable methods
>         at org.junit.internal.runners.MethodValidator.validateInstanceMethods(
>         at org.junit.internal.runners.MethodValidator.validateMethodsForDefaultRunner(
>         at org.junit.internal.runners.JUnit4ClassRunner.validate(
>         at org.junit.internal.runners.JUnit4ClassRunner.<init>(
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance(
>         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
>         at java.lang.reflect.Constructor.newInstance(
>         at org.junit.internal.requests.ClassRequest.buildRunner(
>         at org.junit.internal.requests.ClassRequest.getRunner(
>         at org.apache.maven.surefire.junit4.JUnit4TestSet.<init>(
>         at org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(
>         at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(
>         at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(
>         at
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
>         at java.lang.reflect.Method.invoke(
>         at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(
>         at org.apache.maven.surefire.booter.SurefireBooter.main(
> Such classes should be ignored by Surefire.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


View raw message