You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2020/04/08 08:22:11 UTC
[maven-surefire] 03/18: extended few tests with a new alternative
of forkNode: TCP
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch maven2surefire-jvm-communication
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 56d12dfc986e82546443baa41e481546b86558af
Author: tibordigana <ti...@apache.org>
AuthorDate: Tue Mar 10 21:49:07 2020 +0100
extended few tests with a new alternative of forkNode: TCP
---
.../plugin/surefire/AbstractSurefireMojo.java | 2 +-
surefire-its/pom.xml | 2 +
.../maven/surefire/its/AbstractFailFastIT.java | 28 ++++++-
.../apache/maven/surefire/its/ConsoleOutputIT.java | 97 +++++++++++++---------
.../apache/maven/surefire/its/FailFastJUnitIT.java | 31 +++----
.../maven/surefire/its/FailFastTestNgIT.java | 18 ++--
.../its/JUnit47RerunFailingTestWithCucumberIT.java | 83 +++++++++++++++---
.../maven/surefire/its/TestMethodPatternIT.java | 84 +++++++++++++++++--
.../src/test/resources/consoleoutput-noisy/pom.xml | 17 ++++
.../src/test/resources/fail-fast-junit/pom.xml | 14 ++++
.../src/test/resources/fail-fast-testng/pom.xml | 17 ++++
.../test/resources/junit44-method-pattern/pom.xml | 17 ++++
.../pom.xml | 20 +++++
.../test/resources/junit48-method-pattern/pom.xml | 14 ++++
.../resources/testng-method-pattern-after/pom.xml | 14 ++++
.../resources/testng-method-pattern-before/pom.xml | 14 ++++
.../test/resources/testng-method-pattern/pom.xml | 14 ++++
17 files changed, 402 insertions(+), 84 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 7ba312a..b26e981 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -2288,7 +2288,7 @@ public abstract class AbstractSurefireMojo
ForkNodeFactory forkNode = getForkNodeFactory();
- getConsoleLogger().debug( "Found implementation of fork node factory: " + forkNode.getClass() );
+ getConsoleLogger().debug( "Found implementation of fork node factory: " + forkNode.getClass().getName() );
if ( canExecuteProviderWithModularPath( platform ) )
{
diff --git a/surefire-its/pom.xml b/surefire-its/pom.xml
index a49244f..42e3ec5 100644
--- a/surefire-its/pom.xml
+++ b/surefire-its/pom.xml
@@ -193,6 +193,8 @@
<maxParallelTestThreads>3</maxParallelTestThreads>
</systemPropertyVariables>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <enableProcessChecker>native</enableProcessChecker>
+ <shutdown>kill</shutdown>
</configuration>
<dependencies>
<dependency>
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java
index 507a08a..69964f4 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java
@@ -29,6 +29,8 @@ import org.junit.runner.RunWith;
import java.util.HashMap;
import java.util.Map;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
import static org.junit.runners.Parameterized.Parameter;
/**
@@ -41,6 +43,12 @@ import static org.junit.runners.Parameterized.Parameter;
public abstract class AbstractFailFastIT
extends SurefireJUnit4IntegrationTestCase
{
+ private static final String LEGACY_FORK_NODE =
+ "org.apache.maven.plugin.surefire.extensions.LegacyForkNodeFactory";
+
+ private static final String SUREFIRE_FORK_NODE =
+ "org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory";
+
@Parameter( 0 )
@SuppressWarnings( "checkstyle:visibilitymodifier" )
public String description;
@@ -69,16 +77,26 @@ public abstract class AbstractFailFastIT
@SuppressWarnings( "checkstyle:visibilitymodifier" )
public int skipped;
+ @Parameter( 7 )
+ @SuppressWarnings( "checkstyle:visibilitymodifier" )
+ public boolean useProcessPipes;
+
protected abstract String withProvider();
private OutputValidator prepare( String description, String profile, Map<String, String> properties )
{
MavenLauncher launcher = unpack( "/fail-fast-" + withProvider(), "_" + description )
- .maven();
+ .maven()
+ .debugLogging();
if ( profile != null )
{
- launcher.addGoal( "-P " + profile );
+ launcher.activateProfile( profile );
+ }
+
+ if ( !useProcessPipes )
+ {
+ launcher.activateProfile( "tcp" );
}
if ( failures != 0 || errors != 0 )
@@ -99,9 +117,11 @@ public abstract class AbstractFailFastIT
}
@Test
- public void test()
+ public void test() throws Exception
{
+ String cls = useProcessPipes ? LEGACY_FORK_NODE : SUREFIRE_FORK_NODE;
prepare( description, profile, properties )
- .assertTestSuiteResults( total, errors, failures, skipped );
+ .assertTestSuiteResults( total, errors, failures, skipped )
+ .assertThatLogLine( containsString( "Found implementation of fork node factory: " + cls ), equalTo( 1 ) );
}
}
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java
index 430441b..21b92b9 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java
@@ -32,6 +32,8 @@ import org.junit.runners.Parameterized.Parameters;
import java.util.ArrayList;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
/**
* Basic suite test using all known versions of JUnit 4.x
@@ -42,6 +44,12 @@ import static java.nio.charset.StandardCharsets.UTF_8;
public class ConsoleOutputIT
extends SurefireJUnit4IntegrationTestCase
{
+ private static final String LEGACY_FORK_NODE =
+ "org.apache.maven.plugin.surefire.extensions.LegacyForkNodeFactory";
+
+ private static final String SUREFIRE_FORK_NODE =
+ "org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory";
+
@Parameters
public static Iterable<Object[]> data()
{
@@ -56,58 +64,47 @@ public class ConsoleOutputIT
public String profileId;
@Test
- public void properNewlinesAndEncodingWithDefaultEncodings()
+ public void properNewlinesAndEncodingWithDefaultEncodings() throws Exception
{
- SurefireLauncher launcher =
- unpack( "/consoleOutput", profileId == null ? "" : profileId )
- .forkOnce();
-
- if ( profileId != null )
- {
- launcher.activateProfile( "tcp" );
- }
-
- OutputValidator outputValidator = launcher.executeTest();
-
- validate( outputValidator, profileId == null );
+ OutputValidator outputValidator = unpack().forkOnce().executeTest();
+ validate( outputValidator, profileId == null, true );
}
@Test
- public void properNewlinesAndEncodingWithDifferentEncoding()
+ public void properNewlinesAndEncodingWithDifferentEncoding() throws Exception
{
- SurefireLauncher launcher =
- unpack( "/consoleOutput", profileId == null ? "" : profileId )
+ OutputValidator outputValidator = unpack()
.forkOnce()
- .argLine( "-Dfile.encoding=UTF-16" );
-
- if ( profileId != null )
- {
- launcher.activateProfile( "tcp" );
- }
-
- OutputValidator outputValidator = launcher.executeTest();
-
- validate( outputValidator, profileId == null );
+ .argLine( "-Dfile.encoding=UTF-16" )
+ .executeTest();
+ validate( outputValidator, profileId == null, true );
}
@Test
- public void properNewlinesAndEncodingWithoutFork()
+ public void properNewlinesAndEncodingWithoutFork() throws Exception
+ {
+ OutputValidator outputValidator = unpack()
+ .forkNever()
+ .executeTest();
+ validate( outputValidator, false, false );
+ }
+
+ private SurefireLauncher unpack()
{
SurefireLauncher launcher =
- unpack( "/consoleOutput", profileId == null ? "" : profileId )
- .forkNever();
+ unpack( "/consoleOutput", profileId == null ? "" : "-" + profileId )
+ .debugLogging();
if ( profileId != null )
{
- launcher.activateProfile( "tcp" );
+ launcher.activateProfile( profileId );
}
- OutputValidator outputValidator = launcher.executeTest();
-
- validate( outputValidator, false );
+ return launcher;
}
- private void validate( final OutputValidator outputValidator, boolean includeShutdownHook )
+ private void validate( final OutputValidator outputValidator, boolean includeShutdownHook, boolean canFork )
+ throws Exception
{
TestFile xmlReportFile = outputValidator.getSurefireReportsXmlFile( "TEST-consoleOutput.Test1.xml" );
xmlReportFile.assertContainsText( "SoutLine" );
@@ -125,22 +122,44 @@ public class ConsoleOutputIT
//todo this text should be in null-output.txt
outputFile.assertContainsText( "Printline in shutdown hook" );
}
+
+ String cls = profileId == null ? LEGACY_FORK_NODE : SUREFIRE_FORK_NODE;
+
+ if ( canFork )
+ {
+ outputValidator
+ .assertThatLogLine(
+ containsString( "Found implementation of fork node factory: " + cls ),
+ equalTo( 1 ) );
+ }
}
@Test
- public void largerSoutThanMemory()
+ public void largerSoutThanMemory() throws Exception
{
SurefireLauncher launcher =
- unpack( "consoleoutput-noisy", profileId == null ? "" : "-" + profileId )
+ unpackNoisy()
.setMavenOpts( "-Xmx64m" )
.sysProp( "thousand", "32000" );
+ String cls = profileId == null ? LEGACY_FORK_NODE : SUREFIRE_FORK_NODE;
+
+ launcher.executeTest()
+ .verifyErrorFreeLog()
+ .assertThatLogLine( containsString( "Found implementation of fork node factory: " + cls ), equalTo( 1 ) );
+ }
+
+ private SurefireLauncher unpackNoisy()
+ {
+ SurefireLauncher launcher =
+ unpack( "consoleoutput-noisy", profileId == null ? "" : "-" + profileId )
+ .debugLogging();
+
if ( profileId != null )
{
- launcher.activateProfile( "tcp" );
+ launcher.activateProfile( profileId );
}
- launcher.executeTest()
- .verifyErrorFreeLog();
+ return launcher;
}
}
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java
index 9077c02..b3be032 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java
@@ -33,14 +33,14 @@ public class FailFastJUnitIT
extends AbstractFailFastIT
{
@Parameters( name = "{0}" )
- @SuppressWarnings( "checkstyle:visibilitymodifier" )
+ @SuppressWarnings( { "checkstyle:visibilitymodifier", "checkstyle:linelength" } )
public static Iterable<Object[]> data()
{
/**
* reuseForks=false is not used because of race conditions and unpredictable commands received by
* MasterProcessReader, this feature has significant limitation.
*/
- ArrayList<Object[]> args = new ArrayList<Object[]>();
+ ArrayList<Object[]> args = new ArrayList<>();
// description
// profile
// forkCount,
@@ -50,18 +50,21 @@ public class FailFastJUnitIT
// failures
// errors
// skipped
- args.add( new Object[] { "junit4-oneFork-ff1", "junit4", props( 1, 1, true ), 5, 0, 1, 4 } );
- args.add( new Object[] { "junit47-oneFork-ff1", "junit47", props( 1, 1, true ), 5, 0, 1, 4 } );
- args.add( new Object[] { "junit4-oneFork-ff2", "junit4", props( 1, 2, true ), 5, 0, 2, 3 } );
- args.add( new Object[] { "junit47-oneFork-ff2", "junit47", props( 1, 2, true ), 5, 0, 2, 3 } );
- args.add( new Object[] { "junit4-twoForks-ff1", "junit4", props( 2, 1, true ), 5, 0, 2, 3 } );
- args.add( new Object[] { "junit47-twoForks-ff1", "junit47", props( 2, 1, true ), 5, 0, 2, 3 } );
- args.add( new Object[] { "junit4-twoForks-ff2", "junit4", props( 2, 2, true ), 5, 0, 2, 2 } );
- args.add( new Object[] { "junit47-twoForks-ff2", "junit47", props( 2, 2, true ), 5, 0, 2, 2 } );
- args.add( new Object[] { "junit4-oneFork-ff3", "junit4", props( 1, 3, true ), 5, 0, 2, 0 } );
- args.add( new Object[] { "junit47-oneFork-ff3", "junit47", props( 1, 3, true ), 5, 0, 2, 0 } );
- args.add( new Object[] { "junit4-twoForks-ff3", "junit4", props( 2, 3, true ), 5, 0, 2, 0 } );
- args.add( new Object[] { "junit47-twoForks-ff3", "junit47", props( 2, 3, true ), 5, 0, 2, 0 } );
+ // pipes
+ args.add( new Object[] { "junit4-oneFork-ff1", "junit4", props( 1, 1, true ), 5, 0, 1, 4, true } );
+ args.add( new Object[] { "junit47-oneFork-ff1", "junit47", props( 1, 1, true ), 5, 0, 1, 4, true } );
+ args.add( new Object[] { "junit4-oneFork-ff2", "junit4", props( 1, 2, true ), 5, 0, 2, 3, true } );
+ args.add( new Object[] { "junit47-oneFork-ff2", "junit47", props( 1, 2, true ), 5, 0, 2, 3, true } );
+ args.add( new Object[] { "junit4-twoForks-ff1", "junit4", props( 2, 1, true ), 5, 0, 2, 3, true } );
+ args.add( new Object[] { "junit47-twoForks-ff1", "junit47", props( 2, 1, true ), 5, 0, 2, 3, true } );
+ args.add( new Object[] { "junit4-twoForks-ff2", "junit4", props( 2, 2, true ), 5, 0, 2, 2, true } );
+ args.add( new Object[] { "junit4-twoForks-ff2-tcp", "junit4", props( 2, 2, true ), 5, 0, 2, 2, false } );
+ args.add( new Object[] { "junit47-twoForks-ff2", "junit47", props( 2, 2, true ), 5, 0, 2, 2, true } );
+ args.add( new Object[] { "junit4-oneFork-ff3", "junit4", props( 1, 3, true ), 5, 0, 2, 0, true } );
+ args.add( new Object[] { "junit47-oneFork-ff3", "junit47", props( 1, 3, true ), 5, 0, 2, 0, true } );
+ args.add( new Object[] { "junit4-twoForks-ff3", "junit4", props( 2, 3, true ), 5, 0, 2, 0, true } );
+ args.add( new Object[] { "junit47-twoForks-ff3", "junit47", props( 2, 3, true ), 5, 0, 2, 0, true } );
+ args.add( new Object[] { "junit47-twoForks-ff3-tcp", "junit47", props( 2, 3, true ), 5, 0, 2, 0, false } );
/*args.add( new Object[] { "junit4-twoForks-ff1x","junit4", props( 2, 1, false ), 5, 0, 2, 3 } );
args.add( new Object[] { "junit47-twoForks-ff1x","junit47",props( 2, 1, false ), 5, 0, 2, 3 } );
args.add( new Object[] { "junit4-twoForks-ff2x","junit4", props( 2, 2, false ), 5, 0, 2, 2 } );
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java
index 0ee2606..e282a21 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java
@@ -34,13 +34,14 @@ public class FailFastTestNgIT
{
@Parameters( name = "{0}" )
+ @SuppressWarnings( "checkstyle:linelength" )
public static Iterable<Object[]> data()
{
/**
* reuseForks=false is not used because of race conditions and unpredictable commands received by
* MasterProcessReader, this feature has significant limitation.
*/
- ArrayList<Object[]> args = new ArrayList<Object[]>();
+ ArrayList<Object[]> args = new ArrayList<>();
// description
// profile
// forkCount,
@@ -50,12 +51,15 @@ public class FailFastTestNgIT
// failures
// errors
// skipped
- args.add( new Object[] { "testng-oneFork-ff1", null, props( 1, 1, true ), 5, 1, 0, 4 } );
- args.add( new Object[] { "testng-oneFork-ff2", null, props( 1, 2, true ), 5, 2, 0, 3 } );
- args.add( new Object[] { "testng-twoForks-ff1", null, props( 2, 1, true ), 5, 2, 0, 3 } );
- args.add( new Object[] { "testng-twoForks-ff2", null, props( 2, 2, true ), 5, 2, 0, 2 } );
- args.add( new Object[] { "testng-oneFork-ff3", null, props( 1, 3, true ), 5, 2, 0, 0 } );
- args.add( new Object[] { "testng-twoForks-ff3", null, props( 2, 3, true ), 5, 2, 0, 0 } );
+ // pipes
+ args.add( new Object[] { "testng-oneFork-ff1", null, props( 1, 1, true ), 5, 1, 0, 4, true } );
+ args.add( new Object[] { "testng-oneFork-ff2", null, props( 1, 2, true ), 5, 2, 0, 3, true } );
+ args.add( new Object[] { "testng-twoForks-ff1", null, props( 2, 1, true ), 5, 2, 0, 3, true } );
+ args.add( new Object[] { "testng-twoForks-ff2", null, props( 2, 2, true ), 5, 2, 0, 2, true } );
+ args.add( new Object[] { "testng-twoForks-ff2-tcp", null, props( 2, 2, true ), 5, 2, 0, 2, false } );
+ args.add( new Object[] { "testng-oneFork-ff3", null, props( 1, 3, true ), 5, 2, 0, 0, true } );
+ args.add( new Object[] { "testng-twoForks-ff3", null, props( 2, 3, true ), 5, 2, 0, 0, true } );
+ args.add( new Object[] { "testng-twoForks-ff3-tcp", null, props( 2, 3, true ), 5, 2, 0, 0, false } );
/*args.add( new Object[] { "testng-twoForks-ff1x", null, props( 2, 1, false ), 5, 2, 0, 3 } );
args.add( new Object[] { "testng-twoForks-ff2x", null, props( 2, 2, false ), 5, 2, 0, 2 } );*/
return args;
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java
index 6253cdd..94a33c6 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java
@@ -19,9 +19,18 @@ package org.apache.maven.surefire.its;
* under the License.
*/
+import com.googlecode.junittoolbox.ParallelParameterized;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
/**
* Tests using the JUnit 47 provider to rerun failing tests with the cucumber runner. The main problem that the junit4
@@ -30,35 +39,89 @@ import org.junit.Test;
*
* @author mpkorstanje
*/
+@RunWith( ParallelParameterized.class )
public class JUnit47RerunFailingTestWithCucumberIT extends SurefireJUnit4IntegrationTestCase
{
+ private static final String LEGACY_FORK_NODE =
+ "org.apache.maven.plugin.surefire.extensions.LegacyForkNodeFactory";
+
+ private static final String SUREFIRE_FORK_NODE =
+ "org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory";
+
+ @Parameters
+ public static Iterable<Object[]> data()
+ {
+ ArrayList<Object[]> args = new ArrayList<>();
+ args.add( new Object[] { "tcp" } );
+ args.add( new Object[] { null } );
+ return args;
+ }
+
+ @Parameter
+ @SuppressWarnings( "checkstyle:visibilitymodifier" )
+ public String profileId;
private SurefireLauncher unpack()
{
- return unpack( "junit47-rerun-failing-tests-with-cucumber" ).setJUnitVersion( "4.13" );
+ SurefireLauncher launcher =
+ unpack( "junit47-rerun-failing-tests-with-cucumber", profileId == null ? "" : "-" + profileId )
+ .setJUnitVersion( "4.13" );
+
+ if ( profileId != null )
+ {
+ launcher.activateProfile( profileId );
+ }
+
+ return launcher;
}
@Test
public void testRerunFailingErrorTestsFalse()
+ throws Exception
{
- unpack().maven().addGoal(
- "-Dsurefire.rerunFailingTestsCount=" + 0 ).withFailure().executeTest().assertTestSuiteResults( 1, 0, 1,
- 0, 0 );
+ String cls = profileId == null ? LEGACY_FORK_NODE : SUREFIRE_FORK_NODE;
+ unpack()
+ .debugLogging()
+ .maven()
+ .sysProp( "surefire.rerunFailingTestsCount", 0 )
+ .withFailure()
+ .executeTest()
+ .assertTestSuiteResults( 1, 0, 1, 0, 0 )
+ .assertThatLogLine(
+ containsString( "Found implementation of fork node factory: " + cls ),
+ equalTo( 1 ) );
}
@Test
public void testRerunFailingErrorTestsWithOneRetry()
+ throws Exception
{
- unpack().maven().addGoal(
- "-Dsurefire.rerunFailingTestsCount=" + 1 ).withFailure().executeTest().assertTestSuiteResults( 1, 0, 1,
- 0, 0 );
+ String cls = profileId == null ? LEGACY_FORK_NODE : SUREFIRE_FORK_NODE;
+ unpack()
+ .debugLogging()
+ .maven()
+ .sysProp( "surefire.rerunFailingTestsCount", 1 )
+ .withFailure()
+ .executeTest()
+ .assertTestSuiteResults( 1, 0, 1, 0, 0 )
+ .assertThatLogLine(
+ containsString( "Found implementation of fork node factory: " + cls ),
+ equalTo( 1 ) );
}
@Test
public void testRerunFailingErrorTestsTwoRetry()
+ throws Exception
{
- unpack().maven().addGoal( "-Dsurefire.rerunFailingTestsCount=" + 2 ).executeTest().assertTestSuiteResults( 1, 0,
- 0, 0, 2 );
+ String cls = profileId == null ? LEGACY_FORK_NODE : SUREFIRE_FORK_NODE;
+ unpack()
+ .maven()
+ .debugLogging()
+ .sysProp( "surefire.rerunFailingTestsCount", 2 )
+ .executeTest()
+ .assertTestSuiteResults( 1, 0, 0, 0, 2 )
+ .assertThatLogLine(
+ containsString( "Found implementation of fork node factory: " + cls ),
+ equalTo( 1 ) );
}
-
}
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java
index 917ef93..35ff272 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java
@@ -19,29 +19,64 @@ package org.apache.maven.surefire.its;
* under the License.
*/
+import com.googlecode.junittoolbox.ParallelParameterized;
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;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+
/**
* Test project using -Dtest=mtClass#myMethod
*
* @author Olivier Lamy
*/
+@RunWith( ParallelParameterized.class )
public class TestMethodPatternIT
extends SurefireJUnit4IntegrationTestCase
{
private static final String RUNNING_WITH_PROVIDER47 = "parallel='none', perCoreThreadCount=true, threadCount=0";
- public OutputValidator runMethodPattern( String projectName, Map<String, String> props, String... goals )
+ private static final String LEGACY_FORK_NODE =
+ "org.apache.maven.plugin.surefire.extensions.LegacyForkNodeFactory";
+
+ private static final String SUREFIRE_FORK_NODE =
+ "org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory";
+
+ @Parameters
+ public static Iterable<Object[]> data()
+ {
+ ArrayList<Object[]> args = new ArrayList<>();
+ args.add( new Object[] { "tcp" } );
+ args.add( new Object[] { null } );
+ return args;
+ }
+
+ @Parameter
+ @SuppressWarnings( "checkstyle:visibilitymodifier" )
+ public String profileId;
+
+ private OutputValidator runMethodPattern( String projectName, Map<String, String> props, String... goals )
+ throws Exception
{
- SurefireLauncher launcher = unpack( projectName );
+ SurefireLauncher launcher = unpack( projectName, profileId == null ? "" : "-" + profileId );
+
+ if ( profileId != null )
+ {
+ launcher.activateProfile( profileId );
+ }
+
for ( Entry<String, String> entry : props.entrySet() )
{
launcher.sysProp( entry.getKey(), entry.getValue() );
@@ -50,41 +85,60 @@ public class TestMethodPatternIT
{
launcher.addGoal( goal );
}
+ String cls = profileId == null ? LEGACY_FORK_NODE : SUREFIRE_FORK_NODE;
return launcher.showErrorStackTraces().debugLogging()
.executeTest()
- .assertTestSuiteResults( 2, 0, 0, 0 );
+ .assertTestSuiteResults( 2, 0, 0, 0 )
+ .assertThatLogLine(
+ containsString( "Found implementation of fork node factory: " + cls ),
+ equalTo( 1 ) );
}
@Test
public void testJUnit44()
+ throws Exception
{
runMethodPattern( "junit44-method-pattern", Collections.<String, String>emptyMap() );
}
@Test
public void testJUnit48Provider4()
+ throws Exception
{
runMethodPattern( "junit48-method-pattern", Collections.<String, String>emptyMap(), "-P surefire-junit4" );
}
@Test
public void testJUnit48Provider47()
+ throws Exception
{
runMethodPattern( "junit48-method-pattern", Collections.<String, String>emptyMap(), "-P surefire-junit47" )
.verifyTextInLog( RUNNING_WITH_PROVIDER47 );
}
@Test
- public void testJUnit48WithCategoryFilter()
+ public void testJUnit48WithCategoryFilter() throws Exception
{
- unpack( "junit48-method-pattern" )
+ String cls = profileId == null ? LEGACY_FORK_NODE : SUREFIRE_FORK_NODE;
+ SurefireLauncher launcher = unpack( "junit48-method-pattern", profileId == null ? "" : "-" + profileId );
+
+ if ( profileId != null )
+ {
+ launcher.activateProfile( profileId );
+ }
+
+ launcher.debugLogging()
.addGoal( "-Dgroups=junit4.SampleCategory" )
.executeTest()
- .assertTestSuiteResults( 1, 0, 0, 0 );
+ .assertTestSuiteResults( 1, 0, 0, 0 )
+ .assertThatLogLine(
+ containsString( "Found implementation of fork node factory: " + cls ),
+ equalTo( 1 ) );
}
@Test
public void testTestNgMethodBefore()
+ throws Exception
{
Map<String, String> props = new HashMap<>();
props.put( "testNgVersion", "5.7" );
@@ -94,6 +148,7 @@ public class TestMethodPatternIT
@Test
public void testTestNGMethodPattern()
+ throws Exception
{
Map<String, String> props = new HashMap<>();
props.put( "testNgVersion", "5.7" );
@@ -102,14 +157,25 @@ public class TestMethodPatternIT
}
@Test
- public void testMethodPatternAfter()
+ public void testMethodPatternAfter() throws Exception
{
- unpack( "testng-method-pattern-after" )
+ String cls = profileId == null ? LEGACY_FORK_NODE : SUREFIRE_FORK_NODE;
+ SurefireLauncher launcher = unpack( "testng-method-pattern-after", profileId == null ? "" : "-" + profileId );
+
+ if ( profileId != null )
+ {
+ launcher.activateProfile( profileId );
+ }
+
+ launcher.debugLogging()
.sysProp( "testNgVersion", "5.7" )
.sysProp( "testNgClassifier", "jdk15" )
.executeTest()
.verifyErrorFree( 2 )
- .verifyTextInLog( "Called tearDown" );
+ .verifyTextInLog( "Called tearDown" )
+ .assertThatLogLine(
+ containsString( "Found implementation of fork node factory: " + cls ),
+ equalTo( 1 ) );
}
}
diff --git a/surefire-its/src/test/resources/consoleoutput-noisy/pom.xml b/surefire-its/src/test/resources/consoleoutput-noisy/pom.xml
index e80b978..6fd7013 100644
--- a/surefire-its/src/test/resources/consoleoutput-noisy/pom.xml
+++ b/surefire-its/src/test/resources/consoleoutput-noisy/pom.xml
@@ -60,4 +60,21 @@
<threadCount>4</threadCount>
</properties>
+ <profiles>
+ <profile>
+ <id>tcp</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
diff --git a/surefire-its/src/test/resources/fail-fast-junit/pom.xml b/surefire-its/src/test/resources/fail-fast-junit/pom.xml
index f46d4ea..0556f4c 100644
--- a/surefire-its/src/test/resources/fail-fast-junit/pom.xml
+++ b/surefire-its/src/test/resources/fail-fast-junit/pom.xml
@@ -100,6 +100,20 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>tcp</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/surefire-its/src/test/resources/fail-fast-testng/pom.xml b/surefire-its/src/test/resources/fail-fast-testng/pom.xml
index d52ad12..ed07d8a 100644
--- a/surefire-its/src/test/resources/fail-fast-testng/pom.xml
+++ b/surefire-its/src/test/resources/fail-fast-testng/pom.xml
@@ -56,4 +56,21 @@
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>tcp</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
diff --git a/surefire-its/src/test/resources/junit44-method-pattern/pom.xml b/surefire-its/src/test/resources/junit44-method-pattern/pom.xml
index e9ac59e..e3db519 100644
--- a/surefire-its/src/test/resources/junit44-method-pattern/pom.xml
+++ b/surefire-its/src/test/resources/junit44-method-pattern/pom.xml
@@ -57,4 +57,21 @@
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>tcp</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
diff --git a/surefire-its/src/test/resources/junit47-rerun-failing-tests-with-cucumber/pom.xml b/surefire-its/src/test/resources/junit47-rerun-failing-tests-with-cucumber/pom.xml
index 24ee294..d58223c 100644
--- a/surefire-its/src/test/resources/junit47-rerun-failing-tests-with-cucumber/pom.xml
+++ b/surefire-its/src/test/resources/junit47-rerun-failing-tests-with-cucumber/pom.xml
@@ -42,6 +42,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
+ <configuration>
+ <forkMode>once</forkMode>
+ </configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
@@ -74,4 +77,21 @@
</dependency>
</dependencies>
+ <profiles>
+ <profile>
+ <id>tcp</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
diff --git a/surefire-its/src/test/resources/junit48-method-pattern/pom.xml b/surefire-its/src/test/resources/junit48-method-pattern/pom.xml
index 8689549..40227c3 100644
--- a/surefire-its/src/test/resources/junit48-method-pattern/pom.xml
+++ b/surefire-its/src/test/resources/junit48-method-pattern/pom.xml
@@ -98,6 +98,20 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>tcp</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/surefire-its/src/test/resources/testng-method-pattern-after/pom.xml b/surefire-its/src/test/resources/testng-method-pattern-after/pom.xml
index 41768cd..c894f12 100644
--- a/surefire-its/src/test/resources/testng-method-pattern-after/pom.xml
+++ b/surefire-its/src/test/resources/testng-method-pattern-after/pom.xml
@@ -61,6 +61,20 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>tcp</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
<build>
diff --git a/surefire-its/src/test/resources/testng-method-pattern-before/pom.xml b/surefire-its/src/test/resources/testng-method-pattern-before/pom.xml
index 41768cd..c894f12 100644
--- a/surefire-its/src/test/resources/testng-method-pattern-before/pom.xml
+++ b/surefire-its/src/test/resources/testng-method-pattern-before/pom.xml
@@ -61,6 +61,20 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>tcp</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
<build>
diff --git a/surefire-its/src/test/resources/testng-method-pattern/pom.xml b/surefire-its/src/test/resources/testng-method-pattern/pom.xml
index 50b08bf..905a56c 100644
--- a/surefire-its/src/test/resources/testng-method-pattern/pom.xml
+++ b/surefire-its/src/test/resources/testng-method-pattern/pom.xml
@@ -61,6 +61,20 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>tcp</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>