Skip to content

Commit

Permalink
[SUREFIRE-832] Provider detection
Browse files Browse the repository at this point in the history
Fixed with IT

git-svn-id: https://svn.apache.org/repos/asf/maven/surefire/trunk@1242381 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
krosenvold committed Feb 9, 2012
1 parent 139ad3b commit 48f2290
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ protected boolean isAnyConcurrencySelected()

protected boolean isAnyGroupsSelected()
{
return this.getGroups() != null && this.getExcludedGroups() != null;
return this.getGroups() != null || this.getExcludedGroups() != null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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" );
}

}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package junit4;

interface CategoryA {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package junit4;

interface CategoryB {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package junit4;

interface CategoryC {}
Original file line number Diff line number Diff line change
@@ -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 );
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 48f2290

Please sign in to comment.