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/21 11:41:40 UTC
git commit: o Added test on runlistener with multiple iignores
Updated Branches:
refs/heads/master 4b09fd133 -> ab4eea7e0
o Added test on runlistener with multiple iignores
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/ab4eea7e
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/ab4eea7e
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/ab4eea7e
Branch: refs/heads/master
Commit: ab4eea7e0d4cb9920014a4955d38d4e5e081151c
Parents: 4b09fd1
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Fri Dec 21 11:40:41 2012 +0100
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Fri Dec 21 11:40:41 2012 +0100
----------------------------------------------------------------------
.../src/test/resources/junit-ignore/pom.xml | 4 +-
.../ClassAndMethodIgnoreNothingToRunTest.java | 18 +++++++
...lassLevelIgnore1WithMethodThatIsNormalTest.java | 17 +++++++
...lassLevelIgnore2WithMethodThatIsNormalTest.java | 17 +++++++
...reeIgnoredMethodsAnd1AssumptionFailureTest.java | 38 +++++++++++++++
.../surefire/junitcore/JUnitCoreRunListener.java | 26 +++++-----
.../junitcore/JUnitCoreRunListenerTest.java | 22 ++++++++
7 files changed, 129 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ab4eea7e/surefire-integration-tests/src/test/resources/junit-ignore/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit-ignore/pom.xml b/surefire-integration-tests/src/test/resources/junit-ignore/pom.xml
index c62fabd..a40b986 100644
--- a/surefire-integration-tests/src/test/resources/junit-ignore/pom.xml
+++ b/surefire-integration-tests/src/test/resources/junit-ignore/pom.xml
@@ -31,6 +31,7 @@
<properties>
<junit.version>4.4</junit.version>
<surefire.parallel></surefire.parallel>
+ <surefire.threadcount>3</surefire.threadcount>
</properties>
<dependencies>
@@ -57,7 +58,8 @@
<version>${surefire.version}</version>
<configuration>
<parallel>${surefire.parallel}</parallel>
- <threadCount>3</threadCount>
+ <perCoreThreadCount>false</perCoreThreadCount>
+ <threadCount>${surefire.threadcount}</threadCount>
</configuration>
</plugin>
</plugins>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ab4eea7e/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassAndMethodIgnoreNothingToRunTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassAndMethodIgnoreNothingToRunTest.java b/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassAndMethodIgnoreNothingToRunTest.java
new file mode 100644
index 0000000..15f05f9
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassAndMethodIgnoreNothingToRunTest.java
@@ -0,0 +1,18 @@
+package junit.ignore;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore( "ignore this test" )
+public class ClassAndMethodIgnoreNothingToRunTest
+{
+
+ @Ignore( "ignore this test" )
+ @Test
+ public void testIgnorable()
+ {
+ Assert.fail( "you should have ignored me!" );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ab4eea7e/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore1WithMethodThatIsNormalTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore1WithMethodThatIsNormalTest.java b/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore1WithMethodThatIsNormalTest.java
new file mode 100644
index 0000000..7570f7f
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore1WithMethodThatIsNormalTest.java
@@ -0,0 +1,17 @@
+package junit.ignore;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore( "ignore this test" )
+public class ClassLevelIgnore1WithMethodThatIsNormalTest
+{
+
+ @Test
+ public void testIgnorable()
+ {
+ Assert.fail( "you should have ignored me!" );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ab4eea7e/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore2WithMethodThatIsNormalTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore2WithMethodThatIsNormalTest.java b/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore2WithMethodThatIsNormalTest.java
new file mode 100644
index 0000000..b6cbcf6
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore2WithMethodThatIsNormalTest.java
@@ -0,0 +1,17 @@
+package junit.ignore;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore( "ignore this test" )
+public class ClassLevelIgnore2WithMethodThatIsNormalTest
+{
+
+ @Test
+ public void testIgnorable()
+ {
+ Assert.fail( "you should have ignored me!" );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ab4eea7e/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java b/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java
new file mode 100644
index 0000000..765eb8a
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java
@@ -0,0 +1,38 @@
+package junit.ignore;
+
+import org.junit.Assume;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest
+{
+
+ @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} );
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ab4eea7e/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
index 1d8ea74..5d76c39 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
@@ -32,13 +32,12 @@ import org.junit.runner.notification.Failure;
/**
* Noteworthy things about JUnit4 listening:
- *
+ * <p/>
* A class that is annotated with @Ignore will have one invocation of "testSkipped" with source==name
* A method that is annotated with @Ignore will have a invocation of testSkipped with source and name distinct
* Methods annotated with @Ignore trigger no further events.
*
* @see org.apache.maven.surefire.junitcore.ConcurrentRunListener for details about parallel running
- *
*/
public class JUnitCoreRunListener
extends JUnit4RunListener
@@ -82,21 +81,24 @@ public class JUnitCoreRunListener
String itemTestClassName = null;
for ( Description item : children )
{
- if ( item.isTest() && item.getMethodName() != null )
- {
- testSet.incrementTestMethodCount();
- if ( itemTestClassName == null )
- {
- itemTestClassName = item.getClassName();
- }
- }
- else if ( item.getChildren().size() > 0 )
+ if ( !item.isTest() )
{
fillTestCountMap( item );
}
else
{
- classMethodCounts.put( item.getClassName(), testSet );
+ if ( item.getMethodName() != null )
+ {
+ testSet.incrementTestMethodCount();
+ if ( itemTestClassName == null )
+ {
+ itemTestClassName = item.getClassName();
+ }
+ }
+ else
+ {
+ classMethodCounts.put( item.getClassName(), new TestSet( item ) );
+ }
}
}
if ( itemTestClassName != null )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ab4eea7e/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java
index c63b78a..9d3d4c1 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.surefire.junitcore;
*/
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import org.apache.maven.surefire.junit4.MockReporter;
@@ -62,6 +63,27 @@ public class JUnitCoreRunListenerTest
assertEquals( 1, result.getRunCount() );
}
+ public void testStateForClassesWithNoChildren()
+ throws Exception
+ {
+ Description testDescription =
+ Description.createSuiteDescription( "testMethod(cannot.be.loaded.by.junit.Test)" );
+ Description st1 = Description.createSuiteDescription( STest1.class);
+// st1.addChild( Description.createSuiteDescription( STest1.class ) );
+ testDescription.addChild( st1 );
+ Description st2 = Description.createSuiteDescription( STest2.class);
+ // st2.addChild( Description.createSuiteDescription( STest2.class ) );
+ testDescription.addChild( st2 );
+
+ Map<String, TestSet> classMethodCounts = new HashMap<String, TestSet>();
+ JUnitCoreRunListener listener = new JUnitCoreRunListener( new MockReporter(), classMethodCounts );
+ listener.testRunStarted( testDescription );
+ assertEquals( 2, classMethodCounts.size() );
+ Iterator<TestSet> iterator = classMethodCounts.values().iterator();
+ assertFalse(iterator.next().equals( iterator.next() ));
+
+ }
+
public void testTestClassNotLoadableFromJUnitClassLoader()
throws Exception
{