Quality Testing

Quality is delighting customers

how to rerun the only the failed test cases in selenium

how to rerun the only the failed test cases in selenium

Views: 480

Reply to This

Replies to This Discussion

You have to add loop for this until you to don't reach at your end result. 

If you can give some example then we can help you much better.

I was asked this question in interview. if there are 300 failed test cases , how you will rerun only these test cases

That is possible only when there are no dependencies on the passed test cases section.

This can be done from using frame work. In the frame we can log the failed cases and we can design script to re-run only failed cases.

Note:Suppose user logout is failed and login is passed. then we are forced or we are bound to test login as we have to reach logout section. Until we are not login we cannot test logout.

Inside the output folder there is another xml file is created for concerning only failed test cases failed_testcases.xml there won't be any passed test cases included. Re-run that xml file will run all failed test cases again. Refer TestNG documentation for more details.

If you are running the tests by using TestNG we can get the failed test cases in the output folder. You can see the file name with "testng-failed.xml". We can directly re-run this file.

To rerun the only the failed test cases in selenium,
use ITestResultset interface
Create method with @aftermethod
and ITestResult result (where result is variable) like

if (ItestResult.Failure==result.getStatus())

also you need to create one utility class with method to take screenshots and call this method.

Pl do let me know if you need more info.
Thanks

Aniruddha

The Art Of Writing Good Test Cases.This article is dedicated towards test case writing. Test case writing forms an important part of any good software testing course in Pune with placement. In fact, it forms the backbone of software testing.
READ MORE=>http://crbtech.in/Testing/art-writing-good-test-cases/

The Art Of Writing Good Test Cases.This article is dedicated towards test case writing. Test case writing forms an important part of any good software testing course in Pune with placement. In fact, it forms the backbone of software testing.
READ MORE=>http://crbtech.in/Testing/art-writing-good-test-cases/

Often times engineers in software testing company encounter issues like network, browser, or system errors. Due to this, some scripts get failed, So it is quite common practice to re-run the failed test cases.

There are a couple of ways we can run the failed test cases, one simple way to do is using the testng-failed.xml file which is generated by TestNG after test execution in the test-output folder, so simply refresh the project & run this XML file.

Other way is a little complicated with it has some advanced features, there an interface in testNG IRetryAnalyzer using which we can define how many times we want to execute/try running the failed test case.

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2020   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service