[ http://jira.codehaus.org/browse/SUREFIRE-556?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Radai Rosenblatt closed SUREFIRE-556. ------------------------------------- Resolution: Not A Bug junit deems any class that extends TestCase to be a legacy (junit 3.8) test class and does not rpocess annotations. > methods in a TestCase annotated with @Test but unconventionally named are not > picked up > --------------------------------------------------------------------------------------- > > Key: SUREFIRE-556 > URL: http://jira.codehaus.org/browse/SUREFIRE-556 > Project: Maven Surefire > Issue Type: Bug > Components: Junit 4.x support > Affects Versions: 2.4.3 > Environment: JDK 1.6.13, maven 2.2.0, surefire 2.4.3, junit 4.6 > Reporter: Radai Rosenblatt > Attachments: test.rar > > > according to Junit 4.x tutorials, any public void method annotated with @Test > is a test method to be run. > however, surefire still seems to rely on the public void test*() naming > convention to find tests to run. > the example project (test) i've attached is a simple modification of the > maven quick-start archetype project to demonstrate this. > this i've done: > 1. create a new maven quickstart project using archetype > 2. change project to depend on junit 4.6 (instead of 3.8.1) > 3. change build configuration to produce java 6 code > 4. change generated TestCase by removing the TestSuite-creating methods, > renaming the testApp() method and annotate it with @Test > running mvn clean install for this project fails with the following error: > ------------------------------------------------------- > T E S T S > ------------------------------------------------------- > Running test.AppTest > Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.032 sec <<< > FAILURE! > Results : > Failed tests: > warning(test.AppTest) > Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 > [INFO] > ------------------------------------------------------------------------ > [ERROR] BUILD FAILURE > [INFO] > ------------------------------------------------------------------------ > [INFO] There are test failures. > when looking in the report file, the warning is as follows: > ------------------------------------------------------------------------------- > Test set: test.AppTest > ------------------------------------------------------------------------------- > Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< > FAILURE! > warning(test.AppTest) Time elapsed: 0 sec <<< FAILURE! > junit.framework.AssertionFailedError: No tests found in test.AppTest > at junit.framework.Assert.fail(Assert.java:47) > at junit.framework.TestSuite$1.runTest(TestSuite.java:97) > at junit.framework.TestCase.runBare(TestCase.java:134) > at junit.framework.TestResult$1.protect(TestResult.java:110) > at junit.framework.TestResult.runProtected(TestResult.java:128) > at junit.framework.TestResult.run(TestResult.java:113) > at junit.framework.TestCase.run(TestCase.java:124) > at junit.framework.TestSuite.runTest(TestSuite.java:232) > at junit.framework.TestSuite.run(TestSuite.java:227) > at > org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:91) > at > org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) > at > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) > at > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) > at org.apache.maven.surefire.Surefire.run(Surefire.java:177) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) > at > org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009) > which is wrong. the @Test-annotated method should have been picked up > renaming the method according to convention resolves this, however i dont > think this should be strictly needed. > the attachement is the modified quickstart project. simply running "mvn clean > install" for it will demonstrate. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira