Using Priority Test Case in TestNG

Test Case: 1

package testng;

import org.testng.annotations.Test;

public class PriorityTestCase 
{
	@Test (priority=1)
	public void register()
	{
		System.out.println("Create an account in Gmail" +"\n");
	}
	@Test (priority=2)
	public void login()
	{
		System.out.println("Login into an account in Gmail" +"\n");
	}
	@Test (priority=3)
	public void logout()
	{
		System.out.println("Logout from Gmail account" +"\n");
	}

}

Output 1:

[TestNG] Running:  
  C:\Users\QA\AppData\Local\Temp\testng-eclipse-241244459\testng-customsuite.xml

Create an account in Gmail

Login into an account in Gmail

Logout from Gmail account

PASSED: register
PASSED: login
PASSED: logout

===============================================
    Default test
    Tests run: 3, Failures: 0, Skips: 0
===============================================

Test Case 2:

package testng;

import org.testng.annotations.Test;

public class PriorityTestCase 
{
	@Test (priority=3)
	public void register()
	{
		System.out.println("Create an account in Gmail" +"\n");
	}
	@Test (priority=2)
	public void login()
	{
		System.out.println("Login into an account in Gmail" +"\n");
	}
	@Test (priority=1)
	public void logout()
	{
		System.out.println("Logout from Gmail account" +"\n");
	}

}

Output 2:

[TestNG] Running:
  C:\Users\QA\AppData\Local\Temp\testng-eclipse--1702558414\testng-customsuite.xml

Logout from Gmail account

Login into an account in Gmail

Create an account in Gmail

PASSED: logout
PASSED: login
PASSED: register

===============================================
    Default test
    Tests run: 3, Failures: 0, Skips: 0
===============================================

 

Leave a Reply

Your email address will not be published. Required fields are marked *