I am trying to run the following 2 tests in parallel using TestNG 6.13.1 and gradle from an Android studio 3.0 project.
Here is my testng.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default test suite">
<!--parallel="methods" thread-count="4">-->
<listeners>
<listener class-name="org.testng.reporters.XMLReporter"></listener>
</listeners>
<test name="SignIn Test" >
<classes>
<class name="com.android.testinglibrary.DeviceTesting.Appium.SignInTest"/>
</classes>
</test>
<test name="HealthCheck Test" >
<classes>
<class name="com.android.testinglibrary.DeviceTesting.Appium.HealthCheckTest"/>
</classes>
</test>
</suite>
I am trying to use Gradle TestNG Options documented at: https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/testng/TestNGOptions.html The gradle test api documentation can be found at: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html
I am running following task which is specified in my build.gradle file task real {
description = "real"
tasks.withType(Test) {
useTestNG() {
//maxParallelForks = 2
options {
suites 'src/test/java/com/android/testinglibrary/DeviceTesting/Appium/testng.xml'
setParallel('tests')
setThreadCount(2)
}
}
}
}
I am running the above task from windows terminal using following command
gradlew real testinglibrary:testDebugUnitTest
With these settings, it runs the same 'HealthCheck Test' in 2 parallel threads. Hence it duplicates the running of 1st test found. After that it runs SignIn Test in single thread. Ideally it should start both HealthCheck Test and SignIn Test in 2 threads at the same time and should NOT duplicate the running of HealthCheck Test. It also does NOT seem to read thread-count from testng.xml and that is why I commented it out in testng.xml file above. I also commented out //maxParallelForks = 2 from build.gradle as it was NOT doing any parallelization of tests. It looks like testng api within gradle is buggy.
Please guide how to achieve parallelization of my appium integration tests using TestNG, gradle (not maven) from an android studio test automation framework.
Try to remove
setParallel('tests') setThreadCount(2)
and use corresponding settings in xml only
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.