What is the priority of Test in testng if no priority set?

When the @Test annotation in TestNG does not have a priority attribute, the test method is assigned a default priority of 0. If multiple test methods are defined with explicit priorities such as 1, 2, or 3, the test without a priority (i.e., with default priority 0) will be executed before those.

To execute any test before the one with default priority 0, you need to assign it a negative priority value (e.g., -1, -2, etc.).

Example:

@Test
public void test1() {
System.out.println("Test 1");
}

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

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

Output:

Test 3   // priority -1
Test 1 // priority 0 (default)
Test 2 // priority 1
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Testingtalkslatest.com - A project by CreativeHub IT Solutions.
Contact Us At: support@testingtalkslatest.com
Our Partner websites - Classified Hub , CodesToolbox , CodesToolbox
Scroll to Top
0
Would love your thoughts, please comment.x
()
x