You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/05/25 05:36:59 UTC
[maven-surefire] branch master updated: [SUREFIRE-2075] Only set thread count if spec'd
This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/master by this push:
new 2cf4674e7 [SUREFIRE-2075] Only set thread count if spec'd
2cf4674e7 is described below
commit 2cf4674e75df0a9d5ea8396c429e5972676641dd
Author: Scott Babcock <sc...@hotmail.com>
AuthorDate: Sun Apr 24 23:54:17 2022 -0700
[SUREFIRE-2075] Only set thread count if spec'd
---
.../surefire/its/CheckTestNg740ParallelIT.java | 8 +++
.../pom.xml | 73 ++++++++++++++++++++++
.../java/testng740/TestNG740ParallelTest.java} | 25 ++++----
.../testng/conf/TestNGMapConfigurator.java | 16 +++--
4 files changed, 104 insertions(+), 18 deletions(-)
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java
index 70741ece0..2122e91a5 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java
@@ -35,4 +35,12 @@ public class CheckTestNg740ParallelIT
.executeTest()
.assertTestSuiteResults( 2, 0, 0, 0 );
}
+
+ @Test
+ public void withTestNG740AndParallelSetWithoutThreadCount()
+ {
+ unpack( "testng-740-parallel-without-threadcount" )
+ .executeTest()
+ .assertTestSuiteResults( 2, 0, 0, 0 );
+ }
}
diff --git a/surefire-its/src/test/resources/testng-740-parallel-without-threadcount/pom.xml b/surefire-its/src/test/resources/testng-740-parallel-without-threadcount/pom.xml
new file mode 100644
index 000000000..3ebb85308
--- /dev/null
+++ b/surefire-its/src/test/resources/testng-740-parallel-without-threadcount/pom.xml
@@ -0,0 +1,73 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>testng-740-parallel</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>TestNG 7.4.0 parallel test</name>
+
+ <properties>
+ <surefire.testng.verbose>0</surefire.testng.verbose>
+ <argLine/>
+ <jacoco.agent/>
+ <maven.compiler.source>1.7</maven.compiler.source>
+ <maven.compiler.target>1.7</maven.compiler.target>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <configuration>
+ <argLine>${argLine} ${jacoco.agent}</argLine>
+ <parallel>methods</parallel>
+ <properties>
+ <property>
+ <name>surefire.testng.verbose</name>
+ <value>${surefire.testng.verbose}</value>
+ </property>
+ </properties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>7.4.0</version>
+ <exclusions>
+ <exclusion>
+ <!-- NOTE: Deliberaty excluding junit to enforce TestNG only tests, cf. SUREFIRE-642 -->
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java b/surefire-its/src/test/resources/testng-740-parallel-without-threadcount/src/test/java/testng740/TestNG740ParallelTest.java
similarity index 64%
copy from surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java
copy to surefire-its/src/test/resources/testng-740-parallel-without-threadcount/src/test/java/testng740/TestNG740ParallelTest.java
index 70741ece0..855b92fa0 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java
+++ b/surefire-its/src/test/resources/testng-740-parallel-without-threadcount/src/test/java/testng740/TestNG740ParallelTest.java
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.its;
+package testng.simple;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,20 +19,17 @@ package org.apache.maven.surefire.its;
* under the License.
*/
-import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
-import org.junit.Test;
+import org.testng.annotations.Test;
-/**
- */
-@SuppressWarnings( "checkstyle:magicnumber" )
-public class CheckTestNg740ParallelIT
- extends SurefireJUnit4IntegrationTestCase
-{
+
+public class TestNG740ParallelTest {
@Test
- public void withTestNG740AndParallelSet()
- {
- unpack( "testng-740-parallel" )
- .executeTest()
- .assertTestSuiteResults( 2, 0, 0, 0 );
+ public void testOne() {
+
+ }
+
+ @Test
+ public void testTwo() {
+
}
}
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
index 186110d69..874e7f1f3 100755
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
@@ -28,7 +28,6 @@ import org.apache.maven.surefire.api.testset.TestSetFailedException;
import org.testng.TestNG;
import org.testng.xml.XmlSuite;
-import static java.lang.Integer.parseInt;
import static org.apache.maven.surefire.api.booter.ProviderParameterNames.PARALLEL_PROP;
import static org.apache.maven.surefire.api.booter.ProviderParameterNames.THREADCOUNT_PROP;
import static org.apache.maven.surefire.testng.conf.AbstractDirectConfigurator.loadListenerClasses;
@@ -68,9 +67,18 @@ public class TestNGMapConfigurator
protected void configureThreadCount( XmlSuite suite, Map<String, String> options )
throws TestSetFailedException
{
- String threadCountAsString = options.get( THREADCOUNT_PROP );
- int threadCount = threadCountAsString == null ? 1 : parseInt( threadCountAsString );
- suite.setThreadCount( threadCount );
+ String threadCount = options.get( THREADCOUNT_PROP );
+ if ( threadCount != null )
+ {
+ try
+ {
+ suite.setThreadCount( Integer.parseInt( threadCount ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new TestSetFailedException( "Non-integer TestNG [threadcount] setting: " + threadCount, e );
+ }
+ }
}
protected void configureParallel( XmlSuite suite, Map<String, String> options )