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 2012/01/27 21:42:03 UTC
svn commit: r1236882 - in /maven/surefire/trunk:
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/
surefire-api/src/main/java/org/apach...
Author: krosenvold
Date: Fri Jan 27 20:42:02 2012
New Revision: 1236882
URL: http://svn.apache.org/viewvc?rev=1236882&view=rev
Log:
[SUREFIRE-537] Added message attribute to skipped/assumption failed tests
Added:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
- copied, changed from r1236550, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/StackTraceWriter.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/IgnoreWithMessagesTest.java (with props)
maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java (with props)
maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector40Test.java (with props)
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4Reflector481Test.java (with props)
Modified:
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/MulticastingReporter.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/XMLReporter.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.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/RunStatistics.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SimpleReportEntry.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/StackTraceWriter.java
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit4IgnoreIT.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test2.java
maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java Fri Jan 27 20:42:02 2012
@@ -19,6 +19,7 @@ package org.apache.maven.plugin.surefire
* under the License.
*/
+import org.apache.maven.surefire.report.SafeThrowable;
import org.apache.maven.surefire.report.StackTraceWriter;
/**
@@ -53,8 +54,8 @@ public class DeserializedStacktraceWrite
return stackTrace;
}
- public Throwable getThrowable()
+ public SafeThrowable getThrowable()
{
- return new Throwable( message );
+ return new SafeThrowable( new Throwable( message ));
}
}
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java Fri Jan 27 20:42:02 2012
@@ -179,14 +179,15 @@ public class ForkClient
String source = tokens.nextToken();
String name = tokens.nextToken();
String group = nullableCsv( tokens.nextToken() );
+ String message = nullableCsv( tokens.nextToken() );
String elapsedStr = tokens.nextToken();
Integer elapsed = "null".equals( elapsedStr ) ? null : Integer.decode( elapsedStr );
final StackTraceWriter stackTraceWriter =
tokens.hasMoreTokens() ? deserializeStackStraceWriter( tokens ) : null;
return group != null
- ? new CategorizedReportEntry( source, name, group, stackTraceWriter, elapsed )
- : new SimpleReportEntry( source, name, stackTraceWriter, elapsed );
+ ? new CategorizedReportEntry( source, name, group, stackTraceWriter, elapsed, message )
+ : new SimpleReportEntry( source, name, stackTraceWriter, elapsed, message );
}
catch ( RuntimeException e )
{
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/MulticastingReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/MulticastingReporter.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/MulticastingReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/MulticastingReporter.java Fri Jan 27 20:42:02 2012
@@ -113,7 +113,8 @@ public class MulticastingReporter
}
return new CategorizedReportEntry( other.getSourceName(), other.getName(), other.getGroup(),
other.getStackTraceWriter(),
- (int) ( System.currentTimeMillis() - this.lastStartAt ) );
+ (int) ( System.currentTimeMillis() - this.lastStartAt ),
+ other.getMessage());
}
public void writeMessage( String message )
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/XMLReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/XMLReporter.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/XMLReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/XMLReporter.java Fri Jan 27 20:42:02 2012
@@ -35,6 +35,7 @@ import java.util.Properties;
import java.util.StringTokenizer;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.report.SafeThrowable;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomWriter;
@@ -295,29 +296,27 @@ public class XMLReporter
String stackTrace = getStackTrace( report );
- Throwable t = null;
- if ( report.getStackTraceWriter() != null )
+ if ( report.getMessage() != null && report.getMessage().length() > 0)
{
- //noinspection ThrowableResultOfMethodCallIgnored
- t = report.getStackTraceWriter().getThrowable();
+ element.setAttribute( "message", report.getMessage() );
}
- if ( t != null )
+ if ( report.getStackTraceWriter() != null )
{
-
- String message = t.getMessage();
-
- if ( message != null )
- {
- element.setAttribute( "message", message );
-
- element.setAttribute( "type", ( stackTrace.indexOf( ":" ) > -1
- ? stackTrace.substring( 0, stackTrace.indexOf( ":" ) )
- : stackTrace ) );
- }
- else
+ //noinspection ThrowableResultOfMethodCallIgnored
+ SafeThrowable t = report.getStackTraceWriter().getThrowable();
+ if ( t != null )
{
- element.setAttribute( "type", new StringTokenizer( stackTrace ).nextToken() );
+ if ( t.getMessage() != null )
+ {
+ element.setAttribute( "type", ( stackTrace.indexOf( ":" ) > -1
+ ? stackTrace.substring( 0, stackTrace.indexOf( ":" ) )
+ : stackTrace ) );
+ }
+ else
+ {
+ element.setAttribute( "type", new StringTokenizer( stackTrace ).nextToken() );
+ }
}
}
@@ -353,7 +352,11 @@ public class XMLReporter
/**
* Adds system properties to the XML report.
*
+<<<<<<< HEAD
* @param testSuite The test suite to report to
+=======
+ * @param testSuite the target dom suite
+>>>>>>> [SUREFIRE-537]
*/
private void showProperties( Xpp3Dom testSuite )
{
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java Fri Jan 27 20:42:02 2012
@@ -26,6 +26,7 @@ import org.apache.maven.surefire.report.
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.RunListener;
+import org.apache.maven.surefire.report.SafeThrowable;
import org.apache.maven.surefire.report.StackTraceWriter;
import org.apache.maven.surefire.util.internal.ByteBuffer;
import org.apache.maven.surefire.util.internal.StringUtils;
@@ -248,6 +249,7 @@ public class ForkingRunListener
nullableEncoding( stringBuffer, reportEntry.getSourceName() ).comma( stringBuffer );
nullableEncoding( stringBuffer, reportEntry.getName() ).comma( stringBuffer );
nullableEncoding( stringBuffer, reportEntry.getGroup() ).comma( stringBuffer );
+ nullableEncoding( stringBuffer, reportEntry.getMessage() ).comma( stringBuffer );
nullableEncoding( stringBuffer, reportEntry.getElapsed() );
encode( stringBuffer, reportEntry.getStackTraceWriter() );
stringBuffer.append( "\n" );
@@ -308,10 +310,10 @@ public class ForkingRunListener
{
comma( stringBuffer );
//noinspection ThrowableResultOfMethodCallIgnored
- final Throwable throwable = stackTraceWriter.getThrowable();
+ final SafeThrowable throwable = stackTraceWriter.getThrowable();
if ( throwable != null )
{
- String message = safeGetLocalizedMessage( throwable );
+ String message = throwable.getLocalizedMessage();
nullableEncoding( stringBuffer, message );
}
comma( stringBuffer );
@@ -321,16 +323,4 @@ public class ForkingRunListener
: stackTraceWriter.writeTraceToString() );
}
}
-
- private String safeGetLocalizedMessage( Throwable throwable )
- {
- try
- {
- return throwable.getLocalizedMessage();
- }
- catch ( Throwable t )
- {
- return t.getLocalizedMessage();
- }
- }
}
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java Fri Jan 27 20:42:02 2012
@@ -33,13 +33,18 @@ public class CategorizedReportEntry
this( source, name, group, null, null );
}
- public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
- Integer elapsed )
+ public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter, Integer elapsed )
{
super( source, name, stackTraceWriter, elapsed );
this.group = group;
}
+ public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter, Integer elapsed, String message )
+ {
+ super( source, name, stackTraceWriter, elapsed, message );
+ this.group = group;
+ }
+
public String getGroup()
{
return group;
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java Fri Jan 27 20:42:02 2012
@@ -99,8 +99,8 @@ public class PojoStackTraceWriter
return trace.toString();
}
- public Throwable getThrowable()
+ public SafeThrowable getThrowable()
{
- return t;
+ return new SafeThrowable( t);
}
}
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=1236882&r1=1236881&r2=1236882&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 27 20:42:02 2012
@@ -21,13 +21,40 @@ package org.apache.maven.surefire.report
public interface ReportEntry
{
+ /**
+ * The class name of the test
+ * @return A string with the class name
+ */
public String getSourceName();
+ /**
+ * The name of the test case
+ * @return A string describing the test case
+ */
public String getName();
+ /**
+ * The group/category of the testcase
+ * @return A string
+ */
public String getGroup();
+ /**
+ * The group/category of the testcase
+ * @return A string
+ */
public StackTraceWriter getStackTraceWriter();
+ /**
+ * @deprecated
+ **/
public Integer getElapsed();
+
+
+ /**
+ * A message relating to a non-successful termination.
+ * May be the "message" from an exception or the reason for a test being ignored
+ * @return A string that explains an anomaly
+ */
+ public String getMessage();
}
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java Fri Jan 27 20:42:02 2012
@@ -102,7 +102,7 @@ public class RunStatistics
return stackTraceWriter != null ? getMessageOfThrowable( stackTraceWriter.getThrowable() ) : "";
}
- private String getMessageOfThrowable( Throwable throwable )
+ private String getMessageOfThrowable( SafeThrowable throwable )
{
return throwable != null ? throwable.getLocalizedMessage() : "";
}
Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java (from r1236550, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/StackTraceWriter.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/StackTraceWriter.java&r1=1236550&r2=1236882&rev=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/StackTraceWriter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java Fri Jan 27 20:42:02 2012
@@ -1,5 +1,4 @@
package org.apache.maven.surefire.report;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -20,30 +19,38 @@ package org.apache.maven.surefire.report
*/
/**
- * Ability to write a stack trace, filtered to omit locations inside Surefire and Maven.
- *
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * Guards against misbehaving throwables
*/
-public interface StackTraceWriter
+public class SafeThrowable
{
- /**
- * Write the throwable to a string, without trimming.
- *
- * @return the trace
- */
- String writeTraceToString();
+ private final Throwable target;
+
+ public SafeThrowable( Throwable target )
+ {
+ this.target = target;
+ }
- /**
- * Write the throwable to a string, trimming extra locations.
- *
- * @return the trace
- */
- String writeTrimmedTraceToString();
+ public String getLocalizedMessage()
+ {
+ try
+ {
+ return target.getLocalizedMessage();
+ }
+ catch ( Throwable t )
+ {
+ return t.getLocalizedMessage();
+ }
+ }
- /**
- * Retrieve the throwable for this writer.
- *
- * @return the throwable
- */
- Throwable getThrowable();
+ public String getMessage()
+ {
+ try
+ {
+ return target.getMessage();
+ }
+ catch ( Throwable t )
+ {
+ return t.getMessage();
+ }
+ }
}
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SimpleReportEntry.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SimpleReportEntry.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SimpleReportEntry.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SimpleReportEntry.java Fri Jan 27 20:42:02 2012
@@ -33,11 +33,18 @@ public class SimpleReportEntry
private final Integer elapsed;
+ private final String message;
+
public SimpleReportEntry( String source, String name )
{
this( source, name, null, null );
}
+ public SimpleReportEntry( String source, String name, String message )
+ {
+ this( source, name, null, null, message );
+ }
+
public SimpleReportEntry( String source, String name, StackTraceWriter stackTraceWriter )
{
this( source, name, stackTraceWriter, null );
@@ -52,6 +59,7 @@ public class SimpleReportEntry
{
this.name = name;
this.stackTraceWriter = null;
+ this.message = null;
this.elapsed = null;
this.source = null;
}
@@ -59,6 +67,27 @@ public class SimpleReportEntry
public SimpleReportEntry( String source, String name, StackTraceWriter stackTraceWriter, Integer elapsed )
{
+ //noinspection ThrowableResultOfMethodCallIgnored
+ this( source, name, stackTraceWriter, elapsed, safeGetMessage( stackTraceWriter ) );
+ }
+
+ private static String safeGetMessage( StackTraceWriter stackTraceWriter )
+ {
+ try
+ {
+ return ( stackTraceWriter != null && stackTraceWriter.getThrowable() != null )
+ ? stackTraceWriter.getThrowable().getMessage()
+ : null;
+ }
+ catch ( Throwable t )
+ {
+ return t.getMessage();
+ }
+ }
+
+ public SimpleReportEntry( String source, String name, StackTraceWriter stackTraceWriter, Integer elapsed,
+ String message )
+ {
if ( source == null )
{
throw new NullPointerException( "source is null" );
@@ -74,10 +103,11 @@ public class SimpleReportEntry
this.stackTraceWriter = stackTraceWriter;
+ this.message = message;
+
this.elapsed = elapsed;
}
-
public String getSourceName()
{
return source;
@@ -106,9 +136,13 @@ public class SimpleReportEntry
public String toString()
{
return "ReportEntry{" + "source='" + source + '\'' + ", name='" + name + '\'' + ", stackTraceWriter="
- + stackTraceWriter + ", elapsed=" + elapsed + '}';
+ + stackTraceWriter + ", elapsed=" + elapsed + ",message=" + message + '}';
}
+ public String getMessage()
+ {
+ return message;
+ }
/**
* @noinspection RedundantIfStatement
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/StackTraceWriter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/StackTraceWriter.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/StackTraceWriter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/StackTraceWriter.java Fri Jan 27 20:42:02 2012
@@ -45,5 +45,5 @@ public interface StackTraceWriter
*
* @return the throwable
*/
- Throwable getThrowable();
+ SafeThrowable getThrowable();
}
Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit4IgnoreIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit4IgnoreIT.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit4IgnoreIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit4IgnoreIT.java Fri Jan 27 20:42:02 2012
@@ -32,12 +32,13 @@ public class Junit4IgnoreIT
{
public void testJunit4Ignore()
{
- unpack().executeTest().verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 3 );
+ // Todo: Support assumption failure == ignore for junit4
+ unpack().executeTest().verifyErrorFreeLog().assertTestSuiteResults( 7, 0, 0, 6 );
}
public void testJunit47ParallelIgnore()
{
- unpack().setJUnitVersion( "4.8.1" ).parallelClasses().executeTest().verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 3 );
+ unpack().setJUnitVersion( "4.8.1" ).parallelClasses().executeTest().verifyErrorFreeLog().assertTestSuiteResults( 7, 0, 0, 7 );
}
private SurefireLauncher unpack()
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/IgnoreWithMessagesTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/IgnoreWithMessagesTest.java?rev=1236882&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/IgnoreWithMessagesTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/IgnoreWithMessagesTest.java Fri Jan 27 20:42:02 2012
@@ -0,0 +1,38 @@
+package junit.ignore;
+
+import org.junit.Assume;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class IgnoreWithMessagesTest
+{
+
+ @Ignore
+ @Test
+ public void testWithIgnore1()
+ {
+ }
+
+ @Ignore("Ignorance is bliss2")
+ @Test
+ public void testWithIgnore2()
+ {
+ }
+
+ @Ignore("Ignorance \"is\' <>bliss2")
+ @Test
+ public void testWithQuotesInIgnore()
+ {
+ }
+
+ @Test
+ public void testWithAssumptionFailure()
+ {
+ Assume.assumeNotNull( new Object[]{ null} );
+ }
+
+}
+
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/IgnoreWithMessagesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test2.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test2.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test2.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test2.java Fri Jan 27 20:42:02 2012
@@ -25,7 +25,7 @@ public class Test2
{
}
- @Ignore
+ @Ignore("Ignorance is bliss2")
@Test
public void testWithIgnore2()
{
Added: maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java?rev=1236882&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java (added)
+++ maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java Fri Jan 27 20:42:02 2012
@@ -0,0 +1,52 @@
+package org.apache.maven.surefire.common.junit4;
+
+/*
+ * 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.
+ */
+
+import java.lang.reflect.Method;
+import org.apache.maven.surefire.util.ReflectionUtils;
+
+import org.junit.Ignore;
+import org.junit.runner.Description;
+
+public final class JUnit4Reflector
+{
+ private static final Class[] params = new Class[]{ Class.class };
+
+ private static final Class[] ignoreParams = new Class[]{ Ignore.class };
+
+ public Ignore getAnnotatedIgnore( Description description )
+ {
+ Method getAnnotation = ReflectionUtils.tryGetMethod( description.getClass(), "getAnnotation", params );
+
+ if ( getAnnotation == null )
+ {
+ return null;
+ }
+
+ return (Ignore) ReflectionUtils.invokeMethodWithArray( description, getAnnotation, ignoreParams );
+ }
+
+ public String getAnnotatedIgnoreValue( Description description )
+ {
+ final Ignore ignore = getAnnotatedIgnore( description );
+ return ignore != null ? ignore.value() : null;
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java (original)
+++ maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java Fri Jan 27 20:42:02 2012
@@ -48,6 +48,8 @@ public class JUnit4RunListener
*/
private final ThreadLocal<Boolean> failureFlag = new InheritableThreadLocal<Boolean>();
+ private final JUnit4Reflector jUnit4Reflector = new JUnit4Reflector();
+
/**
* Constructor.
*
@@ -68,7 +70,10 @@ public class JUnit4RunListener
public void testIgnored( Description description )
throws Exception
{
- reporter.testSkipped( createReportEntry( description ) );
+ final String reason = jUnit4Reflector.getAnnotatedIgnoreValue( description );
+ final SimpleReportEntry report =
+ new SimpleReportEntry( extractClassName( description ), description.getDisplayName(), reason );
+ reporter.testSkipped( report );
}
/**
Modified: maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java?rev=1236882&r1=1236881&r2=1236882&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java (original)
+++ maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java Fri Jan 27 20:42:02 2012
@@ -20,6 +20,7 @@ package org.apache.maven.surefire.common
*/
import org.apache.maven.surefire.report.PojoStackTraceWriter;
+import org.apache.maven.surefire.report.SafeThrowable;
import org.apache.maven.surefire.report.StackTraceWriter;
import org.junit.runner.notification.Failure;
@@ -78,9 +79,9 @@ public class JUnit4StackTraceWriter
*
* @see org.apache.maven.surefire.report.StackTraceWriter#getThrowable()
*/
- public Throwable getThrowable()
+ public SafeThrowable getThrowable()
{
- return junitFailure.getException();
+ return new SafeThrowable( junitFailure.getException());
}
}
Added: maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector40Test.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector40Test.java?rev=1236882&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector40Test.java (added)
+++ maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector40Test.java Fri Jan 27 20:42:02 2012
@@ -0,0 +1,37 @@
+package org.apache.maven.surefire.common.junit4;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.Description;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class JUnit4Reflector40Test
+ extends TestCase
+{
+ @Test
+ public void testGetAnnotatedIgnore()
+ {
+ JUnit4Reflector reflector = new JUnit4Reflector();
+ Description desc = Description.createTestDescription( IgnoreWithDescription.class, "testSomething2" );
+ Ignore annotatedIgnore = reflector.getAnnotatedIgnore( desc );
+ Assert.assertNull( annotatedIgnore );
+ }
+
+ private static final String reason = "Ignorance is bliss";
+
+ public static class IgnoreWithDescription
+ {
+
+ @Test
+ @Ignore( reason )
+ public void testSomething2()
+ {
+ }
+ }
+}
+
+
Propchange: maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector40Test.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1236882&r1=1236881&r2=1236882&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 Fri Jan 27 20:42:02 2012
@@ -123,7 +123,7 @@ class TestMethod
{
int elapsed = (int) ( endTime - startTime );
return new CategorizedReportEntry( description.getSourceName(), description.getName(), description.getGroup(),
- description.getStackTraceWriter(), elapsed );
+ description.getStackTraceWriter(), elapsed, description.getMessage() );
}
public void attachToThread()
Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4Reflector481Test.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4Reflector481Test.java?rev=1236882&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4Reflector481Test.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4Reflector481Test.java Fri Jan 27 20:42:02 2012
@@ -0,0 +1,63 @@
+package org.apache.maven.surefire.junitcore;
+
+/*
+ * 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.
+ */
+import org.apache.maven.surefire.common.junit4.JUnit4Reflector;
+import org.apache.maven.surefire.util.ReflectionUtils;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.Description;
+
+/**
+ * Reflector Test with junit 4.8.1
+ * @author Kristian Rosenvold
+ */
+public class JUnit4Reflector481Test
+{
+ private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+
+ @Test
+ public void testGetAnnotatedIgnore(){
+ JUnit4Reflector reflector = new JUnit4Reflector();
+ final Method testSomething2 =
+ ReflectionUtils.getMethod( IgnoreWithDescription.class, "testSomething2", EMPTY_CLASS_ARRAY );
+ final Annotation[] annotations = testSomething2.getAnnotations();
+ Description desc = Description.createTestDescription( IgnoreWithDescription.class, "testSomething2", annotations );
+ Ignore annotatedIgnore = reflector.getAnnotatedIgnore( desc );
+ Assert.assertEquals( reason, annotatedIgnore.value() );
+ }
+
+ private static final String reason = "Ignorance is bliss";
+ public static class IgnoreWithDescription
+ {
+
+ @Test
+ @Ignore( reason )
+ public void testSomething2()
+ {
+ }
+ }
+
+
+}
Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4Reflector481Test.java
------------------------------------------------------------------------------
svn:eol-style = native