java - testng not running in priority order when dependsOnMethods is specified -
whenever specify priority
, dependsonmethods
on @test
annotated method, order of execution of test methods not according priority. why so? here test class demonstrate issue:
package unittest.testngtestcases; import org.testng.annotations.test; public class testngtest1 { @test(priority=1) public void t1() { system.out.println("running 1"); } @test(priority=2,dependsonmethods="t1") public void t2() { system.out.println("running 2"); } @test(priority=3,dependsonmethods="t2") public void t3() { system.out.println("running 3"); } @test(priority=4) public void t4() { system.out.println("running 4"); } }
actual output :
running 1 running 4 running 2 running 3 =============================================== tests suite total tests run: 4, failures: 0, skips: 0 ===============================================
expected output :
running 1 running 2 running 3 running 4 =============================================== tests suite total tests run: 4, failures: 0, skips: 0 ===============================================
the order of test execution should have been t1, t2, t3, t4. why t4 getting executed after t1, when t2 , t3 have higher priority t4?
tia
all independent methods (that not have @dependsonmethods dependency) executed first. methods dependency executed. if there ambiguity in execution order after ordering, priority comes picture.
this ordering scheme:
- execute independent methods (methods without @dependsonmethods annotation)
- if there ambiguity in ordering use priority resolve ambiguity independent methods
- execute dependent methods in order of dependency
- if there ambiguity in ordering use priority resolve ambiguity dependent methods
- if there still ambiguity (due not using priority or 2 methods having same priority) order them based on alphabetical order.
now ambiguity resolved since no 2 methods can have same name.
Comments
Post a Comment