Whenever we specify priority and dependsOnMethods on a @Test annotated method, the order of execution of test methods is not according to the priority. why is so? Here is the test class to demonstrate the 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
===============================================
All Tests Suite
Total tests run: 4, Failures: 0, Skips: 0
===============================================Expected output :
Running 1
Running 2
Running 3
Running 4
===============================================
All Tests Suite
Total tests run: 4, Failures: 0, Skips: 0
===============================================The order of test execution should have been t1, t2, t3, t4. why is t4 getting executed after t1, when t2 and t3 have higher priority then t4?
TIA
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Hi Krishnan
Please read my reply below to krishnan's concern. there i have specified the requirement. TIA
@dataprovider is really just a convenience feature; it doesn't do anything you couldn't do yourself with a loop. You can and should use @afterClass rather than use this lack of dataprovider as an excuse to make cleanup a test when it really isn't one. Alternatively, you could setup the XML to run T3 and T4 in that order, I think that would achieve your goal as well.
--