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 kr...@apache.org on 2010/12/11 14:28:40 UTC
svn commit: r1044651 [2/2] - in /maven/surefire/trunk:
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/
maven-surefire-common/src/test/java/org/apac...
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListener.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListener.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListener.java Sat Dec 11 13:28:38 2010
@@ -18,15 +18,15 @@ package org.apache.maven.surefire.junitc
* under the License.
*/
-import org.apache.maven.surefire.report.ReporterManager;
-import org.apache.maven.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.report.Reporter;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.report.ReporterFactory;
import org.apache.maven.surefire.testset.TestSetFailedException;
import org.junit.runner.Description;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
-import java.io.PrintStream;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -36,13 +36,11 @@ import java.util.concurrent.ConcurrentHa
public abstract class ConcurrentReportingRunListener
extends RunListener
{
- private final PrintStream orgSystemOut = System.out;
-
- private final PrintStream orgSystemErr = System.err;
-
protected Map<Class, TestSet> classMethodCounts = new ConcurrentHashMap<Class, TestSet>();
- private final ThreadLocal<ReporterManager> reporterManagerThreadLocal = new ThreadLocal<ReporterManager>();
+ private final ReporterConfiguration reporterConfiguration;
+
+ private final ThreadLocal<Reporter> reporterManagerThreadLocal = new ThreadLocal<Reporter>();
protected final boolean reportImmediately;
@@ -50,16 +48,19 @@ public abstract class ConcurrentReportin
private final ConcurrentPrintStream err = new ConcurrentPrintStream( false );
- private ReporterManagerFactory reporterFactory;
+ private ReporterFactory reporterFactory;
- public ConcurrentReportingRunListener( ReporterManagerFactory reporterFactory, boolean reportImmediately )
+ public ConcurrentReportingRunListener( ReporterFactory reporterFactory, boolean reportImmediately,
+ ReporterConfiguration reporterConfiguration )
throws TestSetFailedException
{
this.reportImmediately = reportImmediately;
this.reporterFactory = reporterFactory;
+ this.reporterConfiguration = reporterConfiguration;
+
// We must create the first reporterManager here, even though we will never use it.
// There is some room for improvement here
- this.reporterFactory.createReporterManager();
+ this.reporterFactory.createReporter();
// Important: We must capture System.out/System.err AFTER the reportManager captures stdout/stderr
// because we know how to demultiplex correctly. The redirection in reporterManager is basically
// ignored/unused because we use ConcurrentPrintStream.
@@ -68,27 +69,28 @@ public abstract class ConcurrentReportin
}
- protected ReporterManager getReporterManager()
+ protected Reporter getReporterManager()
throws TestSetFailedException
{
- ReporterManager reporterManager = reporterManagerThreadLocal.get();
+ Reporter reporterManager = reporterManagerThreadLocal.get();
if ( reporterManager == null )
{
- reporterManager = reporterFactory.createReporterManager();
+ reporterManager = reporterFactory.createReporter();
reporterManagerThreadLocal.set( reporterManager );
}
return reporterManager;
}
- public static ConcurrentReportingRunListener createInstance( ReporterManagerFactory reporterManagerFactory,
+ public static ConcurrentReportingRunListener createInstance( ReporterFactory reporterManagerFactory,
+ ReporterConfiguration reporterConfiguration,
boolean parallelClasses, boolean parallelBoth )
throws TestSetFailedException
{
if ( parallelClasses )
{
- return new ClassesParallelRunListener( reporterManagerFactory );
+ return new ClassesParallelRunListener( reporterManagerFactory, reporterConfiguration );
}
- return new MethodsParallelRunListener( reporterManagerFactory, !parallelBoth );
+ return new MethodsParallelRunListener( reporterManagerFactory, reporterConfiguration, !parallelBoth );
}
@@ -107,11 +109,8 @@ public abstract class ConcurrentReportin
{
testSet.replay( getReporterManager() );
}
- System.setOut( orgSystemOut );
- System.setErr( orgSystemErr );
-
- out.writeTo( orgSystemOut );
- err.writeTo( orgSystemErr );
+ out.writeTo( reporterConfiguration.getOriginalSystemOut() );
+ err.writeTo( reporterConfiguration.getOriginalSystemErr() );
}
protected TestMethod getTestMethod()
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java Sat Dec 11 13:28:38 2010
@@ -22,9 +22,9 @@ package org.apache.maven.surefire.junitc
import org.apache.maven.surefire.NonAbstractClassFilter;
import org.apache.maven.surefire.providerapi.ProviderParameters;
import org.apache.maven.surefire.providerapi.SurefireProvider;
+import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.ReporterFactory;
-import org.apache.maven.surefire.report.ReporterManagerFactory;
import org.apache.maven.surefire.suite.RunResult;
import org.apache.maven.surefire.testset.TestSetFailedException;
import org.apache.maven.surefire.util.DirectoryScanner;
@@ -50,10 +50,13 @@ public class JUnitCoreProvider
private TestsToRun testsToRun;
+ private final ReporterConfiguration reporterConfiguration;
+
@SuppressWarnings( { "UnusedDeclaration" } )
public JUnitCoreProvider( ProviderParameters booterParameters )
{
this.reporterFactory = booterParameters.getReporterFactory();
+ reporterConfiguration = booterParameters.getReporterConfiguration();
this.testClassLoader = booterParameters.getTestClassLoader();
this.directoryScanner = booterParameters.getDirectoryScanner();
this.jUnitCoreParameters = new JUnitCoreParameters( booterParameters.getProviderProperties() );
@@ -75,7 +78,7 @@ public class JUnitCoreProvider
throws TestSetFailedException, ReporterException
{
final String message = "Concurrency config is " + jUnitCoreParameters.toString();
- this.reporterFactory.createReporterManager().writeConsoleMessage( message );
+ reporterFactory.createReporter().writeMessage( message );
if ( testsToRun == null )
{
@@ -83,8 +86,12 @@ public class JUnitCoreProvider
? scanClassPath()
: TestsToRun.fromClassName( (String) forkTestSet, testClassLoader );
}
- JUnitCoreWrapper.execute( testsToRun.getLocatedClasses(), ( ReporterManagerFactory)this.reporterFactory, jUnitCoreParameters );
- reporterFactory.warnIfNoTests();
+ ConcurrentReportingRunListener listener =
+ ConcurrentReportingRunListener.createInstance( this.reporterFactory, this.reporterConfiguration,
+ jUnitCoreParameters.isParallelClasses(),
+ jUnitCoreParameters.isParallelBoth() );
+
+ JUnitCoreWrapper.execute( testsToRun.getLocatedClasses(), jUnitCoreParameters, listener );
return reporterFactory.close();
}
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java Sat Dec 11 13:28:38 2010
@@ -19,7 +19,6 @@ package org.apache.maven.surefire.junitc
* under the License.
*/
-import org.apache.maven.surefire.report.ReporterManagerFactory;
import org.apache.maven.surefire.testset.TestSetFailedException;
import org.junit.runner.Computer;
import org.junit.runner.JUnitCore;
@@ -34,14 +33,10 @@ import java.util.concurrent.ExecutionExc
class JUnitCoreWrapper
{
- public static void execute( Class[] classes, ReporterManagerFactory reporterManagerFactory,
- JUnitCoreParameters jUnitCoreParameters )
+ public static void execute( Class[] classes, JUnitCoreParameters jUnitCoreParameters,
+ ConcurrentReportingRunListener listener )
throws TestSetFailedException
{
- final ConcurrentReportingRunListener listener =
- ConcurrentReportingRunListener.createInstance( reporterManagerFactory,
- jUnitCoreParameters.isParallelClasses(),
- jUnitCoreParameters.isParallelBoth() );
Computer computer = getComputer( jUnitCoreParameters );
JUnitCore junitCore = new JUnitCore();
junitCore.addListener( listener );
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java Sat Dec 11 13:28:38 2010
@@ -18,7 +18,7 @@ package org.apache.maven.surefire.junitc
* under the License.
*/
-import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.report.Reporter;
import java.util.ArrayList;
import java.util.List;
@@ -53,9 +53,9 @@ public class LogicalStream
}
- public void writeToConsole( ReporterManager reporter )
+ public void writeDetails( Reporter reporter )
{
- reporter.writeConsoleMessage( value );
+ reporter.writeDetailMessage( value );
}
@Override
@@ -79,11 +79,11 @@ public class LogicalStream
}
}
- public void writeToConsole( ReporterManager reporter )
+ public void writeDetails( Reporter reporter )
{
for ( Entry entry : output )
{
- entry.writeToConsole( reporter );
+ entry.writeDetails( reporter );
}
}
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java Sat Dec 11 13:28:38 2010
@@ -18,12 +18,13 @@ package org.apache.maven.surefire.junitc
* under the License.
*/
-import org.apache.maven.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.report.ReporterFactory;
import org.apache.maven.surefire.testset.TestSetFailedException;
/**
-* @author Kristian Rosenvold
-*/
+ * @author Kristian Rosenvold
+ */
public class MethodsParallelRunListener
extends ConcurrentReportingRunListener
{
@@ -31,10 +32,11 @@ public class MethodsParallelRunListener
private final Object lock = new Object();
- public MethodsParallelRunListener( ReporterManagerFactory reporterFactory, boolean reportImmediately )
+ public MethodsParallelRunListener( ReporterFactory reporterFactory, ReporterConfiguration reporterConfiguration,
+ boolean reportImmediately )
throws TestSetFailedException
{
- super( reporterFactory, reportImmediately );
+ super( reporterFactory, reportImmediately, reporterConfiguration );
}
@Override
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java Sat Dec 11 13:28:38 2010
@@ -1,4 +1,5 @@
package org.apache.maven.surefire.junitcore;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,8 +20,9 @@ package org.apache.maven.surefire.junitc
*/
import org.apache.maven.surefire.Surefire;
+import org.apache.maven.surefire.report.DefaultReportEntry;
import org.apache.maven.surefire.report.ReportEntry;
-import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.report.Reporter;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
@@ -81,7 +83,7 @@ class TestMethod
this.testAssumptionFailure = failure;
}
- public void replay( ReporterManager reporter )
+ public void replay( Reporter reporter )
throws Exception
{
@@ -94,8 +96,7 @@ class TestMethod
reporter.testStarting( createReportEntry( "testStarting" ) );
if ( output != null )
{
- // For some reason, console output is not written to the txt file.
- output.writeToConsole( reporter );
+ output.writeDetails( reporter );
}
if ( testFailure != null )
{
@@ -124,15 +125,15 @@ class TestMethod
private ReportEntry createReportEntry( String rawString2 )
{
String rawString = bundle.getString( rawString2 );
- return new ReportEntry( description.getTestClass().getCanonicalName(), description.getDisplayName(),
- rawString );
+ return new DefaultReportEntry( description.getTestClass().getCanonicalName(), description.getDisplayName(),
+ rawString );
}
private ReportEntry createFailureEntry( Failure failure, String rawString2 )
{
String rawString = bundle.getString( rawString2 );
- return new ReportEntry( failure.getDescription().getTestClass().getCanonicalName(), failure.getTestHeader(),
- rawString, new JUnitCoreStackTraceWriter( failure ) );
+ return new DefaultReportEntry( failure.getDescription().getTestClass().getCanonicalName(),
+ failure.getTestHeader(), rawString, new JUnitCoreStackTraceWriter( failure ) );
}
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java Sat Dec 11 13:28:38 2010
@@ -19,8 +19,9 @@ package org.apache.maven.surefire.junitc
*/
import org.apache.maven.surefire.Surefire;
+import org.apache.maven.surefire.report.DefaultReportEntry;
import org.apache.maven.surefire.report.ReportEntry;
-import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.report.Reporter;
import org.junit.runner.Description;
import java.util.ArrayList;
@@ -51,6 +52,7 @@ public class TestSet
private static final InheritableThreadLocal<TestSet> testSet = new InheritableThreadLocal<TestSet>();
private AtomicBoolean allScheduled = new AtomicBoolean();
+
private AtomicBoolean played = new AtomicBoolean();
@@ -59,9 +61,12 @@ public class TestSet
this.testSetDescription = testSetDescription;
}
- public void replay( ReporterManager target )
+ public void replay( Reporter target )
{
- if (!played.compareAndSet( false, true )) return;
+ if ( !played.compareAndSet( false, true ) )
+ {
+ return;
+ }
try
{
@@ -98,7 +103,7 @@ public class TestSet
boolean isJunit3 = testSetDescription.getTestClass() == null;
String classNameToUse =
isJunit3 ? testSetDescription.getChildren().get( 0 ).getClassName() : testSetDescription.getClassName();
- return new ReportEntry( classNameToUse, classNameToUse, rawString );
+ return new DefaultReportEntry( classNameToUse, classNameToUse, rawString );
}
public void incrementTestMethodCount()
@@ -111,16 +116,16 @@ public class TestSet
testMethods.add( testMethod );
}
- public void incrementFinishedTests( ReporterManager reporterManager, boolean reportImmediately )
+ public void incrementFinishedTests( Reporter reporterManager, boolean reportImmediately )
{
numberOfCompletedChildren.incrementAndGet();
- if ( allScheduled.get() && isAllTestsDone() && reportImmediately)
+ if ( allScheduled.get() && isAllTestsDone() && reportImmediately )
{
replay( reporterManager );
}
}
- public void setAllScheduled( ReporterManager reporterManager )
+ public void setAllScheduled( Reporter reporterManager )
{
allScheduled.set( true );
if ( isAllTestsDone() )
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java Sat Dec 11 13:28:38 2010
@@ -23,9 +23,7 @@ package org.apache.maven.surefire.junitc
import junit.framework.Assert;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.maven.surefire.report.ReporterConfiguration;
-import org.apache.maven.surefire.report.ReporterManagerFactory;
-import org.apache.maven.surefire.report.RunStatistics;
+import org.apache.maven.surefire.report.*;
import org.apache.maven.surefire.testset.TestSetFailedException;
import org.junit.Ignore;
import org.junit.Test;
@@ -33,9 +31,10 @@ import org.junit.runner.Computer;
import org.junit.runner.JUnitCore;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.PrintStream;
import java.util.ArrayList;
-import java.util.List;
+import java.util.Arrays;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -48,34 +47,38 @@ public class ConcurrentReportingRunListe
{
// Tests are in order of increasing complexity
@Test
- public void testNoErrorsCounting() throws Exception
+ public void testNoErrorsCounting()
+ throws Exception
{
- runClasses( 3, 0 ,0, DummyAllOk.class );
+ runClasses( 3, 0, 0, DummyAllOk.class );
}
@Test
- public void testNoErrorsCounting2() throws Exception
+ public void testNoErrorsCounting2()
+ throws Exception
{
- runClasses( 2, 0 ,0 , Dummy3.class );
+ runClasses( 2, 0, 0, Dummy3.class );
}
@Test
- public void testOneIgnoreCounting() throws Exception
+ public void testOneIgnoreCounting()
+ throws Exception
{
- runClasses( 3, 1, 0, DummyWithOneIgnore.class );
+ runClasses( 3, 1, 0, DummyWithOneIgnore.class );
}
@Test
- public void testOneFailureCounting() throws Exception
+ public void testOneFailureCounting()
+ throws Exception
{
- runClasses( 3, 0 ,1, DummyWithFailure.class );
+ runClasses( 3, 0, 1, DummyWithFailure.class );
}
@Test
public void testWithErrorsCountingDemultiplexed()
throws Exception
{
- runClasses( 6, 1, 1 , DummyWithOneIgnore.class, DummyWithFailure.class);
+ runClasses( 6, 1, 1, DummyWithOneIgnore.class, DummyWithFailure.class );
}
@@ -83,35 +86,35 @@ public class ConcurrentReportingRunListe
public void testJunitResultCountingDemultiplexed()
throws Exception
{
- runClasses( 8, 1, 1, DummyWithOneIgnore.class, DummyWithFailure.class, Dummy3.class );
+ runClasses( 8, 1, 1, DummyWithOneIgnore.class, DummyWithFailure.class, Dummy3.class );
}
@Test
public void testJunitResultCountingJUnit3Demultiplexed()
throws Exception
{
- runClasses( 3, 0 ,0, Junit3Tc1.class, Junit3Tc2.class );
+ runClasses( 3, 0, 0, Junit3Tc1.class, Junit3Tc2.class );
}
@Test
public void testJunitResultCountingJUnit3OddTest()
throws Exception
{
- runClasses( 2, 0 ,0, Junit3OddTest1.class );
+ runClasses( 2, 0, 0, Junit3OddTest1.class );
}
@Test
public void testJunit3WithNestedSuite()
throws TestSetFailedException
{
- runClasses( 4, 0 ,0, Junit3WithNestedSuite.class );
+ runClasses( 4, 0, 0, Junit3WithNestedSuite.class );
}
@Test
public void testJunit3NestedSuite()
throws Exception
{
- runClasses( 2, 0 ,0, Junit3OddTest1.class );
+ runClasses( 2, 0, 0, Junit3OddTest1.class );
}
@@ -124,9 +127,8 @@ public class ConcurrentReportingRunListe
PrintStream orgOur = System.out;
System.setOut( collector );
- RunStatistics result = runClasses(Dummy3.class);
- assertReporter( result, 2, 0 ,0, "msgs" );
-
+ RunStatistics result = runClasses( Dummy3.class );
+ assertReporter( result, 2, 0, 0, "msgs" );
String foo = new String( byteArrayOutputStream.toByteArray() );
assertNotNull( foo );
@@ -143,9 +145,8 @@ public class ConcurrentReportingRunListe
PrintStream orgOur = System.out;
System.setOut( collector );
- RunStatistics result = runClasses(DummyWithOneIgnore.class, DummyWithFailure.class, Dummy3.class);
- assertReporter( result, 8, 1 ,1, "msgs" );
-
+ RunStatistics result = runClasses( DummyWithOneIgnore.class, DummyWithFailure.class, Dummy3.class );
+ assertReporter( result, 8, 1, 1, "msgs" );
String foo = new String( byteArrayOutputStream.toByteArray() );
assertNotNull( foo );
@@ -159,24 +160,30 @@ public class ConcurrentReportingRunListe
private void runClasses( int success, int ignored, int failure, Class... classes )
throws TestSetFailedException
{
- ReporterManagerFactory reporterManagerFactory = createReporterFactory();
- RunStatistics result = runClasses(reporterManagerFactory, new ClassesParallelRunListener( reporterManagerFactory ), classes);
- assertReporter( result, success, ignored ,failure, "classes" );
+ ReporterFactory reporterManagerFactory = createReporterFactory();
+ RunStatistics result = runClasses( reporterManagerFactory,
+ new ClassesParallelRunListener( reporterManagerFactory,
+ getReporterConfiguration() ), classes );
+ assertReporter( result, success, ignored, failure, "classes" );
reporterManagerFactory = createReporterFactory();
- result = runClasses(reporterManagerFactory, new MethodsParallelRunListener(reporterManagerFactory, true) , classes);
- assertReporter( result, success, ignored ,failure, "methods" );
+ result = runClasses( reporterManagerFactory,
+ new MethodsParallelRunListener( reporterManagerFactory, getReporterConfiguration(), true ),
+ classes );
+ assertReporter( result, success, ignored, failure, "methods" );
reporterManagerFactory = createReporterFactory();
- result = runClasses(reporterManagerFactory, new MethodsParallelRunListener(reporterManagerFactory, false) , classes);
- assertReporter( result, success, ignored ,failure, "methods" );
+ result = runClasses( reporterManagerFactory,
+ new MethodsParallelRunListener( reporterManagerFactory, getReporterConfiguration(),
+ false ), classes );
+ assertReporter( result, success, ignored, failure, "methods" );
}
private RunStatistics runClasses( Class... classes )
throws TestSetFailedException
{
- final ReporterManagerFactory reporterManagerFactory = createReporterFactory();
+ final ReporterFactory reporterManagerFactory = createReporterFactory();
ConcurrentReportingRunListener demultiplexingRunListener = createRunListener( reporterManagerFactory );
JUnitCore jUnitCore = new JUnitCore();
@@ -188,7 +195,8 @@ public class ConcurrentReportingRunListe
return reporterManagerFactory.getGlobalRunStatistics();
}
- private RunStatistics runClasses( ReporterManagerFactory reporterManagerFactory, ConcurrentReportingRunListener demultiplexingRunListener, Class... classes )
+ private RunStatistics runClasses( ReporterFactory reporterManagerFactory,
+ ConcurrentReportingRunListener demultiplexingRunListener, Class... classes )
throws TestSetFailedException
{
@@ -201,10 +209,15 @@ public class ConcurrentReportingRunListe
return reporterManagerFactory.getGlobalRunStatistics();
}
- private ConcurrentReportingRunListener createRunListener( ReporterManagerFactory reporterFactory )
+ private ConcurrentReportingRunListener createRunListener( ReporterFactory reporterFactory )
throws TestSetFailedException
{
- return new ClassesParallelRunListener( reporterFactory );
+ return new ClassesParallelRunListener( reporterFactory, getReporterConfiguration() );
+ }
+
+ public ReporterConfiguration getReporterConfiguration()
+ {
+ return new ReporterConfiguration( new ArrayList(), new File( "." ), true );
}
@@ -350,8 +363,6 @@ public class ConcurrentReportingRunListe
suite.addTest( new Junit3OddTest1( "testMe" ) );
suite.addTest( new Junit3OddTest1( "testMe" ) );
-
-
return suite;
}
@@ -378,7 +389,7 @@ public class ConcurrentReportingRunListe
suite.addTest( new Junit3WithNestedSuite( "testMe2" ) );
suite.addTest( new Junit3WithNestedSuite( "testMe2" ) );
- suite.addTestSuite( Junit3Tc2.class);
+ suite.addTestSuite( Junit3Tc2.class );
return suite;
}
@@ -395,26 +406,23 @@ public class ConcurrentReportingRunListe
}
- private ReporterManagerFactory createReporterFactory()
+ private ReporterFactory createReporterFactory()
{
- Object[] reporter = new Object[]{MockReporter.class.getCanonicalName(), new Object[] {} };
- final List<Object> objects = new ArrayList();
- objects.add( reporter );
ReporterConfiguration reporterConfiguration = getTestReporterConfiguration();
- return new ReporterManagerFactory(objects, this.getClass().getClassLoader());
+ return new ReporterManagerFactory( this.getClass().getClassLoader(), reporterConfiguration );
}
public static ReporterConfiguration getTestReporterConfiguration()
{
- return new ReporterConfiguration( new ArrayList(), null, Boolean.TRUE );
+ return new ReporterConfiguration( Arrays.asList( ConsoleReporter.class.getName() ), null, Boolean.TRUE );
}
private void assertReporter( RunStatistics result, int success, int ignored, int failure, String message )
{
- assertEquals( message, success, result.getCompletedCount() );
- assertEquals( message, failure, result.getFailureSources().size() );
- assertEquals( message, ignored, result.getSkipped() );
+ assertEquals( message, success, result.getCompletedCount() );
+ assertEquals( message, failure, result.getFailureSources().size() );
+ assertEquals( message, ignored, result.getSkipped() );
}
}
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java Sat Dec 11 13:28:38 2010
@@ -17,8 +17,8 @@
package org.apache.maven.surefire.junitcore;
import junit.framework.Assert;
-import org.apache.maven.surefire.report.ConsoleReporter;
import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.report.ReporterFactory;
import org.apache.maven.surefire.report.ReporterManagerFactory;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -27,58 +27,58 @@ import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
+import java.io.File;
import java.util.ArrayList;
-import java.util.List;
/**
* TestCase that expose "No tests were executed!" on Test failure using Maven Surefire 2.6-SNAPSHOT
* and the JUnit 4.7 Runner.
- *
+ * <p/>
* -------------------------------------------------------
- * T E S T S
- * -------------------------------------------------------
- *
- * Results :
- *
- * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
- *
- * [INFO] ------------------------------------------------------------------------
- * [INFO] BUILD FAILURE
- * [INFO] ------------------------------------------------------------------------
- * [INFO] Total time: 11.011s
- * [INFO] Finished at: Thu Jul 15 13:59:14 CEST 2010
- * [INFO] Final Memory: 24M/355M
- * [INFO] ------------------------------------------------------------------------
- * [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.5:test
- * (default-test) on project xxxxxx: No tests were executed! (Set -DfailIfNoTests=false to
- * ignore this error.) -> [Help 1]
- *
- *
- * <dependency>
- * <groupId>junit</groupId>
- * <artifactId>junit</artifactId>
- * <version>4.8.1</version>
- * <scope>test</scope>
- * </dependency>
- *
- * <dependency>
- * <groupId>org.apache.maven.surefire</groupId>
- * <artifactId>surefire-booter</artifactId>
- * <version>2.6-SNAPSHOT</version>
- * <scope>test</scope>
- * </dependency>
- * <dependency>
- * <groupId>org.apache.maven.plugins</groupId>
- * <artifactId>maven-surefire-plugin</artifactId>
- * <version>2.6-SNAPSHOT</version>
- * <scope>test</scope>
- * </dependency>
- * <dependency>
- * <groupId>org.apache.maven.surefire</groupId>
- * <artifactId>surefire-junit47</artifactId>
- * <version>2.6-SNAPSHOT</version>
- * <scope>test</scope>
- * </dependency>
+ * T E S T S
+ * -------------------------------------------------------
+ * <p/>
+ * Results :
+ * <p/>
+ * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
+ * <p/>
+ * [INFO] ------------------------------------------------------------------------
+ * [INFO] BUILD FAILURE
+ * [INFO] ------------------------------------------------------------------------
+ * [INFO] Total time: 11.011s
+ * [INFO] Finished at: Thu Jul 15 13:59:14 CEST 2010
+ * [INFO] Final Memory: 24M/355M
+ * [INFO] ------------------------------------------------------------------------
+ * [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.5:test
+ * (default-test) on project xxxxxx: No tests were executed! (Set -DfailIfNoTests=false to
+ * ignore this error.) -> [Help 1]
+ * <p/>
+ * <p/>
+ * <dependency>
+ * <groupId>junit</groupId>
+ * <artifactId>junit</artifactId>
+ * <version>4.8.1</version>
+ * <scope>test</scope>
+ * </dependency>
+ * <p/>
+ * <dependency>
+ * <groupId>org.apache.maven.surefire</groupId>
+ * <artifactId>surefire-booter</artifactId>
+ * <version>2.6-SNAPSHOT</version>
+ * <scope>test</scope>
+ * </dependency>
+ * <dependency>
+ * <groupId>org.apache.maven.plugins</groupId>
+ * <artifactId>maven-surefire-plugin</artifactId>
+ * <version>2.6-SNAPSHOT</version>
+ * <scope>test</scope>
+ * </dependency>
+ * <dependency>
+ * <groupId>org.apache.maven.surefire</groupId>
+ * <artifactId>surefire-junit47</artifactId>
+ * <version>2.6-SNAPSHOT</version>
+ * <scope>test</scope>
+ * </dependency>
*
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
* @version $Revision: $
@@ -86,7 +86,7 @@ import java.util.List;
public class MavenSurefireJUnit47RunnerTestCase
{
- /*
+ /*
* Assumption:
* The ConcurrentReportingRunListener assumes a Test will be Started before it Fails or Finishes.
*
@@ -107,74 +107,69 @@ public class MavenSurefireJUnit47RunnerT
* and the recorded state will never be replayed on the ReportManager.
*
* The End result: ReporterManager falsely believe no Test were run.
- * t
- */
- @SuppressWarnings( { "unchecked", "ThrowableResultOfMethodCallIgnored" } )
- @Test
- public void surefireShouldBeAbleToReportRunStatusEvenWithFailingTests() throws Exception
- {
- Object[] reportDefinition = new Object[2];
- reportDefinition[0] = ConsoleReporter.class.getName();
- reportDefinition[1] = new Object[] {true};
-
- List reportDefinitions = new ArrayList();
- reportDefinitions.add(reportDefinition);
-
- ReporterConfiguration reporterConfiguration = ConcurrentReportingRunListenerTest.getTestReporterConfiguration();
-
- ReporterManagerFactory reporterManagerFactory = new ReporterManagerFactory(reportDefinitions, this.getClass().getClassLoader());
-
- ConcurrentReportingRunListener concurrentReportingRunListener = ConcurrentReportingRunListener.createInstance(
- reporterManagerFactory, false, false);
-
- Computer computer = new Computer();
-
- JUnitCore junitCore = new JUnitCore();
-
- junitCore.addListener(concurrentReportingRunListener);
-
- Result result = junitCore.run(computer, FailingTestClassTestNot.class);
-
- junitCore.removeListener(concurrentReportingRunListener);
-
- Assert.assertEquals(
- "JUnit should report correctly number of test ran(Finished)",
- 0,
- result.getRunCount());
-
- // Sys.out swallowed in ConsoleReporter..
- for(Failure failure : result.getFailures())
- {
- System.out.println(failure.getException().getMessage());
- }
-
- Assert.assertEquals(
- "There should only be one Exception reported, the one from the failing TestCase",
- 1,
- result.getFailureCount());
-
- Assert.assertEquals(
- "The exception thrown by the failing TestCase",
- RuntimeException.class,
- result.getFailures().get(0).getException().getClass());
- }
-
- /**
- * Simple TestCase to force a Exception in @BeforeClass.
*
*/
- public static class FailingTestClassTestNot
- {
- @BeforeClass
- public static void failingBeforeClass() throws Exception
- {
- throw new RuntimeException("Opps, we failed in @BeforeClass");
- }
-
- @Test
- public void shouldNeverBeCalled() throws Exception
- {
- Assert.assertTrue(true);
- }
- }
-}
\ No newline at end of file
+ @SuppressWarnings( { "unchecked", "ThrowableResultOfMethodCallIgnored" } )
+ @Test
+ public void surefireShouldBeAbleToReportRunStatusEvenWithFailingTests()
+ throws Exception
+ {
+ ReporterConfiguration reporterConfiguration = ConcurrentReportingRunListenerTest.getTestReporterConfiguration();
+
+ ReporterFactory reporterManagerFactory =
+ new ReporterManagerFactory( this.getClass().getClassLoader(), reporterConfiguration );
+
+ ConcurrentReportingRunListener concurrentReportingRunListener =
+ ConcurrentReportingRunListener.createInstance( reporterManagerFactory, getReporterConfiguration(), false,
+ false );
+
+ Computer computer = new Computer();
+
+ JUnitCore junitCore = new JUnitCore();
+
+ junitCore.addListener( concurrentReportingRunListener );
+
+ Result result = junitCore.run( computer, FailingTestClassTestNot.class );
+
+ junitCore.removeListener( concurrentReportingRunListener );
+
+ Assert.assertEquals( "JUnit should report correctly number of test ran(Finished)", 0, result.getRunCount() );
+
+ // Sys.out swallowed in ConsoleReporter..
+ for ( Failure failure : result.getFailures() )
+ {
+ System.out.println( failure.getException().getMessage() );
+ }
+
+ Assert.assertEquals( "There should only be one Exception reported, the one from the failing TestCase", 1,
+ result.getFailureCount() );
+
+ Assert.assertEquals( "The exception thrown by the failing TestCase", RuntimeException.class,
+ result.getFailures().get( 0 ).getException().getClass() );
+ }
+
+ private ReporterConfiguration getReporterConfiguration()
+ {
+ return new ReporterConfiguration( new ArrayList(), new File( "." ), true );
+ }
+
+ /**
+ * Simple TestCase to force a Exception in @BeforeClass.
+ */
+ public static class FailingTestClassTestNot
+ {
+ @BeforeClass
+ public static void failingBeforeClass()
+ throws Exception
+ {
+ throw new RuntimeException( "Opps, we failed in @BeforeClass" );
+ }
+
+ @Test
+ public void shouldNeverBeCalled()
+ throws Exception
+ {
+ Assert.assertTrue( true );
+ }
+ }
+}
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java Sat Dec 11 13:28:38 2010
@@ -21,80 +21,102 @@ package org.apache.maven.surefire.junitc
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.Reporter;
+import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.report.ReporterException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-public class MockReporter implements Reporter
+public class MockReporter
+ implements Reporter
{
- private final List<String> events = new ArrayList<String>( );
+ private final List<String> events = new ArrayList<String>();
+
public static final String RUN_STARTED = "RUN_STARTED";
+
public static final String RUN_COMPLETED = "RUN_COMPLETED";
+
public static final String SET_STARTED = "SET_STARTED";
+
public static final String SET_COMPLETED = "SET_COMPLETED";
+
public static final String TEST_STARTED = "TEST_STARTED";
+
public static final String TEST_COMPLETED = "TEST_COMPLETED";
- public static final String TEST_FAILED= "TEST_FAILED";
+
+ public static final String TEST_FAILED = "TEST_FAILED";
+
public static final String TEST_ERROR = "TEST_ERROR";
+
public static final String TEST_SKIPPED = "TEST_SKIPPED";
- private final AtomicInteger testSucceeded = new AtomicInteger( );
- private final AtomicInteger testIgnored = new AtomicInteger( );
- private final AtomicInteger testFailed = new AtomicInteger( );
- private final AtomicInteger testError = new AtomicInteger( );
+ private final AtomicInteger testSucceeded = new AtomicInteger();
+ private final AtomicInteger testIgnored = new AtomicInteger();
- public void runStarting( )
+ private final AtomicInteger testFailed = new AtomicInteger();
+
+ private final AtomicInteger testError = new AtomicInteger();
+
+ public MockReporter()
{
- events.add(RUN_STARTED);
+ }
+
+ public MockReporter( ReporterConfiguration reporterConfiguration )
+ {
+
+ }
+
+ public void runStarting()
+ {
+ events.add( RUN_STARTED );
}
public void runCompleted()
{
- events.add( RUN_COMPLETED);
+ events.add( RUN_COMPLETED );
}
public void testSetStarting( ReportEntry report )
throws ReporterException
{
- events.add( SET_STARTED);
+ events.add( SET_STARTED );
}
public void testSetCompleted( ReportEntry report )
throws ReporterException
{
- events.add( SET_COMPLETED);
+ events.add( SET_COMPLETED );
}
public void testStarting( ReportEntry report )
{
- events.add( TEST_STARTED);
+ events.add( TEST_STARTED );
}
public void testSucceeded( ReportEntry report )
{
- events.add( TEST_COMPLETED);
+ events.add( TEST_COMPLETED );
testSucceeded.incrementAndGet();
}
public void testError( ReportEntry report, String stdOut, String stdErr )
{
- events.add( TEST_ERROR);
+ events.add( TEST_ERROR );
testError.incrementAndGet();
}
public void testFailed( ReportEntry report, String stdOut, String stdErr )
{
- events.add( TEST_FAILED);
+ events.add( TEST_FAILED );
testFailed.incrementAndGet();
}
public void testSkipped( ReportEntry report )
{
- events.add( TEST_SKIPPED);
+ events.add( TEST_SKIPPED );
testIgnored.incrementAndGet();
}
@@ -110,6 +132,10 @@ public class MockReporter implements Rep
{
}
+ public void writeDetailMessage( String message )
+ {
+ }
+
public List<String> getEvents()
{
return events;
@@ -130,4 +156,7 @@ public class MockReporter implements Rep
return testFailed.get();
}
+ public void writeConsoleMessage( String message )
+ {
+ }
}
Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/SynchronizedReporterManager.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/SynchronizedReporterManager.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/SynchronizedReporterManager.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/SynchronizedReporterManager.java Sat Dec 11 13:28:38 2010
@@ -118,11 +118,6 @@ class SynchronizedReporterManager
super.writeMessage( message );
}
- public synchronized void writeFooter( String footer )
- {
- super.writeFooter( footer );
- }
-
public synchronized void writeConsoleMessage( String message )
{
super.writeConsoleMessage( message );
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=1044651&r1=1044650&r2=1044651&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 Sat Dec 11 13:28:38 2010
@@ -29,6 +29,7 @@ import java.util.Properties;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.apache.maven.surefire.report.DefaultReportEntry;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.ReporterManager;
@@ -49,31 +50,33 @@ public class TestNGDirectoryTestSuite
private ArtifactVersion version;
private String classifier;
-
+
private Map options;
private String testSourceDirectory;
-
+
private File reportsDirectory;
public TestNGDirectoryTestSuite( File basedir, ArrayList includes, ArrayList excludes, String testSourceDirectory,
- String artifactVersion, String artifactClassifier, Properties confOptions, File reportsDirectory )
+ String artifactVersion, String artifactClassifier, Properties confOptions,
+ File reportsDirectory )
{
this( basedir, includes, excludes, testSourceDirectory, new DefaultArtifactVersion( artifactVersion ),
artifactClassifier, confOptions, reportsDirectory );
}
public TestNGDirectoryTestSuite( File basedir, List includes, List excludes, String testSourceDirectory,
- ArtifactVersion artifactVersion, String artifactClassifier, Map confOptions, File reportsDirectory )
+ ArtifactVersion artifactVersion, String artifactClassifier, Map confOptions,
+ File reportsDirectory )
{
super( basedir, includes, excludes );
this.options = confOptions;
-
+
this.testSourceDirectory = testSourceDirectory;
this.reportsDirectory = reportsDirectory;
this.version = artifactVersion;
-
+
this.classifier = artifactClassifier;
}
@@ -101,9 +104,9 @@ public class TestNGDirectoryTestSuite
ReporterManager reporterManager = reporterManagerFactory.createReporterManager();
startTestSuite( reporterManager, this );
- TestNGExecutor.run( new Class[]{testSet.getTestClass()}, this.testSourceDirectory, this.options, this.version,
+ TestNGExecutor.run( new Class[]{ testSet.getTestClass() }, this.testSourceDirectory, this.options, this.version,
this.classifier, reporterManager, this, reportsDirectory );
-
+
finishTestSuite( reporterManager, this );
}
@@ -140,47 +143,49 @@ public class TestNGDirectoryTestSuite
testNgTestClasses.add( c );
}
}
-
+
File testNgReportsDirectory = reportsDirectory, junitReportsDirectory = reportsDirectory;
-
+
if ( junitTestClasses.size() > 0 && testNgTestClasses.size() > 0 )
{
- testNgReportsDirectory = new File( reportsDirectory, "testng-native-results");
- junitReportsDirectory = new File( reportsDirectory, "testng-junit-results");
+ testNgReportsDirectory = new File( reportsDirectory, "testng-native-results" );
+ junitReportsDirectory = new File( reportsDirectory, "testng-junit-results" );
}
ReporterManager reporterManager =
- new SynchronizedReporterManager( reporterManagerFactory.createReporterManager());
+ new SynchronizedReporterManager( reporterManagerFactory.createReporterManager() );
startTestSuite( reporterManager, this );
-
+
Class[] testClasses = (Class[]) testNgTestClasses.toArray( new Class[0] );
- TestNGExecutor.run( testClasses, this.testSourceDirectory, this.options, this.version,
- this.classifier, reporterManager, this, testNgReportsDirectory );
-
- if (junitTestClasses.size() > 0) {
+ TestNGExecutor.run( testClasses, this.testSourceDirectory, this.options, this.version, this.classifier,
+ reporterManager, this, testNgReportsDirectory );
+
+ if ( junitTestClasses.size() > 0 )
+ {
testClasses = (Class[]) junitTestClasses.toArray( new Class[0] );
-
+
Map junitOptions = new HashMap();
- for (Iterator it = this.options.keySet().iterator(); it.hasNext();) {
+ for ( Iterator it = this.options.keySet().iterator(); it.hasNext(); )
+ {
Object key = it.next();
junitOptions.put( key, options.get( key ) );
}
-
+
junitOptions.put( "junit", Boolean.TRUE );
-
+
TestNGExecutor.run( testClasses, this.testSourceDirectory, junitOptions, this.version, this.classifier,
reporterManager, this, junitReportsDirectory );
}
-
+
finishTestSuite( reporterManager, this );
}
public static void startTestSuite( ReporterManager reporterManager, Object suite )
{
String rawString = bundle.getString( "testSetStarting" );
-
- ReportEntry report = new ReportEntry( suite.getClass().getName(), getSuiteName(suite), rawString );
+
+ ReportEntry report = new DefaultReportEntry( suite.getClass().getName(), getSuiteName( suite ), rawString );
try
{
@@ -191,38 +196,44 @@ public class TestNGDirectoryTestSuite
// TODO: remove this exception from the report manager
}
}
-
+
public static void finishTestSuite( ReporterManager reporterManager, Object suite )
{
String rawString = bundle.getString( "testSetCompletedNormally" );
- ReportEntry report =
- new ReportEntry( suite.getClass().getName(), getSuiteName(suite), rawString );
+ ReportEntry report = new DefaultReportEntry( suite.getClass().getName(), getSuiteName( suite ), rawString );
reporterManager.testSetCompleted( report );
reporterManager.reset();
}
-
- public String getSuiteName() {
- String result = (String) options.get("suitename");
- if (result == null) {
+
+ public String getSuiteName()
+ {
+ String result = (String) options.get( "suitename" );
+ if ( result == null )
+ {
result = "TestSuite";
}
return result;
}
- private static String getSuiteName(Object suite)
+ private static String getSuiteName( Object suite )
{
String result;
- if (suite instanceof TestNGDirectoryTestSuite) {
- return ((TestNGDirectoryTestSuite) suite).getSuiteName();
- } else if (suite instanceof TestNGXmlTestSuite) {
- return ((TestNGXmlTestSuite) suite).getSuiteName();
- }else {
+ if ( suite instanceof TestNGDirectoryTestSuite )
+ {
+ return ( (TestNGDirectoryTestSuite) suite ).getSuiteName();
+ }
+ else if ( suite instanceof TestNGXmlTestSuite )
+ {
+ return ( (TestNGXmlTestSuite) suite ).getSuiteName();
+ }
+ else
+ {
result = "TestSuite";
}
return result;
- }
+ }
}
Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java?rev=1044651&r1=1044650&r2=1044651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java Sat Dec 11 13:28:38 2010
@@ -84,13 +84,13 @@ public class TestNGProvider
suite.locateTestSets( testClassLoader );
if ( forkTestSet != null && testRequest == null )
{
- suite.execute( (String) forkTestSet, (ReporterManagerFactory)reporterFactory, testClassLoader );
+ suite.execute( (String) forkTestSet, (ReporterManagerFactory) reporterFactory, testClassLoader );
}
else
{
- suite.execute( (ReporterManagerFactory)reporterFactory, testClassLoader );
+ suite.execute( (ReporterManagerFactory) reporterFactory, testClassLoader );
}
- reporterFactory.warnIfNoTests();
+
return reporterFactory.close();
}
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=1044651&r1=1044650&r2=1044651&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 Sat Dec 11 13:28:38 2010
@@ -22,6 +22,7 @@ package org.apache.maven.surefire.testng
import java.util.ResourceBundle;
import org.apache.maven.surefire.Surefire;
+import org.apache.maven.surefire.report.DefaultReportEntry;
import org.apache.maven.surefire.report.PojoStackTraceWriter;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.ReporterManager;
@@ -74,11 +75,12 @@ public class TestNGReporter
{
String rawString = bundle.getString( "testStarting" );
String group = groupString( result.getMethod().getGroups(), result.getTestClass().getName() );
- ReportEntry report = new ReportEntry( getSource( result ), getUserFriendlyTestName( result ), group, rawString );
+ ReportEntry report =
+ new DefaultReportEntry( getSource( result ), getUserFriendlyTestName( result ), group, rawString );
reportManager.testStarting( report );
}
-
+
private String getSource( ITestResult result )
{
return result.getTestClass().getName();
@@ -86,8 +88,8 @@ public class TestNGReporter
public void onTestSuccess( ITestResult result )
{
- ReportEntry report =
- new ReportEntry( getSource( result ), getUserFriendlyTestName( result ), bundle.getString( "testSuccessful" ) );
+ ReportEntry report = new DefaultReportEntry( getSource( result ), getUserFriendlyTestName( result ),
+ bundle.getString( "testSuccessful" ) );
reportManager.testSucceeded( report );
}
@@ -95,9 +97,10 @@ public class TestNGReporter
{
String rawString = bundle.getString( "executeException" );
- ReportEntry report = new ReportEntry( getSource( result ), getUserFriendlyTestName( result ), rawString,
- new PojoStackTraceWriter( result.getTestClass().getRealClass().getName(),
- result.getMethod().getMethodName(), result.getThrowable() ) );
+ ReportEntry report = new DefaultReportEntry( getSource( result ), getUserFriendlyTestName( result ), rawString,
+ new PojoStackTraceWriter(
+ result.getTestClass().getRealClass().getName(),
+ result.getMethod().getMethodName(), result.getThrowable() ) );
reportManager.testFailed( report );
}
@@ -110,8 +113,8 @@ public class TestNGReporter
public void onTestSkipped( ITestResult result )
{
- ReportEntry report =
- new ReportEntry( getSource( result ), getUserFriendlyTestName( result ), bundle.getString( "testSkipped" ) );
+ ReportEntry report = new DefaultReportEntry( getSource( result ), getUserFriendlyTestName( result ),
+ bundle.getString( "testSkipped" ) );
reportManager.testSkipped( report );
}
@@ -120,30 +123,30 @@ public class TestNGReporter
{
String rawString = bundle.getString( "executeException" );
- ReportEntry report =
- new ReportEntry( getSource( result ), getUserFriendlyTestName( result ), rawString,
- new PojoStackTraceWriter( result.getTestClass().getRealClass().getName(),
- result.getMethod().getMethodName(), result.getThrowable() ) );
+ ReportEntry report = new DefaultReportEntry( getSource( result ), getUserFriendlyTestName( result ), rawString,
+ new PojoStackTraceWriter(
+ result.getTestClass().getRealClass().getName(),
+ result.getMethod().getMethodName(), result.getThrowable() ) );
reportManager.testError( report );
}
public void onStart( ITestContext context )
{
-
+
}
public void onFinish( ITestContext context )
{
-
+
}
public void onStart( ISuite suite )
{
-
+
}
-
+
public void onFinish( ISuite suite )
{