We need to set priority of test cases to execute test case in a particular order. If we do not set priority of test cases then we are not sure the order of execution of test case (i.e. Logout test case may run or execute before Login test case).
Steps to test an application
1. Login
2. Workflow
3. Logout
There is three test cases
1. Login test case
2. Workflow test case
3. Logout test case
How to set priority of test cases
import org.testng.annotations.Test; public class TestCasePriority { @Test(priority=1) public void LoginTest(){ System.out.println(" Login Test case should execute first"); } @Test(priority=2) public void WorkflowTest(){ System.out.println(" Workflow Test case should not execute before Login test case"); } @Test(priority=3) public void LogoutTest(){ System.out.println(" Logout should not execute before Login and Workflow test cases"); System.out.println(" "); } }