You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2011/06/06 22:16:10 UTC
svn commit: r1132744 - in /maven/surefire/trunk:
surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/
surefire-integration-tests/src/test/resources/junit4-runlistener/
surefire-integration-tests/src/test/resources/junit4-runlistener/...
Author: krosenvold
Date: Mon Jun 6 20:16:10 2011
New Revision: 1132744
URL: http://svn.apache.org/viewvc?rev=1132744&view=rev
Log:
[SUREFIRE-743] run-level RunListener method support for junit4
Updated IT to cover 4.x and 4.7 provider feature
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/EchoingRunListener.java (with props)
Modified:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RunListenerIT.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/pom.xml
maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RunListenerIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RunListenerIT.java?rev=1132744&r1=1132743&r2=1132744&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RunListenerIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RunListenerIT.java Mon Jun 6 20:16:10 2011
@@ -43,6 +43,9 @@ public class JUnit4RunListenerIT
executeTest();
verifyErrorFreeLog();
assertResults();
+ verifyTextInLog( "testRunStarted null" );
+ verifyTextInLog( "testFinished simpleTest" );
+ verifyTextInLog( "testRunFinished org.junit.runner.Result" );
}
private void assertResults()
@@ -62,6 +65,9 @@ public class JUnit4RunListenerIT
executeTest();
verifyErrorFreeLog();
assertResults();
+ verifyTextInLog( "testRunStarted null" );
+ verifyTextInLog( "testFinished simpleTest" );
+ verifyTextInLog( "testRunFinished org.junit.runner.Result" );
}
private void assertFileExists( final File file )
Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/pom.xml?rev=1132744&r1=1132743&r2=1132744&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/pom.xml (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/pom.xml Mon Jun 6 20:16:10 2011
@@ -60,7 +60,7 @@
<properties>
<property>
<name>listener</name>
- <value>runListener.FileWritingRunListener1,runListener.FileWritingRunListener2</value>
+ <value>runListener.FileWritingRunListener1,runListener.FileWritingRunListener2,runListener.EchoingRunListener</value>
</property>
</properties>
</configuration>
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/EchoingRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/EchoingRunListener.java?rev=1132744&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/EchoingRunListener.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/EchoingRunListener.java Mon Jun 6 20:16:10 2011
@@ -0,0 +1,63 @@
+package runListener;
+
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunListener;
+
+/**
+ * {@link org.junit.runner.notification.RunListener} to generate an output file whose existence can be checked by surefire-integration.
+ *
+ * @author <a href="mailto:matthew.gilliard@gmail.com">Matthew Gilliard</a>
+ */
+public class EchoingRunListener
+ extends RunListener
+{
+
+ @Override
+ public void testRunStarted( Description description )
+ throws Exception
+ {
+ System.out.println("testRunStarted " + description);
+ }
+
+ @Override
+ public void testRunFinished( Result result )
+ throws Exception
+ {
+ System.out.println("testRunFinished " + result);
+ }
+
+ @Override
+ public void testStarted( Description description )
+ throws Exception
+ {
+ System.out.println("testStarted " + description);
+ }
+
+ @Override
+ public void testFinished( Description description )
+ throws Exception
+ {
+ System.out.println("testFinished " + description);
+ }
+
+ @Override
+ public void testFailure( Failure failure )
+ throws Exception
+ {
+ System.out.println("testFailure " + failure);
+ }
+
+ @Override
+ public void testIgnored( Description description )
+ throws Exception
+ {
+ System.out.println("testIgnored " + description);
+ }
+
+ public void testAssumptionFailure( Failure failure )
+ {
+ System.out.println("testAssumptionFailure " + failure);
+ }
+}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/EchoingRunListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java?rev=1132744&r1=1132743&r2=1132744&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java Mon Jun 6 20:16:10 2011
@@ -40,6 +40,7 @@ import org.apache.maven.surefire.util.De
import org.apache.maven.surefire.util.DirectoryScanner;
import org.apache.maven.surefire.util.TestsToRun;
+import org.junit.runner.Result;
import org.junit.runner.notification.RunNotifier;
/**
@@ -77,7 +78,6 @@ public class JUnit4Provider
public RunResult invoke( Object forkTestSet )
throws TestSetFailedException, ReporterException
{
- long start = System.currentTimeMillis();
if ( testsToRun == null )
{
testsToRun = forkTestSet == null ? scanClassPath() : TestsToRun.fromClass( (Class) forkTestSet );
@@ -88,23 +88,26 @@ public class JUnit4Provider
final ReporterFactory reporterFactory = providerParameters.getReporterFactory();
final RunListener reporter = reporterFactory.createReporter();
- //final AsynchRunListener asynchRunListener = new AsynchRunListener( reporter , "JUnitProvider");
- final RunListener asynchRunListener = reporter;
- ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) asynchRunListener );
- JUnit4RunListener jUnit4TestSetReporter = new JUnit4RunListener( asynchRunListener );
+ ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter );
- RunNotifier runNotifer = getRunNotifer( jUnit4TestSetReporter, customRunListeners );
+ JUnit4RunListener jUnit4TestSetReporter = new JUnit4RunListener( reporter );
+
+ Result result = new Result();
+ RunNotifier runNotifer = getRunNotifer( jUnit4TestSetReporter, result, customRunListeners );
+
+ runNotifer.fireTestRunStarted( null );
for ( Class clazz : testsToRun.getLocatedClasses() )
{
executeTestSet( clazz, reporter, runNotifer );
}
+ runNotifer.fireTestRunFinished( result );
+
closeRunNotifer( jUnit4TestSetReporter, customRunListeners );
- //asynchRunListener.close();
return reporterFactory.close();
}
@@ -135,11 +138,11 @@ public class JUnit4Provider
}
}
- private RunNotifier getRunNotifer( org.junit.runner.notification.RunListener main,
- List<org.junit.runner.notification.RunListener> others )
+ private RunNotifier getRunNotifer( org.junit.runner.notification.RunListener main, Result result, List<org.junit.runner.notification.RunListener> others )
{
RunNotifier fNotifier = new RunNotifier();
fNotifier.addListener( main );
+ fNotifier.addListener( result.createListener() );
for ( org.junit.runner.notification.RunListener listener : others )
{
fNotifier.addListener( listener );