testng: Tests are not running in correct order if parallel="classes" is used with tests having dependsOnGroup and Priority

TestNG Version

7.4.0

Expected behavior

image

Actual behavior

image

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>

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 24 (17 by maintainers)

Most upvoted comments

From what I see in the code, we use priority to sort the free nodes.

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.