TestNG JDK1.4 JavaDoc annotated classes never run ... and now I know why. -------------------------------------------------------------------------
Key: MSUREFIRE-173 URL: http://jira.codehaus.org/browse/MSUREFIRE-173 Project: Maven 2.x Surefire Plugin Issue Type: Bug Components: TestNG support Affects Versions: 2.2 Environment: - WinXP - Maven 2.0.4 (with maven-surefire-plugin 2.2) Reporter: Davy Toch Attachments: m2-testng-example-jdk14.zip After a day of trying to find out why JDK1.4 JavaDoc annotated test classes were never run, I finally found out why: In maven-surefire\surefire-providers\surefire-testng\src\main\java\org\apache\maven\surefire\testng\TestNGExecutor.java, the method testng.runSuitesLocally() is called: static void executeTestNG( SurefireTestSuite surefireSuite, String testSourceDirectory, XmlSuite suite, ReporterManager reporterManager ) { ... // TODO: Doesn't find testng.xml based suites when these are un-commented // TestNG ~also~ looks for the currentThread context classloader // ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); // Thread.currentThread().setContextClassLoader( suite.getClass().getClassLoader() ); testNG.runSuitesLocally(); //Thread.currentThread().setContextClassLoader( oldClassLoader ); ... } However, in the TestNG 5.1 source file org\testng\TestNG.java, only the method run() correctly loads the JDK1.4 annotations. So the above class should call testng.run() and not testng.runSuitesLocally(). org\testng\TestNG.java: /** * Run TestNG. */ public void run() { // lazy scan sourcedirs if needed if(isJdk14() || JAVADOC_ANNOTATION_TYPE.equals(m_target)) { AnnotationConfiguration.getInstance().getAnnotationFinder().addSourceDirs(m_sourceDirs); } ... } The problem is also still present in the latest 2.3-SNAPSHOT version of the maven-surefire-plugin. Included a small example project to illustrate the problem (just run "maven test"). -- 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