Tests are not running in correct order if parallel="classes" is used with tests having dependsOnGroup and Priority
See original GitHub issueTestNG Version
7.4.0
Expected behavior
Actual behavior
Is the issue reproducible on runner?
- Shell
- Maven
- Gradle
- Ant
- Eclipse
- IntelliJ
- NetBeans
Test case sample
package com.org.testng7;
import org.testng.annotations.Test;
public class Testng7{
public Testng7() {
// TODO Auto-generated constructor stub
}
@Test(groups = { "g1" }, priority = 1)
public void t1() {
System.out.println("Testng7:test 1" + " Thread ID: " + Thread.currentThread().getId());
}
@Test(groups = { "g2" }, dependsOnGroups = "g1", priority = 3)
public void t2() {
System.out.println("Testng7:test 2" + " Thread ID: " + Thread.currentThread().getId());
}
@Test(groups = { "g2" }, dependsOnGroups = "g1", priority = 2)
public void t3() {
System.out.println("Testng7:test 3" + " Thread ID: " + Thread.currentThread().getId());
}
@Test(groups = { "g2" }, dependsOnGroups = "g1", priority = 5)
public void t4() {
System.out.println("Testng7:test 4" + " Thread ID: " + Thread.currentThread().getId());
}
@Test(groups = { "g2" }, priority = 4)
public void t5() {
System.out.println("Testng7:test 5" + " Thread ID: " + Thread.currentThread().getId());
}
}
// Another File
package com.org.testng7;
import org.testng.annotations.Test;
import com.kronos.testng.BaseUITest;
public class Testng7_copy{
public Testng7_copy() {
// TODO Auto-generated constructor stub
}
@Test(groups = { "g1" }, priority = 1)
public void Testng7_copyt1() {
System.out.println("Testng7_copy:test 1" + " Thread ID: " + Thread.currentThread().getId());
}
@Test(groups = { "g2" }, dependsOnGroups = "g1", priority = 3)
public void Testng7_copyt2() {
System.out.println("Testng7_copy:test 2" + " Thread ID: " + Thread.currentThread().getId());
}
@Test(groups = { "g2" }, dependsOnGroups = "g1", priority = 2)
public void Testng7_copyt3() {
System.out.println("Testng7_copy:test 3" + " Thread ID: " + Thread.currentThread().getId());
}
@Test(groups = { "g2" }, dependsOnGroups = "g1", priority = 5)
public void Testng7_copyt4() {
System.out.println("Testng7_copy:test 4" + " Thread ID: " + Thread.currentThread().getId());
}
@Test(groups = { "g2" }, priority = 4)
public void Testng7_copyt5() {
System.out.println("Testng7_copy:test 5" + " Thread ID: " + Thread.currentThread().getId());
}
}
//Testng.xml file
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suites" parallel="classes" thread-count="2"
configfailurepolicy="continue">
<test name="Tests" >
<groups>
<run>
<include name="g1" />
<include name="g2" />
</run>
</groups>
<classes>
<class name="com.org.testng7.Testng7" />
<class name="com.org.testng7.Testng7_copy" />
</classes>
</test>
</suite>
Issue Analytics
- State:
- Created 2 years ago
- Comments:24
Top Results From Across the Web
java - Parallel(methods) execution with dependsOn running in ...
A soft dependency is obtained by adding "alwaysRun=true" in your @Test annotation. For the dependsOnGroup example it reads. In this example, ...
Read more >What are TestNG Dependent Tests and How to ... - Tools QA
Often, we want to run our test cases in a particular order in TestNG. We may use the priority parameter for that, no...
Read more >Documentation - TestNG
By default, TestNG will run your tests in the order they are found in the XML file. ... If not set, default mechanism...
Read more >testng not running in priority order when dependsOnMethods ...
The order of test execution should have been t1, t2, t3, t4. why is t4 getting executed after t1, when t2 and t3...
Read more >Annotations - TestNG Docs
@AfterTest: The annotated method will be run after all the test methods belonging to the classes inside the tag have run.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure but it is not expected. See the disabled tests: https://github.com/cbeust/testng/blob/master/testng-core/src/test/java/test/priority/PriorityTest.java
@krmahadevan I agree with your definition of soft/hard dependencies but it doesn’t explain why a soft dependency could not be respected.