Issues with dependsOnMethods and Priority being used simultaneously
See original GitHub issueHi, I have a scenario where I have 6 test methods that need executed in order. The first one in the order depends on another test method, and the last method in the order also depends on a different test method. So in total there are 6 tests.
Here’s the example:
@Test(priority = 1)
public void initiateSetup(){
if(setupTests.equals("")){
ReportGenerator.logTest("Setup", "SKIPPED - This test has been skipped", reportMap, REPORT_NAME);
throw new SkipException ("Skipping Test: " + this.testId);
}
else
System.out.println("RUNNING SETUP...");
Assert.assertTrue((!setupTests.equals("")));
}
@Test(priority = 2, dataProvider = "feeder", threadPoolSize = 1, invocationCount = 1, dependsOnMethods = {"initiateSetup"})
@Source(tempSetupDataFile)
public void setupTest() throws NumberFormatException, MalformedURLException, java.text.ParseException, InterruptedException
{
executeSetupTest();
}
@Test(priority = 3)
public void initiateTests(){
System.out.println("RUNNING TESTS...");
}
@Test(priority = 4, dataProvider = "feeder", threadPoolSize = 1, invocationCount = 1)
@Source(tempTestDataFile)
public void runTest() throws NumberFormatException, MalformedURLException, java.text.ParseException, InterruptedException
{
executeTest();
}
@Test(priority = 5)
public void initiateTeardown(){
if(teardownTests.equals("")){
ReportGenerator.logTest("Teardown", "SKIPPED - This test has been skipped", reportMap, REPORT_NAME);
throw new SkipException ("Skipping Test: " + this.testId);
}
else
System.out.println("RUNNING TEARDOWN...");
Assert.assertTrue((!teardownTests.equals("")));
}
@Test(priority = 6, dataProvider = "feeder", threadPoolSize = 1, invocationCount = 1, dependsOnMethods = {"initiateTeardown"})
@Source(tempTeardownDataFile)
public void teardownTest() throws NumberFormatException, MalformedURLException, java.text.ParseException, InterruptedException
{
executeTeardownTest();
}
Now this sequence works fine when I remove the dependsOnMethods attribute from the setupTest and teardownTest methods. The moment I add it back, the sequence goes for a toss, it executes initiateSetup, runTest, initiateTeardown, setupTest, teardownTest in this order. I thought this was fixed in a previous release, isn’t that the case ?
I am using TestNG testng-6.2.1.jar
Issue Analytics
- State:
- Created 10 years ago
- Comments:6
Top Results From Across the Web
TestNg using dependsOnMethods and priority violates priority
Don't provide priority and depends on together, you can group the tests. You can do it like : @Test(priority = 1, groups =...
Read more >combined hard and soft dependencies in single @Test?
Use a group but put @Test(alwaysRun=true) on the shutDownService...maybe? ... I have been experimenting with the "priority" argument, but I don't
Read more >Top 50+ TestNG Interview Questions and Answers for 2022
Ans: Priority is an attribute that tells TestNG which orders have to follow to run test method. It is used to set the...
Read more >Documentation - TestNG
dependsOnMethods, The list of methods this method depends on. ... Note: this attribute used to be called sequential (now deprecated).
Read more >A Quick JUnit vs TestNG Comparison - Baeldung
In the previous JUnit 4 version, we would need to use the @Before and ... A suite is a collection of test cases...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
http://stackoverflow.com/q/39330510/4234729
Fixed by https://github.com/cbeust/testng/pull/1158