Skip to content

Commit

Permalink
[SUREFIRE-745][SUREFIRE-1126]
Browse files Browse the repository at this point in the history
  • Loading branch information
Tibor17 committed Mar 24, 2015
1 parent 866a535 commit 947abde
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 45 deletions.
Expand Up @@ -185,7 +185,8 @@ public class IntegrationTestMojo
* Each include item may also contain a comma-separated sublist of items, which will be treated as multiple
* &nbsp;&lt;include> entries.<br/>
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):<br/>
* &nbsp;&lt;include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg&#47;**&#47;*Fast*.java, Basic????, !Unstable*&lt;/include><br/>
* &nbsp;&lt;include>%regex[.*[Cat|Dog].*], Basic????, !Unstable*&lt;/include><br/>
* &nbsp;&lt;include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg&#47;**&#47;*Fast*.java&lt;/include><br/>
* <p/>
* This parameter is ignored if the TestNG <code>suiteXmlFiles</code> parameter is specified.<br/>
* <br/>
Expand Down
Expand Up @@ -166,7 +166,8 @@ public class SurefirePlugin
* Each include item may also contain a comma-separated sublist of items, which will be treated as multiple
* &nbsp;&lt;include> entries.<br/>
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):<br/>
* &nbsp;&lt;include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg&#47;**&#47;*Fast*.java, Basic????, !Unstable*&lt;/include><br/>
* &nbsp;&lt;include>%regex[.*[Cat|Dog].*], Basic????, !Unstable*&lt;/include><br/>
* &nbsp;&lt;include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg&#47;**&#47;*Fast*.java&lt;/include><br/>
* <p/>
* This parameter is ignored if the TestNG <code>suiteXmlFiles</code> parameter is specified.<br/>
* <br/>
Expand Down
Expand Up @@ -21,6 +21,7 @@

import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;

/**
Expand All @@ -33,9 +34,14 @@ public class TestMethodPatternIT
{
private static final String RUNNING_WITH_JUNIT48 = "parallel='none', perCoreThreadCount=true, threadCount=0";

public OutputValidator runMethodPattern( String projectName )
public OutputValidator runMethodPattern( String projectName, String... goals )
{
return unpack( projectName ).executeTest().assertTestSuiteResults( 2, 0, 0, 0 );
SurefireLauncher launcher = unpack( projectName );
for ( String goal : goals )
{
launcher.addGoal( goal );
}
return launcher.executeTest().assertTestSuiteResults( 2, 0, 0, 0 );
}

@Test
Expand All @@ -45,15 +51,25 @@ public void testJUnit44()
}

@Test
public void testJUnit48()
public void testJUnit48Provider4()
{
runMethodPattern( "junit48-method-pattern" ).verifyTextInLog( RUNNING_WITH_JUNIT48 );
runMethodPattern( "junit48-method-pattern", "-P surefire-junit4" );
}

@Test
public void testJUnit48Provider47()
{
runMethodPattern( "junit48-method-pattern", "-P surefire-junit47" )
.verifyTextInLog( RUNNING_WITH_JUNIT48 );
}

@Test
public void testJUnit48WithCategoryFilter()
{
unpack( "junit48-method-pattern" ).addGoal( "-Dgroups=junit4.SampleCategory" ).executeTest().assertTestSuiteResults( 1, 0, 0, 0 );;
unpack( "junit48-method-pattern" )
.addGoal( "-Dgroups=junit4.SampleCategory" )
.executeTest()
.assertTestSuiteResults( 1, 0, 0, 0 );;
}

@Test
Expand All @@ -71,7 +87,10 @@ public void testTestNGMethodPattern()
@Test
public void testMethodPatternAfter()
{
unpack( "testng-method-pattern-after" ).executeTest().verifyErrorFree( 2 ).verifyTextInLog( "Called tearDown" );
unpack( "testng-method-pattern-after" )
.executeTest()
.verifyErrorFree( 2 )
.verifyTextInLog( "Called tearDown" );
}

}
Expand Up @@ -21,6 +21,7 @@

import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;


Expand All @@ -35,10 +36,15 @@ public class TestMultipleMethodsIT

private static final String RUNNING_WITH_JUNIT48 = "parallel='none', perCoreThreadCount=true, threadCount=0";

public OutputValidator multipleMethod( String projectName )
public OutputValidator multipleMethod( String projectName, String... goals )
throws Exception
{
return unpack( projectName ).executeTest().verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 );
SurefireLauncher launcher = unpack( projectName );
for ( String goal : goals )
{
launcher.addGoal( goal );
}
return launcher.executeTest().verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 );
}

@Test
Expand All @@ -49,10 +55,18 @@ public void testJunit44()
}

@Test
public void testJunit48()
public void testJunit48Provider4()
throws Exception
{
multipleMethod( "junit48-multiple-methods" ).verifyTextInLog( RUNNING_WITH_JUNIT48 );
multipleMethod( "junit48-multiple-methods", "-P surefire-junit4" );
}

@Test
public void testJunit48Provider47()
throws Exception
{
multipleMethod( "junit48-multiple-methods", "-P surefire-junit47" )
.verifyTextInLog( RUNNING_WITH_JUNIT48 );
}

}
Expand Up @@ -21,6 +21,7 @@

import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;

/**
Expand All @@ -33,10 +34,15 @@ public class TestSingleMethodIT
{
private static final String RUNNING_WITH_JUNIT48 = "parallel='none', perCoreThreadCount=true, threadCount=0";

public OutputValidator singleMethod( String projectName )
public OutputValidator singleMethod( String projectName, String... goals )
throws Exception
{
return unpack( projectName ).executeTest().verifyErrorFreeLog().assertTestSuiteResults( 1, 0, 0, 0 );
SurefireLauncher launcher = unpack( projectName );
for ( String goal : goals )
{
launcher.addGoal( goal );
}
return launcher.executeTest().verifyErrorFreeLog().assertTestSuiteResults( 1, 0, 0, 0 );
}

@Test
Expand All @@ -47,20 +53,30 @@ public void testJunit44()
}

@Test
public void testJunit48()
public void testJunit48Provider4()
throws Exception
{
singleMethod( "junit48-single-method" ).verifyTextInLog( RUNNING_WITH_JUNIT48 );
singleMethod( "junit48-single-method", "-P surefire-junit4" );
}

@Test
public void testJunit48Provider47()
throws Exception
{
singleMethod( "junit48-single-method", "-P surefire-junit47" )
.verifyTextInLog( RUNNING_WITH_JUNIT48 );
}

@Test
public void testJunit48parallel()
throws Exception
{
unpack( "junit48-single-method" )
.executeTest()
.verifyErrorFreeLog()
.assertTestSuiteResults( 1, 0, 0, 0 );
.parallel( "all" )
.useUnlimitedThreads()
.executeTest()
.verifyErrorFreeLog()
.assertTestSuiteResults( 1, 0, 0, 0 );
}

@Test
Expand Down
Expand Up @@ -23,12 +23,18 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>it-parent</artifactId>
<version>1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>org.apache.maven.plugins.surefire</groupId>
<artifactId>junit4</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Test for JUnit 4.8.1</name>


<properties>
<junitVersion>4.8.1</junitVersion>
</properties>
Expand All @@ -55,19 +61,51 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<test>BasicTest#testSuccess*</test>
<forkMode>once</forkMode>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>surefire-junit47</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>surefire-junit4</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Expand Up @@ -35,7 +35,6 @@
<version>1.0-SNAPSHOT</version>
<name>Test for JUnit 4.8.1</name>


<properties>
<junitVersion>4.8.1</junitVersion>
</properties>
Expand Down Expand Up @@ -64,16 +63,49 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<test>junit4/BasicTest#testSuccessOne+testFailOne,junit4/TestThree#testSuccessTwo</test>
<forkMode>once</forkMode>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>surefire-junit47</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>surefire-junit4</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit 947abde

Please sign in to comment.