Preserving the Order in TestNG

How to Control the order of execution in TestNG?
Many of you would be wondering if we can control the order of execution in TestNG. Say, if you have 4 Test Cases in a single java file. Based on alphabetical order TestNG will execute the Test Cases. If you want to execute in a specific order as per your requirement, then we can do by prioritizing the order of execution.

Here we are taking an example : TestNGOrder.java which contains 4 Test Cases in a java file. If we execute the Test Cases, TestNG will execute without following the order which we gave the Test Cases. Hence we can set our priority for the order of execution in TestNG like

OUTPUT :

Leave a Comment

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