You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/07/25 14:25:00 UTC

[jira] [Commented] (SUREFIRE-1398) TestNG test fails when both JUnitCore provider and TestNG provider are on classpath

    [ https://issues.apache.org/jira/browse/SUREFIRE-1398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16100103#comment-16100103 ] 

ASF GitHub Bot commented on SUREFIRE-1398:
------------------------------------------

GitHub user MatousJobanek opened a pull request:

    https://github.com/apache/maven-surefire/pull/160

    SUREFIRE-1398 Sets threadCount only when parallel parameter is set

    Otherwise, the TestNG fails with 
    `Cannot use a threadCount parameter less than 1; 1 > 0` 
    in some cases when the parallel parameter was not set. To identify the cases, take a look at related Jira issue: https://issues.apache.org/jira/browse/SUREFIRE-1398
    I removed the check for positiveness of the `threadCount` value as it's a responsibility of the user to provide correct value.
    The question is if the default value of `threadCount` parameter shouldn't be 1, to avoid such a problems...? If yes, then I'll update my PR

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/MatousJobanek/maven-surefire SUREFIRE-1398

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/maven-surefire/pull/160.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #160
    
----
commit 30df0c3fb5cc1f22caf0a9031155cb2d778b3fab
Author: Matous Jobanek <mj...@redhat.com>
Date:   2017-07-25T14:19:01Z

    SUREFIRE-1398 Sets threadCount only when parallel parameter is set

----


> TestNG test fails when both JUnitCore provider and TestNG provider are on classpath
> -----------------------------------------------------------------------------------
>
>                 Key: SUREFIRE-1398
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1398
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Maven Surefire Plugin, TestNG support
>    Affects Versions: 2.20
>            Reporter: Matous Jobanek
>
> When both JUnitCore and TestNG providers are on classpath:
> {code:xml}
>         <plugin>
>             <groupId>org.apache.maven.plugins</groupId>
>             <artifactId>maven-surefire-plugin</artifactId>
>             <version>2.20</version>
>             <dependencies>
>                 <dependency>
>                     <groupId>org.apache.maven.surefire</groupId>
>                     <artifactId>surefire-junit47</artifactId>
>                     <version>2.20</version>
>                 </dependency>
>                 <dependency>
>                     <groupId>org.apache.maven.surefire</groupId>
>                     <artifactId>surefire-testng</artifactId>
>                     <version>2.20</version>
>                 </dependency>
>             </dependencies>
>         </plugin>
> {code}
> then the TestNG execution fails with a message:
> {noformat}
> Configuring TestNG with: TestNG60Configurator
> Cannot use a threadCount parameter less than 1; 1 > 0
> Usage: <main class> [options] The XML suite files to run
>   Options:
>     -configfailurepolicy
>        Configuration failure policy (skip or continue)
>     -d
>        Output directory
>     -dataproviderthreadcount
>        Number of threads to use when running data providers
>     -excludegroups
>        Comma-separated list of group names to  exclude
>     -groups
>        Comma-separated list of group names to be run
>     -junit
>        JUnit mode
>        Default: false
>     -listener
>        List of .class files or list of class names implementing ITestListener or
>        ISuiteListener
>     -methods
>        Comma separated of test methods
>        Default: []
>     -methodselectors
>        List of .class files or list of class names implementing IMethodSelector
>     -mixed
>        Mixed mode - autodetect the type of current test and run it with
>        appropriate runner
>        Default: false
>     -objectfactory
>        List of .class files or list of class names implementing
>        ITestRunnerFactory
>     -parallel
>        Parallel mode (methods, tests or classes)
>        Possible Values: [tests, methods, classes, instances, none, true, false]
>     -port
>        The port
>     -reporter
>        Extended configuration for custom report listener
>     -suitename
>        Default name of test suite, if not specified in suite definition file or
>        source code
>     -suitethreadpoolsize
>        Size of the thread pool to use to run suites
>        Default: 1
>     -testclass
>        The list of test classes
>     -testjar
>        A jar file containing the tests
>     -testname
>        Default name of test, if not specified in suitedefinition file or source
>        code
>     -testnames
>        The list of test names to run
>     -testrunfactory, -testRunFactory
>        The factory used to create tests
>     -threadcount
>        Number of threads to use when running tests in parallel
>     -usedefaultlisteners
>        Whether to use the default listeners
>        Default: true
>     -log, -verbose
>        Level of verbosity
>     -xmlpathinjar
>        The full path to the xml file inside the jar file (only valid if -testjar
>        was specified)
>        Default: testng.xml
> {noformat}
> The same behavior occurs when instead of these two providers I use my own dynamic provider and delegate the execution to the TestNG provider.
> The cause of the behavior is a combination of the method [convertJunitCoreParameters()|https://github.com/apache/maven-surefire/blob/master/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java#L1289] and the TestNG provider.
> The method is called for [JunitCoreProvider|https://github.com/apache/maven-surefire/blob/master/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java#L2696] and sets the thread count to the current value (no matter if it is set or not). In case that it is not set, then the value is 0, which causes the before mentioned failure when {{TestNGProvider}} is being executed.
> The same in case of [DynamicProvider|https://github.com/apache/maven-surefire/blob/master/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java#L2745]
> In the description of the parameter [threadCount|http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#threadCount], there is written that it only makes sense to use in conjunction with the parallel parameter. So, I would propose to set the parameter only when the parameter {{parallel}} is set.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)