Property changes on: /home/jkuhnert/projects/surefire ___________________________________________________________________ Name: svn:ignore - target *.iml *.ipr *.iws + target *.iml *.ipr *.iws .project Index: /home/jkuhnert/projects/surefire/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java =================================================================== --- /home/jkuhnert/projects/surefire/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java (revision 418041) +++ /home/jkuhnert/projects/surefire/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java (working copy) @@ -22,6 +22,7 @@ import org.testng.xml.Parser; import org.testng.xml.XmlSuite; import org.testng.xml.XmlTest; +import org.testng.xml.XmlClass; import org.xml.sax.SAXException; import javax.xml.parsers.ParserConfigurationException; @@ -149,7 +150,7 @@ { throw new TestSetFailedException( "Duplicate test set '" + xmlTest.getName() + "'" ); } - + // We don't need to put real test sets in here, the key is the important part testSets.put( xmlTest.getName(), xmlTest ); } Index: /home/jkuhnert/projects/surefire/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java =================================================================== --- /home/jkuhnert/projects/surefire/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java (revision 418041) +++ /home/jkuhnert/projects/surefire/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java (working copy) @@ -134,7 +134,7 @@ XmlSuite suite = new XmlSuite(); suite.setParallel( parallel ); suite.setThreadCount( threadCount ); - + for ( Iterator i = testSets.values().iterator(); i.hasNext(); ) { SurefireTestSet testSet = (SurefireTestSet) i.next(); @@ -150,6 +150,7 @@ XmlTest xmlTest = new XmlTest( suite ); xmlTest.setName( testSet.getName() ); xmlTest.setXmlClasses( Collections.singletonList( new XmlClass( testSet.getTestClass() ) ) ); + if ( groups != null ) { xmlTest.setIncludedGroups( Arrays.asList( groups.split( "," ) ) ); @@ -158,13 +159,18 @@ { xmlTest.setExcludedGroups( Arrays.asList( excludedGroups.split( "," ) ) ); } - -// if ( !TestNGClassFinder.isTestNGClass( testSet.getTestClass(), annotationFinder ) ) + + // if ( !TestNGClassFinder.isTestNGClass( testSet.getTestClass(), annotationFinder ) ) // TODO: this is a bit dodgy, but isTestNGClass wasn't working try { - Class junitClass = Class.forName( "junit.framework.Test" ); - xmlTest.setJUnit( testSet.getTestClass().isAssignableFrom( junitClass ) ); + Class junitClass = Class.forName( "junit.framework.Test" ); + Class junitBase = Class.forName( "junit.framework.TestCase" ); + + if (junitClass.isAssignableFrom(testSet.getTestClass())) + xmlTest.setJUnit( true ); + else if (junitBase.isAssignableFrom(testSet.getTestClass())) + xmlTest.setJUnit( true ); } catch ( ClassNotFoundException e ) { Index: /home/jkuhnert/projects/surefire/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java =================================================================== --- /home/jkuhnert/projects/surefire/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java (revision 418041) +++ /home/jkuhnert/projects/surefire/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java (working copy) @@ -59,9 +59,11 @@ testNG.setSourcePath( testSourceDirectory ); } - ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader( suite.getClass().getClassLoader() ); + // 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 ); + //Thread.currentThread().setContextClassLoader( oldClassLoader ); } }