Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SUREFIRE-2075] Only set thread count if specified in configuration #528

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@ public void withTestNG740AndParallelSet()
.executeTest()
.assertTestSuiteResults( 2, 0, 0, 0 );
}

@Test
public void withTestNG740AndParallelSetWithoutThreadCount()
{
unpack( "testng-740-parallel-without-threadcount" )
.executeTest()
.assertTestSuiteResults( 2, 0, 0, 0 );
}
}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package testng.simple;

/*
* 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.testng.annotations.Test;


public class TestNG740ParallelTest {
@Test
public void testOne() {

}

@Test
public void testTwo() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
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;
Expand Down Expand Up @@ -68,9 +67,18 @@ public void configure( XmlSuite suite, Map<String, String> options )
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 )
Expand Down