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/12/20 15:54:07 UTC

git commit: o Improved junit3 support

Updated Branches:
  refs/heads/master 93beca951 -> 6085acec2


o Improved junit3 support


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/6085acec
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/6085acec
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/6085acec

Branch: refs/heads/master
Commit: 6085acec29d8912786734bcc67d382a23d0ffc38
Parents: 93beca9
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Thu Dec 20 15:53:23 2012 +0100
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Thu Dec 20 15:53:46 2012 +0100

----------------------------------------------------------------------
 .../surefire/report/SmartStackTraceParser.java     |   15 ++++-
 .../surefire/report/SmartStackTraceParserTest.java |   45 +++++++++++++++
 2 files changed, 58 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6085acec/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
index ebdfa40..754494f 100644
--- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
+++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
@@ -111,7 +111,14 @@ public class SmartStackTraceParser
         result.deleteCharAt( result.length() - 1 );
         result.deleteCharAt( result.length() - 1 );
 
-        if ( throwable.getTarget() instanceof AssertionError )
+        Throwable target = throwable.getTarget();
+        if ( target instanceof AssertionError )
+        {
+            result.append( " " );
+            result.append( throwable.getMessage() );
+        }
+        else if ( "junit.framework.AssertiponFailedError".equals( target.getClass().getName() )
+            || "junit.framework.ComparisonFailure".equals( target.getClass().getName() ) )
         {
             result.append( " " );
             result.append( throwable.getMessage() );
@@ -119,7 +126,7 @@ public class SmartStackTraceParser
         else
         {
             result.append( rootIsInclass() ? " " : " ยป " );
-            result.append( getMinimalThrowableMiniMessage( throwable.getTarget() ) );
+            result.append( getMinimalThrowableMiniMessage( target ) );
             result.append( getTruncatedMessage( 77 - result.length() ) );
         }
         return result.toString();
@@ -182,6 +189,10 @@ public class SmartStackTraceParser
 
     private static boolean isInSupers( Class testClass, String lookFor )
     {
+        if ( lookFor.startsWith( "junit.framework." ) )
+        {
+            return false;
+        }
         while ( !testClass.getName().equals( lookFor ) && testClass.getSuperclass() != null )
         {
             testClass = testClass.getSuperclass();

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6085acec/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
index b8c6c0e..03dd5e4 100644
--- a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
+++ b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
@@ -21,8 +21,10 @@ package org.apache.maven.surefire.report;
 import java.util.List;
 
 import junit.framework.Assert;
+import junit.framework.ComparisonFailure;
 import junit.framework.TestCase;
 
+@SuppressWarnings( "ThrowableResultOfMethodCallIgnored" )
 public class SmartStackTraceParserTest
     extends TestCase
 {
@@ -129,6 +131,22 @@ public class SmartStackTraceParserTest
         }
     }
 
+    public void testClassThatWillFail()
+        throws Exception
+    {
+        CaseThatWillFail aTestClass = new CaseThatWillFail();
+        try
+        {
+            aTestClass.testThatWillFail();
+        }
+        catch ( ComparisonFailure e )
+        {
+            SmartStackTraceParser smartStackTraceParser = new SmartStackTraceParser( CaseThatWillFail.class, e );
+            String res = smartStackTraceParser.getString();
+            assertEquals( "SmartStackTraceParserTest$CaseThatWillFail.testThatWillFail:170 expected:<abc> but was:<def>", res );
+        }
+    }
+
     static class ADifferen0tTestClass
     {
         static class InnerATestClass
@@ -145,6 +163,15 @@ public class SmartStackTraceParserTest
         }
     }
 
+    static class CaseThatWillFail
+        extends TestCase
+    {
+        public void testThatWillFail()
+        {
+            assertEquals( "abc", "def" );
+        }
+    }
+
     static class TestClass2
     {
         static class InnerCTestClass
@@ -207,6 +234,16 @@ public class SmartStackTraceParserTest
         assertEquals( TestClass1.InnerBTestClass.class.getName(), outer.getClassName() );
     }
 
+    public void testAssertionWithNoMessage(){
+        try {
+        new AssertionNoMessage().testThrowSomething();
+        } catch(ComparisonFailure e){
+            SmartStackTraceParser smartStackTraceParser = new SmartStackTraceParser( AssertionNoMessage.class, e );
+            String res = smartStackTraceParser.getString();
+            assertEquals( "SmartStackTraceParserTest$AssertionNoMessage.testThrowSomething:270 expected:<abc> but was:<xyz>", res );
+        }
+    }
+
     public void testCollectorWithNested()
     {
         try
@@ -226,5 +263,13 @@ public class SmartStackTraceParserTest
         }
     }
 
+    static class AssertionNoMessage
+        extends TestCase
+    {
+        public void testThrowSomething()
+        {
+            assertEquals( "abc", "xyz" );
+        }
+    }
 
 }


Re: git commit: o Improved junit3 support

Posted by Kristian Rosenvold <kr...@zenior.no>.
I suppose it logically must be so that a typo points to missing test
coverage.... Well not this typo - any more!

Thanks,

Kristian

Den 21. des. 2012 kl. 00:58 skrev Robert Scholte <rf...@apache.org>:

> Looks like a typo: 'p' too much...
>
> Op Thu, 20 Dec 2012 15:54:07 +0100 schreef <kr...@apache.org>:
>
>> else if ( "junit.framework.AssertiponFailedError".equals( target.getClass().getName() )
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: git commit: o Improved junit3 support

Posted by Robert Scholte <rf...@apache.org>.
Looks like a typo: 'p' too much...

Op Thu, 20 Dec 2012 15:54:07 +0100 schreef <kr...@apache.org>:

> else if ( "junit.framework.AssertiponFailedError".equals(  
> target.getClass().getName() )

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org