Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

1 like 0 dislike
288 views
by The go-to Tester (344 points)
retagged by
What is the use of @test method priority in TestNG

1 Answer

1 like 0 dislike
by The go-to Tester (473 points)
selected by
 
Best answer
In single class we can write number of @test methods. And execution order of these @test methods are not difined. It means execution of test case is not depend on any other test case execution order.

Now some time we want test case execution in predefined order. So to achieve this we use parameter 'priority' in @Test

Low number priority means highest priority 0>1>2>3 etc....

@Test(priority = 0)   ---case1

@Test(priority = 2) ---case2

@Test(priority = 1) ---case3

@Test(priority = 3) ---case4

Execution order will be::

case1

case3

case2

case4

 

test case2 will never run before case3 and case0. Same with case4


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...