简体   繁体   中英

Gradle run TestNG suites in parallel

I have a set of TestNG xml files defining test suites. I'm trying to figure out how to run all the suites in parallel but with gradle. Essentially looking for the equivalent of running java org.testng.TestNG -suitethreadpoolsize 3 testng1.xml testng2.xml testng3.xml . Also note that within the suites, the tests are run in parallel there too. Is this possible to do?

You may try this (assume TestNG xmls placed in src/test/resources ):

dependencies {
    // your other dependencies
    testImplementation 'org.testng:testng:7.4.0'
}

test {
    useTestNG() {
        scanForTestClasses = false
        maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
        suites ('src/test/resources/testng1.xml','src/test/resources/testng2.xml', 'src/test/resources/testng3.xml')
    }
}

It will run all tests in parallel threads, based on testng xml configuration, but the total concurrent threads count is limited by maxParallelForks .

Note, that all tests still be executed in separate threads, not in separate processes, so eg all static variables, etc will be shared. At least I found such behavior during experiments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM