You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by df...@apache.org on 2008/01/25 17:39:03 UTC
svn commit: r615261 - in /maven/surefire/trunk:
surefire-api/src/main/java/org/apache/maven/surefire/report/
surefire-api/src/main/java/org/apache/maven/surefire/suite/
surefire-api/src/main/java/org/apache/maven/surefire/testset/
surefire-api/src/test...
Author: dfabulich
Date: Fri Jan 25 08:39:00 2008
New Revision: 615261
URL: http://svn.apache.org/viewvc?rev=615261&view=rev
Log:
[SUREFIRE-433] Fix classname attribute on XML output for various providers.
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/pom.xml
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/BasicTest.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/TestTwo.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/WrapperTestSuite.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCases/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/pom.xml
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/BasicTest.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestSuite.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestTwo.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGSuiteTest.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGTestTwo.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/resources/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/resources/suite.xml
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReportEntry.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/PojoTestSet.java
maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/HelperAssertions.java
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesTest.java
maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java
maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4TestSetReporter.java
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java Fri Jan 25 08:39:00 2008
@@ -81,7 +81,7 @@
private void printAbortionError( String msg, ReportEntry report )
{
writer.println( msg );
- writer.println( report.getSource().getClass().getName() );
+ writer.println( report.getSourceName() );
writer.println( report.getName() );
writer.println( report.getMessage() );
writer.println( getStackTrace( report ) );
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReportEntry.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReportEntry.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReportEntry.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReportEntry.java Fri Jan 25 08:39:00 2008
@@ -25,7 +25,7 @@
public class ReportEntry
{
- private Object source;
+ private String source;
private String name;
@@ -41,21 +41,41 @@
public ReportEntry( Object source, String name, String message )
{
- this( source, name, null, message );
+ this( source.getClass().getName(), name, null, message );
}
public ReportEntry( Object source, String name, String group, String message )
{
- this( source, name, group, message, null );
+ this( source.getClass().getName(), name, group, message, null );
}
public ReportEntry( Object source, String name, String message, StackTraceWriter stackTraceWriter )
{
- this( source, name, null, message, stackTraceWriter );
+ this( source.getClass().getName(), name, null, message, stackTraceWriter );
}
public ReportEntry( Object source, String name, String group, String message, StackTraceWriter stackTraceWriter )
{
+ this( source.getClass().getName(), name, group, message, stackTraceWriter );
+ }
+
+ public ReportEntry( String source, String name, String message )
+ {
+ this( source, name, null, message );
+ }
+
+ public ReportEntry( String source, String name, String group, String message )
+ {
+ this( source, name, group, message, null );
+ }
+
+ public ReportEntry( String source, String name, String message, StackTraceWriter stackTraceWriter )
+ {
+ this( source, name, null, message, stackTraceWriter );
+ }
+
+ public ReportEntry( String source, String name, String group, String message, StackTraceWriter stackTraceWriter )
+ {
if ( source == null )
{
throw new NullPointerException( "source is null" );
@@ -80,13 +100,21 @@
this.setStackTraceWriter( stackTraceWriter );
}
- public void setSource( Object source )
+ public void setSource( String source )
{
this.source = source;
}
-
+
+ /**
+ * @deprecated Use {@link #getSourceName()} instead
+ */
public Object getSource()
{
+ return getSourceName();
+ }
+
+ public String getSourceName()
+ {
return source;
}
@@ -142,7 +170,7 @@
}
ReportEntry rhs = (ReportEntry) obj;
return new EqualsBuilder()
- .append( getSource(), rhs.getSource() )
+ .append( getSourceName(), rhs.getSourceName() )
.append( getName(), rhs.getName() )
.append( getGroup(), rhs.getGroup() )
.append( getMessage(), rhs.getMessage() )
@@ -153,7 +181,7 @@
public String toString()
{
return new ToStringBuilder( this )
- .append( "source", getSource() )
+ .append( "source", getSourceName() )
.append( "name", getName() )
.append( "group", getGroup() )
.append( "message", getMessage() )
@@ -167,7 +195,7 @@
// ideally different for each class
// good resource at http://primes.utm.edu/lists/small/1000.txt
return new HashCodeBuilder( 5897, 6653 )
- .append( getSource() )
+ .append( getSourceName() )
.append( getName() )
.append( getGroup() )
.append( getMessage() )
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java Fri Jan 25 08:39:00 2008
@@ -157,9 +157,9 @@
{
testCase.setAttribute( "group", report.getGroup() );
}
- if ( report.getSource() != null )
+ if ( report.getSourceName() != null )
{
- testCase.setAttribute( "classname", report.getSource().getClass().getName() );
+ testCase.setAttribute( "classname", report.getSourceName() );
}
testCase.setAttribute( "time", elapsedTimeAsString( runTime ) );
return testCase;
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java Fri Jan 25 08:39:00 2008
@@ -133,7 +133,7 @@
{
String rawString = bundle.getString( "testSetStarting" );
- ReportEntry report = new ReportEntry( this, testSet.getName(), rawString );
+ ReportEntry report = new ReportEntry( this.getClass().getName(), testSet.getName(), rawString );
reporterManager.testSetStarting( report );
@@ -141,7 +141,7 @@
rawString = bundle.getString( "testSetCompletedNormally" );
- report = new ReportEntry( this, testSet.getName(), rawString );
+ report = new ReportEntry( this.getClass().getName(), testSet.getName(), rawString );
reporterManager.testSetCompleted( report );
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/PojoTestSet.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/PojoTestSet.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/PojoTestSet.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/PojoTestSet.java Fri Jan 25 08:39:00 2008
@@ -114,7 +114,7 @@
userFriendlyMethodName += ')';
- ReportEntry report = new ReportEntry( testObject, getTestName( userFriendlyMethodName ), getName() );
+ ReportEntry report = new ReportEntry( testObject.getClass().getName(), getTestName( userFriendlyMethodName ), getName() );
reportManager.testStarting( report );
@@ -133,7 +133,7 @@
String stringToPrint = msgFmt.format( stringArgs );
- report = new ReportEntry( testObject, getTestName( userFriendlyMethodName ), stringToPrint,
+ report = new ReportEntry( testObject.getClass().getName(), getTestName( userFriendlyMethodName ), stringToPrint,
new PojoStackTraceWriter( testObject.getClass().getName(), method.getName(),
e ) );
@@ -152,7 +152,7 @@
{
method.invoke( testObject, args );
- report = new ReportEntry( testObject, getTestName( userFriendlyMethodName ), getName() );
+ report = new ReportEntry( testObject.getClass().getName(), getTestName( userFriendlyMethodName ), getName() );
reportManager.testSucceeded( report );
}
@@ -167,7 +167,7 @@
msg = t.toString();
}
- report = new ReportEntry( testObject, getTestName( userFriendlyMethodName ), msg, new PojoStackTraceWriter(
+ report = new ReportEntry( testObject.getClass().getName(), getTestName( userFriendlyMethodName ), msg, new PojoStackTraceWriter(
testObject.getClass().getName(), method.getName(), t ) );
reportManager.testFailed( report );
@@ -183,7 +183,7 @@
msg = t.toString();
}
- report = new ReportEntry( testObject, getTestName( userFriendlyMethodName ), msg, new PojoStackTraceWriter(
+ report = new ReportEntry( testObject.getClass().getName(), getTestName( userFriendlyMethodName ), msg, new PojoStackTraceWriter(
testObject.getClass().getName(), method.getName(), t ) );
reportManager.testFailed( report );
@@ -206,7 +206,7 @@
String stringToPrint = msgFmt.format( stringArgs );
- report = new ReportEntry( testObject, getTestName( userFriendlyMethodName ), stringToPrint,
+ report = new ReportEntry( testObject.getClass().getName(), getTestName( userFriendlyMethodName ), stringToPrint,
new PojoStackTraceWriter( testObject.getClass().getName(), method.getName(),
t ) );
Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java (original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java Fri Jan 25 08:39:00 2008
@@ -39,7 +39,7 @@
super.setUp();
reporter = new XMLReporter( null, Boolean.TRUE );
message = "junit.framework.AssertionFailedError";
- reportEntry = new ReportEntry( this, "XMLReporterTest", message,
+ reportEntry = new ReportEntry( this.getClass().getName(), "XMLReporterTest", message,
new PojoStackTraceWriter( "", "", new AssertionFailedError() ) );
}
Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/HelperAssertions.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/HelperAssertions.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/HelperAssertions.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/HelperAssertions.java Fri Jan 25 08:39:00 2008
@@ -10,7 +10,14 @@
public class HelperAssertions
{
+ /** assert that the reports in the specified testDir have the right summary statistics */
public static void assertTestSuiteResults( int total, int errors, int failures, int skipped,
+ File testDir ) throws MavenReportException {
+ ITSuiteResults suite = parseTestResults( new File[] { testDir } );
+ assertTestSuiteResults( total, errors, failures, skipped, suite );
+ }
+
+ protected static void assertTestSuiteResults( int total, int errors, int failures, int skipped,
ITSuiteResults actualSuite )
{
Assert.assertEquals( "wrong number of tests", total, actualSuite.getTotal() );
@@ -18,22 +25,45 @@
Assert.assertEquals( "wrong number of failures", failures, actualSuite.getFailures() );
Assert.assertEquals( "wrong number of skipped", skipped, actualSuite.getSkipped() );
}
-
- public static void assertTestSuiteResults( int total, int errors, int failures, int skipped,
- File testDir ) throws MavenReportException {
- ITSuiteResults suite = parseTestResults( new File[] { testDir } );
- assertTestSuiteResults( total, errors, failures, skipped, suite );
- }
- public static ITSuiteResults parseTestResults( File testDir )
+ protected static ITSuiteResults parseTestResults( File testDir )
throws MavenReportException
{
return parseTestResults( new File[] { testDir } );
}
- public static ITSuiteResults parseTestResults( File[] testDirs )
+ protected static ITSuiteResults parseTestResults( File[] testDirs )
throws MavenReportException
{
+ List reports = extractReports( testDirs );
+ ITSuiteResults results = parseReportList( reports );
+ return results;
+ }
+
+ /** Converts a list of ReportTestSuites into an ITSuiteResults object, suitable for summary assertions */
+ protected static ITSuiteResults parseReportList( List reports )
+ {
+ Assert.assertTrue( "No reports!", reports.size() > 0 );
+ int total = 0, errors = 0, failures = 0, skipped = 0;
+ for (int i = 0; i < reports.size(); i++) {
+ ReportTestSuite suite = (ReportTestSuite) reports.get( i );
+ total += suite.getNumberOfTests();
+ errors += suite.getNumberOfErrors();
+ failures += suite.getNumberOfFailures();
+ skipped += suite.getNumberOfSkipped();
+ }
+ ITSuiteResults results = new ITSuiteResults(total, errors, failures, skipped);
+ return results;
+ }
+
+ protected static List extractReports( File testDir )
+ {
+ return extractReports( new File[] { testDir } );
+ }
+
+ /** Extracts a list of ReportTestSuites from the specified testDirs */
+ protected static List extractReports( File[] testDirs )
+ {
SurefireReportParser parser = new SurefireReportParser();
File[] reportsDirs = new File[testDirs.length];
for ( int i = 0; i < testDirs.length; i++ )
@@ -50,16 +80,6 @@
} catch (Exception e) {
throw new RuntimeException("Couldn't parse XML reports", e);
}
- Assert.assertTrue( "No reports!", reports.size() > 0 );
- int total = 0, errors = 0, failures = 0, skipped = 0;
- for (int i = 0; i < reports.size(); i++) {
- ReportTestSuite suite = (ReportTestSuite) reports.get( i );
- total += suite.getNumberOfTests();
- errors += suite.getNumberOfErrors();
- failures += suite.getNumberOfFailures();
- skipped += suite.getNumberOfSkipped();
- }
- ITSuiteResults results = new ITSuiteResults(total, errors, failures, skipped);
- return results;
+ return reports;
}
}
Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesTest.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesTest.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesTest.java Fri Jan 25 08:39:00 2008
@@ -1,22 +1,25 @@
package org.apache.maven.surefire.its;
+import java.io.File;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import junit.framework.TestCase;
+
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
-
-import java.io.File;
+import org.apache.maven.plugins.surefire.report.ReportTestSuite;
/**
* Test running two test cases; confirms reporting works correctly
*
* @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
- *
*/
public class TwoTestCasesTest
extends TestCase
{
- public void testTwoTestCases ()
+ public void testTwoTestCases()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/junit-twoTestCases" );
@@ -25,7 +28,83 @@
verifier.executeGoal( "test" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
-
- HelperAssertions.assertTestSuiteResults( 2, 0, 0, 0, testDir );
+
+ HelperAssertions.assertTestSuiteResults( 2, 0, 0, 0, testDir );
+ }
+
+ /** Runs two tests encapsulated in a suite */
+ public void testTwoTestCaseSuite()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/junit-twoTestCaseSuite" );
+
+ Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+ verifier.executeGoal( "test" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+ List reports = HelperAssertions.extractReports( (new File[] { testDir }) );
+ Set classNames = extractClassNames( reports );
+ assertContains( classNames, "junit.twoTestCaseSuite.BasicTest" );
+ assertContains( classNames, "junit.twoTestCaseSuite.TestTwo" );
+ assertEquals( "wrong number of classes", 2, classNames.size() );
+ ITSuiteResults results = HelperAssertions.parseReportList( reports );
+ HelperAssertions.assertTestSuiteResults( 2, 0, 0, 0, results );
+ }
+
+ private void assertContains( Set set, String expected )
+ {
+ if ( set.contains( expected ) ) return;
+ fail( "Set didn't contain " + expected );
+ }
+
+ private Set extractClassNames( List reports )
+ {
+ ReportTestSuite suite;
+ HashSet classNames = new HashSet();
+ for ( int i = 0; i < reports.size(); i++ )
+ {
+ suite = (ReportTestSuite) reports.get( i );
+ classNames.add( suite.getFullClassName() );
+ }
+ return classNames;
+ }
+
+ public void testJunit4Suite()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/junit4-twoTestCaseSuite" );
+
+ Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+ verifier.executeGoal( "test" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+
+ List reports = HelperAssertions.extractReports( (new File[] { testDir }) );
+ Set classNames = extractClassNames( reports );
+ assertContains( classNames, "twoTestCaseSuite.BasicTest" );
+ assertContains( classNames, "twoTestCaseSuite.Junit4TestTwo" );
+ assertEquals( "wrong number of classes", 2, classNames.size() );
+ ITSuiteResults results = HelperAssertions.parseReportList( reports );
+ HelperAssertions.assertTestSuiteResults( 2, 0, 0, 0, results );
+ }
+
+ public void testTestNGSuite()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/testng-twoTestCaseSuite" );
+
+ Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+ verifier.executeGoal( "test" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+
+ List reports = HelperAssertions.extractReports( (new File[] { testDir }) );
+ Set classNames = extractClassNames( reports );
+ assertContains( classNames, "testng.two.TestNGTestTwo" );
+ assertContains( classNames, "testng.two.TestNGSuiteTest" );
+ assertEquals( "wrong number of classes", 2, classNames.size() );
+ ITSuiteResults results = HelperAssertions.parseReportList( reports );
+ HelperAssertions.assertTestSuiteResults( 2, 0, 0, 0, results );
}
+
}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/pom.xml?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/pom.xml Fri Jan 25 08:39:00 2008
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>junit-twoTestCaseSuite</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>Test for single suite with two test cases</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/WrapperTestSuite.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/BasicTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/BasicTest.java?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/BasicTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/BasicTest.java Fri Jan 25 08:39:00 2008
@@ -0,0 +1,67 @@
+package junit.twoTestCaseSuite;
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class BasicTest
+ extends TestCase
+{
+
+ private boolean setUpCalled = false;
+
+ private static boolean tearDownCalled = false;
+
+ public BasicTest( String name, String extraName )
+ {
+ super( name );
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite();
+ Test test = new BasicTest( "testSetUp", "dummy" );
+ suite.addTest( test );
+ TestSetup setup = new TestSetup( suite )
+ {
+
+ protected void setUp()
+ {
+ //oneTimeSetUp();
+ }
+
+ protected void tearDown()
+ {
+ oneTimeTearDown();
+ }
+
+ };
+
+ return setup;
+ }
+
+ protected void setUp()
+ {
+ setUpCalled = true;
+ tearDownCalled = false;
+ System.out.println( "Called setUp" );
+ }
+
+ protected void tearDown()
+ {
+ setUpCalled = false;
+ tearDownCalled = true;
+ System.out.println( "Called tearDown" );
+ }
+
+ public void testSetUp()
+ {
+ assertTrue( "setUp was not called", setUpCalled );
+ }
+
+ public static void oneTimeTearDown()
+ {
+ assertTrue( "tearDown was not called", tearDownCalled );
+ }
+
+}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/TestTwo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/TestTwo.java?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/TestTwo.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/TestTwo.java Fri Jan 25 08:39:00 2008
@@ -0,0 +1,9 @@
+package junit.twoTestCaseSuite;
+import junit.framework.TestCase;
+
+
+public class TestTwo
+ extends TestCase
+{
+ public void testTwo() {}
+}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/WrapperTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/WrapperTestSuite.java?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/WrapperTestSuite.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/WrapperTestSuite.java Fri Jan 25 08:39:00 2008
@@ -0,0 +1,20 @@
+package junit.twoTestCaseSuite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class WrapperTestSuite
+ extends TestSuite
+{
+ public WrapperTestSuite( String name )
+ {
+ super( name );
+ }
+
+ public static Test suite() {
+ WrapperTestSuite suite = new WrapperTestSuite( "My Acceptance Test Suite" );
+ suite.addTestSuite( TestTwo.class );
+ suite.addTest( BasicTest.suite() );
+ return suite;
+ }
+}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/pom.xml?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/pom.xml Fri Jan 25 08:39:00 2008
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>junit4-twoTestCaseSuite</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>Test for JUnit 4 suite with two test cases</name>
+
+
+ <properties>
+ <junitVersion>4.4</junitVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junitVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/Junit4TestSuite.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/BasicTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/BasicTest.java?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/BasicTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/BasicTest.java Fri Jan 25 08:39:00 2008
@@ -0,0 +1,44 @@
+package twoTestCaseSuite;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class BasicTest
+{
+
+ private boolean setUpCalled = false;
+
+ private static boolean tearDownCalled = false;
+
+ @Before
+ public void setUp()
+ {
+ setUpCalled = true;
+ tearDownCalled = false;
+ System.out.println( "Called setUp" );
+ }
+
+ @After
+ public void tearDown()
+ {
+ setUpCalled = false;
+ tearDownCalled = true;
+ System.out.println( "Called tearDown" );
+ }
+
+ @Test
+ public void testSetUp()
+ {
+ Assert.assertTrue( "setUp was not called", setUpCalled );
+ }
+
+ @AfterClass
+ public static void oneTimeTearDown()
+ {
+
+ }
+
+}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestSuite.java?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestSuite.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestSuite.java Fri Jan 25 08:39:00 2008
@@ -0,0 +1,14 @@
+package twoTestCaseSuite;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ BasicTest.class,
+ Junit4TestTwo.class
+})
+public class Junit4TestSuite
+{
+
+}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestTwo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestTwo.java?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestTwo.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestTwo.java Fri Jan 25 08:39:00 2008
@@ -0,0 +1,8 @@
+package twoTestCaseSuite;
+
+import org.junit.Test;
+
+public class Junit4TestTwo
+{
+ @Test public void secondTest() {}
+}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml Fri Jan 25 08:39:00 2008
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>testng-twoTestCaseSuite</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>TestNG Suite XML with two test cases</name>
+
+ <properties>
+ <testNgVersion>5.7</testNgVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testNgVersion}</version>
+ <classifier>jdk15</classifier>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <suiteXmlFiles>
+ <file>src/test/resources/suite.xml</file>
+ </suiteXmlFiles>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGSuiteTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGSuiteTest.java?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGSuiteTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGSuiteTest.java Fri Jan 25 08:39:00 2008
@@ -0,0 +1,13 @@
+package testng.two;
+
+import org.testng.annotations.Test;
+
+
+public class TestNGSuiteTest {
+
+ @Test
+ public void doNothing()
+ {
+
+ }
+}
\ No newline at end of file
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGTestTwo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGTestTwo.java?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGTestTwo.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGTestTwo.java Fri Jan 25 08:39:00 2008
@@ -0,0 +1,13 @@
+package testng.two;
+
+import org.testng.annotations.Test;
+
+
+public class TestNGTestTwo {
+
+ @Test
+ public void testTwo()
+ {
+
+ }
+}
\ No newline at end of file
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/resources/suite.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/resources/suite.xml?rev=615261&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/resources/suite.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/src/test/resources/suite.xml Fri Jan 25 08:39:00 2008
@@ -0,0 +1,7 @@
+<suite name="Foo">
+ <test name="Bar">
+ <packages>
+ <package name="testng.two" />
+ </packages>
+ </test>
+</suite>
\ No newline at end of file
Modified: maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java Fri Jan 25 08:39:00 2008
@@ -151,7 +151,7 @@
// Handler for TestListener.startTest(Test)
public void handleStartTest( Object[] args )
{
- ReportEntry report = new ReportEntry( args[0], args[0].toString(), args[0].getClass().getName() );
+ ReportEntry report = new ReportEntry( args[0].getClass().getName(), args[0].toString(), args[0].getClass().getName() );
reportManager.testStarting( report );
}
@@ -161,7 +161,7 @@
throws IllegalAccessException, InvocationTargetException
{
ReportEntry report =
- new ReportEntry( args[0], args[0].toString(), args[1].toString(), getStackTraceWriter( args ) );
+ new ReportEntry( args[0].getClass().getName(), args[0].toString(), args[1].toString(), getStackTraceWriter( args ) );
reportManager.testError( report );
@@ -190,7 +190,7 @@
throws IllegalAccessException, InvocationTargetException
{
ReportEntry report =
- new ReportEntry( args[0], args[0].toString(), args[1].toString(), getStackTraceWriter( args ) );
+ new ReportEntry( args[0].getClass().getName(), args[0].toString(), args[1].toString(), getStackTraceWriter( args ) );
reportManager.testFailed( report );
@@ -203,7 +203,7 @@
if ( !testHadFailed )
{
- ReportEntry report = new ReportEntry( args[0], args[0].toString(), args[0].getClass().getName() );
+ ReportEntry report = new ReportEntry( args[0].getClass().getName(), args[0].toString(), args[0].getClass().getName() );
reportManager.testSucceeded( report );
}
Modified: maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4TestSetReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4TestSetReporter.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4TestSetReporter.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4TestSetReporter.java Fri Jan 25 08:39:00 2008
@@ -19,6 +19,10 @@
* under the License.
*/
+import java.util.ResourceBundle;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.apache.maven.surefire.Surefire;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.ReporterManager;
@@ -27,8 +31,6 @@
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
-import java.util.ResourceBundle;
-
public class JUnit4TestSetReporter
extends RunListener
{
@@ -67,7 +69,7 @@
throws Exception
{
String rawString = bundle.getString( "testSetStarting" );
- ReportEntry report = new ReportEntry( testSet, testSet.getName(), rawString );
+ ReportEntry report = new ReportEntry( testSet.getName(), testSet.getName(), rawString );
this.reportMgr.testSetStarting( report );
}
@@ -81,7 +83,7 @@
throws Exception
{
String rawString = bundle.getString( "testSetCompletedNormally" );
- ReportEntry report = new ReportEntry( testSet, testSet.getName(), rawString );
+ ReportEntry report = new ReportEntry( testSet.getName(), testSet.getName(), rawString );
this.reportMgr.testSetCompleted( report );
this.reportMgr.reset();
@@ -96,7 +98,7 @@
throws Exception
{
String rawString = bundle.getString( "testSkipped" );
- ReportEntry report = new ReportEntry( testSet, description.getDisplayName(), rawString );
+ ReportEntry report = new ReportEntry( extractClassName( description ), description.getDisplayName(), rawString );
this.reportMgr.testSkipped( report );
}
@@ -110,7 +112,7 @@
throws Exception
{
String rawString = bundle.getString( "testStarting" );
- ReportEntry report = new ReportEntry( testSet, description.getDisplayName(), rawString );
+ ReportEntry report = new ReportEntry( extractClassName( description ), description.getDisplayName(), rawString );
this.reportMgr.testStarting( report );
@@ -127,7 +129,7 @@
{
String rawString = bundle.getString( "executeException" );
ReportEntry report =
- new ReportEntry( testSet, failure.getTestHeader(), rawString, new JUnit4StackTraceWriter( failure ) );
+ new ReportEntry( extractClassName( failure.getDescription() ), failure.getTestHeader(), rawString, new JUnit4StackTraceWriter( failure ) );
if ( failure.getException() instanceof AssertionError )
{
@@ -152,9 +154,24 @@
if ( failureFlag == false )
{
String rawString = bundle.getString( "testSuccessful" );
- ReportEntry report = new ReportEntry( testSet, description.getDisplayName(), rawString );
+ ReportEntry report = new ReportEntry( extractClassName( description ), description.getDisplayName(), rawString );
this.reportMgr.testSucceeded( report );
}
+ }
+
+ private String extractClassName( Description description )
+ {
+ String displayName = description.getDisplayName();
+ final Pattern PARENS = Pattern.compile(
+ "^" +
+ "[^\\(\\)]+" + //non-parens
+ "\\((" + // then an open-paren (start matching a group)
+ "[^\\\\(\\\\)]+" + //non-parens
+ ")\\)" +
+ "$" ); // then a close-paren (end group match)
+ Matcher m = PARENS.matcher( displayName );
+ if (!m.find()) return displayName;
+ return m.group( 1 );
}
}
Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java Fri Jan 25 08:39:00 2008
@@ -35,7 +35,7 @@
public ConfigurationAwareTestNGReporter( ReporterManager reportManager, SurefireTestSuite source )
{
- super( reportManager, source );
+ super( reportManager );
}
}
Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java Fri Jan 25 08:39:00 2008
@@ -158,7 +158,7 @@
{
String rawString = bundle.getString( "testSetStarting" );
- ReportEntry report = new ReportEntry( suite, "TestSuite", rawString );
+ ReportEntry report = new ReportEntry( suite.getClass().getName(), "TestSuite", rawString );
try
{
@@ -175,7 +175,7 @@
String rawString = bundle.getString( "testSetCompletedNormally" );
ReportEntry report =
- new ReportEntry( suite, "TestSuite", rawString );
+ new ReportEntry( suite.getClass().getName(), "TestSuite", rawString );
reporterManager.testSetCompleted( report );
Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java Fri Jan 25 08:39:00 2008
@@ -145,7 +145,7 @@
throw new RuntimeException("Bug in ConfigurationAwareTestNGReporter", e);
}
} catch (ClassNotFoundException e) {
- return new TestNGReporter( reportManager, suite );
+ return new TestNGReporter( reportManager );
}
}
Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java?rev=615261&r1=615260&r2=615261&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java Fri Jan 25 08:39:00 2008
@@ -26,7 +26,6 @@
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.ReporterManager;
-import org.apache.maven.surefire.suite.SurefireTestSuite;
import org.testng.ISuite;
import org.testng.ISuiteListener;
import org.testng.ITestContext;
@@ -51,8 +50,6 @@
*/
protected ReporterManager reportManager;
- private Object source;
-
/**
* Constructs a new instance that will listen to
* test updates from a {@link TestNG} class instance.
@@ -63,7 +60,7 @@
*
* @param reportManager Instance to report suite status to
*/
- public TestNGReporter( ReporterManager reportManager, SurefireTestSuite source )
+ public TestNGReporter( ReporterManager reportManager )
{
this.reportManager = reportManager;
@@ -72,22 +69,26 @@
throw new IllegalArgumentException( "ReportManager passed in was null." );
}
- this.source = source;
}
public void onTestStart( ITestResult result )
{
String rawString = bundle.getString( "testStarting" );
String group = groupString( result.getMethod().getGroups(), result.getTestClass().getName() );
- ReportEntry report = new ReportEntry( source, getUserFriendlyTestName( result ), group, rawString );
+ ReportEntry report = new ReportEntry( getSource( result ), getUserFriendlyTestName( result ), group, rawString );
reportManager.testStarting( report );
}
+
+ private String getSource( ITestResult result )
+ {
+ return result.getTestClass().getName();
+ }
public void onTestSuccess( ITestResult result )
{
ReportEntry report =
- new ReportEntry( source, getUserFriendlyTestName( result ), bundle.getString( "testSuccessful" ) );
+ new ReportEntry( getSource( result ), getUserFriendlyTestName( result ), bundle.getString( "testSuccessful" ) );
reportManager.testSucceeded( report );
}
@@ -95,7 +96,7 @@
{
String rawString = bundle.getString( "executeException" );
- ReportEntry report = new ReportEntry( source, getUserFriendlyTestName( result ), rawString,
+ ReportEntry report = new ReportEntry( getSource( result ), getUserFriendlyTestName( result ), rawString,
new PojoStackTraceWriter( result.getTestClass().getRealClass().getName(),
result.getMethod().getMethodName(), result.getThrowable() ) );
@@ -111,7 +112,7 @@
public void onTestSkipped( ITestResult result )
{
ReportEntry report =
- new ReportEntry( source, getUserFriendlyTestName( result ), bundle.getString( "testSkipped" ) );
+ new ReportEntry( getSource( result ), getUserFriendlyTestName( result ), bundle.getString( "testSkipped" ) );
reportManager.testSkipped( report );
}
@@ -121,7 +122,7 @@
String rawString = bundle.getString( "executeException" );
ReportEntry report =
- new ReportEntry( source, getUserFriendlyTestName( result ), rawString,
+ new ReportEntry( getSource( result ), getUserFriendlyTestName( result ), rawString,
new PojoStackTraceWriter( result.getTestClass().getRealClass().getName(),
result.getMethod().getMethodName(), result.getThrowable() ) );