question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Priority of test methods is ignored

See original GitHub issue

TestNG Version

org.testng:testng:7.0.0

(This worked just fine with version 6.9.6)

Expected behavior

Because of the set priorities I expect following execution order: test05 test04 test02 test03 test01

This works when running from Eclipse IDE.

Actual behavior

Unfortunately, when running from IntelliJ or Gradle (tried with 5.4.1 and 5.6.2) it results in following execution order: test01 test02 test03 test04 test05

Is the issue reproductible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

I have following test class:

public class TryOut {

	@Test(priority = 4)
	public void test01() {
		System.out.println("test01");
	}

	@Test(priority = 3)
	public void test02() {
		System.out.println("test02");
	}

	@Test(priority = 3)
	public void test03() {
		System.out.println("test03");
	}

	@Test(priority = 2)
	public void test04() {
		System.out.println("test04");
	}

	@Test(priority = 1)
	public void test05() {
		System.out.println("test05");
	}
}

build.gradle:

plugins {
    id 'java'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.testng:testng:7.0.0'
}

// Test Logging
test {
	useTestNG()
    testLogging {
        showStandardStreams = true
    }
}

The Gradle command: ./gradlew test --tests mypackage.TryOut

Here the complete Gradle project: TestNgExample.zip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:28 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
mayanktoccommented, May 27, 2021

Problem with 7.4.0 is still exist. I am using Gradle project.

2reactions
juherrcommented, Jan 4, 2020

I’m able to reproduce the issue in a fresh IntelliJ project but not if I add the test in the TestNG project itself. I confirm the issue happens only with 7.x versions and not previous ones.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TestNG Test Case Priority And Sequence - Tools QA
The test methods with no priority assigned have a default priority equal to 0. It means if we define no priorities, all the...
Read more >
testng not running in priority order when dependsOnMethods ...
My solution was to add the dependsOnMethods to ALL of my test methods, while I kept the priority also for ALL of the...
Read more >
Order of execution for Tests in TestNg, If Priority set only for ...
If you are not using any priority in your test method then TestNG assign by default priority=0 to the Test Method; If there...
Read more >
TestNG @Test Priority in Selenium - Guru99
If we don't mention any priority, testng will execute the @Test methods based on alphabetical order of their method names irrespective of ...
Read more >
TestNG Tutorials 22: @Test Annotation - Games Of Priority Of ...
TestNG ignore default priority based on ASCII if priority value is provided. You can pass duplicate priority to test methods. In case of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found