Testcase Prioritization in TestNG

Price: INR 8,999.00
Price: INR 15,999.00
Was: INR 16,999.00

In TestNG, we can prioritize the Test Cases. Test case prioritization means, we can assign the priority to Test case.

 

Test case priority decides test case execution order. Higher prioritize test case execute first. So in TestNG “Priority” is used to schedule the test cases. We can use this feature, When there are multiple test cases, we want to execute test cases in order.

 

We can declare the Priority at Method level as well as Class level. We use need to add annotation as @Test(priority= ). The default value will be zero for priority.If you don’t mention the priority, it will take all the test cases as “priority=0” and execute.

 

Video Tutorial:

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.

 

Test Priority Example in TestNG

Suppose we have test class SamplePrioritization , In this first we execute the tests without prioritization. Later on, we add the priority and execute it again and see the difference in the execution result.

 

Test Priority in TestNG

 

Assign the execution Priority and execute the class. Verify the execution order in TestNG report.

 

Test Priority in TestNG

 

All test cases executed in priority. The first test executes first because we didn’t assign the priority to this and by default the TestNG choose priority zero.

 

So this is all, How you can prioritize the test cases or Set the execution order of the test cases. This is a very important feature in the TestNG.

0 Comment

Leave a Reply