maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antony Stubbs (JIRA)" <>
Subject [jira] Commented: (SUREFIRE-482) Surefire tries to run JUnit4 tests that contain no @Test annotations
Date Fri, 27 Mar 2009 07:29:12 GMT


Antony Stubbs commented on SUREFIRE-482:

This is an issue with anonymous inner classes in a test class, that themselves do not contain

initializationError0(x.x.x.x.x.TestHomePage$1)  Time elapsed: 0.002 sec  <<< ERROR!
java.lang.Exception: Test class should have public zero-argument constructor
	at org.junit.internal.runners.MethodValidator.validateNoArgConstructor(

NB: TestHomePage is an actual junit, but contains at least one anonymous inner class which
is not.

Very annoying... To fix this, I'll have to rename 'test' out of the class name. Ugh.

I also have "TestPages" that are not actually junit tests, but SureFire still tries to run
them as junits. Workaround was to put them all inside  a package, and exclude it manually.

> 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