[SUREFIRE-1177] added documentation, minimum required TestNG version in IT and refactoring
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/3dba8e7b Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/3dba8e7b Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/3dba8e7b Branch: refs/heads/master Commit: 3dba8e7bdc54a8be1b7e2e349a492d601dd7a4fc Parents: dcf925e Author: Tibor17 <[email protected]> Authored: Wed Sep 30 00:52:47 2015 +0200 Committer: Tibor17 <[email protected]> Committed: Wed Sep 30 00:53:57 2015 +0200 ---------------------------------------------------------------------- .../src/site/apt/examples/testng.apt.vm | 26 ++++++++++++++++++++ .../pom.xml | 3 ++- .../testng/conf/TestNG510Configurator.java | 21 ++++++++-------- .../testng/conf/TestNGMapConfigurator.java | 4 +++ 4 files changed, 43 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/3dba8e7b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm ---------------------------------------------------------------------- diff --git a/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm index 489771b..e9c6cde 100644 --- a/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm +++ b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm @@ -170,6 +170,32 @@ Using TestNG This is particularly useful for slow tests that can have high concurrency, or to quickly and roughly assess the independence and thread safety of your tests and code. + + TestNG 5.10 or higher allows you to run methods in parallel test using data provider. + ++---+ +</plugins> + [...] + <plugin> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + <configuration> + <properties> + <property> + <name>parallel</name> + <value>methods</value> + </property> + <property> + <name>dataproviderthreadcount</name> + <value>30</value> + </property> + </properties> + </configuration> + </plugin> + [...] +</plugins> ++---+ See also {{{./fork-options-and-parallel-execution.html}Fork Options and Parallel Test Execution}}. http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/3dba8e7b/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml index 97414b3..4366138 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml @@ -26,7 +26,8 @@ <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> - <version>6.9.6</version> + <version>5.10</version> + <classifier>jdk15</classifier> </dependency> </dependencies> <build> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/3dba8e7b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG510Configurator.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG510Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG510Configurator.java index 2bb2577..8e12008 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG510Configurator.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG510Configurator.java @@ -25,7 +25,7 @@ import org.testng.xml.XmlSuite; import java.util.Map; /** - * TestNG 5.10 configurator. Add support of dataproviderthreadcount + * TestNG 5.10 configurator. Added support of dataproviderthreadcount. * * @since 2.19 */ @@ -33,15 +33,16 @@ public class TestNG510Configurator extends TestNGMapConfigurator { - @Override - public void configure( XmlSuite suite, Map<String, String> options ) throws TestSetFailedException - { - super.configure( suite, options ); - - String dataProviderThreadCount = options.get( "dataproviderthreadcount" ); - if ( dataProviderThreadCount != null ) + @Override + public void configure( XmlSuite suite, Map<String, String> options ) + throws TestSetFailedException { - suite.setDataProviderThreadCount( Integer.parseInt( dataProviderThreadCount ) ); + super.configure( suite, options ); + + String dataProviderThreadCount = options.get( "dataproviderthreadcount" ); + if ( dataProviderThreadCount != null ) + { + suite.setDataProviderThreadCount( Integer.parseInt( dataProviderThreadCount ) ); + } } - } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/3dba8e7b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java ---------------------------------------------------------------------- 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 0ce0868..fe08810 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 @@ -117,10 +117,14 @@ public class TestNGMapConfigurator // Related issues: // https://issues.apache.org/jira/browse/SUREFIRE-1177 // https://issues.apache.org/jira/browse/SUREFIRE-1179 + // should work in TestNG 6.9.7 + // only useful in specific cases - prevents from passing string instead of integer else if ( "suitethreadpoolsize".equals( key ) ) { val = convert( val, Integer.class ); } + // should work in TestNG 6.9.7 + // only useful in specific cases - prevents from passing string instead of integer else if ( "dataproviderthreadcount".equals( key ) ) { val = convert( val, Integer.class );
