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/02/09 17:34:04 UTC
svn commit: r1242381 - in /maven/surefire/trunk:
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/
surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/
surefire-integration-tests/src/test/resources/surefire-...
Author: krosenvold
Date: Thu Feb 9 16:34:03 2012
New Revision: 1242381
URL: http://svn.apache.org/viewvc?rev=1242381&view=rev
Log:
[SUREFIRE-832] Provider detection
Fixed with IT
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire832ProviderSelectionIT.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/pom.xml
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/BasicTest.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryA.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryB.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryC.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryCTest.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/NoCategoryTest.java
Modified:
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1242381&r1=1242380&r2=1242381&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Thu Feb 9 16:34:03 2012
@@ -297,7 +297,7 @@ public abstract class AbstractSurefireMo
protected boolean isAnyGroupsSelected()
{
- return this.getGroups() != null && this.getExcludedGroups() != null;
+ return this.getGroups() != null || this.getExcludedGroups() != null;
}
/**
Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire832ProviderSelectionIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire832ProviderSelectionIT.java?rev=1242381&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire832ProviderSelectionIT.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire832ProviderSelectionIT.java Thu Feb 9 16:34:03 2012
@@ -0,0 +1,29 @@
+package org.apache.maven.surefire.its.jiras;
+
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireIntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.SurefireLauncher;
+
+public class Surefire832ProviderSelectionIT
+ extends SurefireIntegrationTestCase
+{
+ public void testJUnitRunCategoryAB()
+ {
+ OutputValidator validator = unpackJUnit().groups( "junit4.CategoryA&&junit4.CategoryB" ).executeTest();
+ validator.verifyErrorFreeLog();
+ validator.assertTestSuiteResults( 2, 0, 0, 0 );
+ validator.verifyTextInLog( "catA: 1" );
+ validator.verifyTextInLog( "catB: 1" );
+ validator.verifyTextInLog( "catC: 0" );
+ validator.verifyTextInLog( "catNone: 0" );
+ validator.verifyTextInLog( "mA: 1" );
+ validator.verifyTextInLog( "mB: 1" );
+ validator.verifyTextInLog( "mC: 0" );
+ }
+
+ private SurefireLauncher unpackJUnit()
+ {
+ return unpack( "surefire-832-provider-selection" );
+ }
+
+}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/pom.xml?rev=1242381&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/pom.xml Thu Feb 9 16:34:03 2012
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>junit4</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>4.8.1 provider selection Test for JUnit Groups</name>
+
+
+ <properties>
+ <junitVersion>4.8.1</junitVersion>
+ <groups>junit4.CategoryA,junit4.CategoryB</groups>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junitVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/BasicTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/BasicTest.java?rev=1242381&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/BasicTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/BasicTest.java Thu Feb 9 16:34:03 2012
@@ -0,0 +1,88 @@
+package 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 org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+
+public class BasicTest
+{
+ static int catACount = 0;
+ static int catBCount = 0;
+ static int catCCount = 0;
+ static int catNoneCount = 0;
+
+ @Rule
+ public TestName testName = new TestName();
+
+ @Before
+ public void testName()
+ {
+ System.out.println( "Running " + getClass().getName() + "." + testName.getMethodName() );
+ }
+
+ @Test
+ @Category(CategoryA.class)
+ public void testInCategoryA()
+ {
+ catACount++;
+ }
+
+ @Test
+ @Category(CategoryB.class)
+ public void testInCategoryB()
+ {
+ catBCount++;
+ }
+
+ @Test
+ @Category({CategoryA.class, CategoryB.class})
+ public void testInCategoryAB()
+ {
+ catACount++;
+ catBCount++;
+ }
+
+ @Test
+ @Category(CategoryC.class)
+ public void testInCategoryC()
+ {
+ catCCount++;
+ }
+
+ @Test
+ public void testInNoCategory()
+ {
+ catNoneCount++;
+ }
+
+ @AfterClass
+ public static void oneTimeTearDown()
+ {
+ System.out.println("catA: " + catACount + "\n" +
+ "catB: " + catBCount + "\n" +
+ "catC: " + catCCount + "\n" +
+ "catNone: " + catNoneCount);
+ }
+}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryA.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryA.java?rev=1242381&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryA.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryA.java Thu Feb 9 16:34:03 2012
@@ -0,0 +1,3 @@
+package junit4;
+
+interface CategoryA {}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryB.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryB.java?rev=1242381&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryB.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryB.java Thu Feb 9 16:34:03 2012
@@ -0,0 +1,3 @@
+package junit4;
+
+interface CategoryB {}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryC.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryC.java?rev=1242381&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryC.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryC.java Thu Feb 9 16:34:03 2012
@@ -0,0 +1,3 @@
+package junit4;
+
+interface CategoryC {}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryCTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryCTest.java?rev=1242381&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryCTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/CategoryCTest.java Thu Feb 9 16:34:03 2012
@@ -0,0 +1,80 @@
+package 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 org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+
+@Category(CategoryC.class)
+public class CategoryCTest
+{
+ static int catACount = 0;
+ static int catBCount = 0;
+ static int catCCount = 0;
+
+ @Rule
+ public TestName testName = new TestName();
+
+ @Before
+ public void testName()
+ {
+ System.out.println( "Running " + getClass().getName() + "." + testName.getMethodName() );
+ }
+
+ @Test
+ @Category( CategoryA.class )
+ public void testInCategoryA()
+ {
+ catACount++;
+ }
+
+ @Test
+ @Category(CategoryB.class)
+ public void testInCategoryB()
+ {
+ catBCount++;
+ }
+
+ @Test
+ @Category({CategoryA.class, CategoryB.class})
+ public void testInCategoriesAB()
+ {
+ catACount++;
+ catBCount++;
+ }
+
+ @Test
+ public void testInCategoryC()
+ {
+ catCCount++;
+ }
+
+ @AfterClass
+ public static void oneTimeTearDown()
+ {
+ System.out.println("mA: " + catACount + "\n" +
+ "mB: " + catBCount + "\n" +
+ "mC: " + catCCount );
+ }
+}
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/NoCategoryTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/NoCategoryTest.java?rev=1242381&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/NoCategoryTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/src/test/java/junit4/NoCategoryTest.java Thu Feb 9 16:34:03 2012
@@ -0,0 +1,38 @@
+package 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 org.junit.AfterClass;
+import org.junit.Test;
+
+public class NoCategoryTest {
+ static int catNoneCount = 0;
+
+ @Test
+ public void testInNoCategory()
+ {
+ catNoneCount++;
+ }
+
+ @AfterClass
+ public static void oneTimeTearDown()
+ {
+ System.out.println("NoCategoryTest.CatNone: " + catNoneCount);
+ }
+}