简体   繁体   中英

Selenium - TestNG

This question was asked in an interview. Lets say there is a class with 4 test methods, with priorities given properly. While running the test cases, 3rd test case is getting failed. So, how to make sure that the 4th Test case has been run?

You can utilize Soft Assertions in testNG to do that. Have a look here how this can be utilized.

And here is the SoftAssert class

Also, look here for other methods to do the same.

To make sure that the 4th Test case is always executed you have to set the alwaysRun argument to true along with the TestNG annotation as follows:

@Test(priority=4)(alwaysRun=true)
void pkg3() 
{
    System.out.println("pkg3");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM