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 186110d691..874e7f1f3c 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.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 void configure( XmlSuite suite, Map options ) protected void configureThreadCount( XmlSuite suite, Map 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 options )