question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to check the test case corresponding to the invocation-numbers value from testng-failed.xml?

See original GitHub issue

TestNG Version

7.4.0

Expected behavior

The test that failed in the first run should be the one that is retried.

Actual behavior

Some other test is run in the retry using the testng-failed.xml file.

Is the issue reproducible on runner?

  • Shell
  • Maven
  • [✓] Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

I’m having a bunch of tests that I run in parallel with a dataproviderthreadcount of 10. I see that the test that fails in the first run is not the same as that run in a retry using the testng-failed.xml file that looks like below. I believe the invocation-numbers property value is used for retrying the failed tests. Since I observe the issue with a 100% replication rate, I’d first like to understand how to identify the test case corresponding to this value.

<suite thread-count="10" parallel="classes" name="Failed suite [Gradle suite]" verbose="0">
<test thread-count="10" parallel="classes" name="Gradle test(failed)" verbose="0">
<groups>
<run>
<include name="GROUP_1"/>
<include name="GROUP_2"/>
</run>
</groups>
<classes>
<class name="package.TestSample">
<methods>
<include name="beforeSuiteHook"/>
<include name="verifySomething" invocation-numbers="9"/>
<include name="beforeMethodHook"/>
<include name="afterSuiteHook"/>
</methods>
</class>
<!--  package.TestSample  -->
</classes>
</test>
<!--  Gradle test(failed)  -->
</suite>
<!--  Failed suite [Gradle suite]  -->

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:23

github_iconTop GitHub Comments

1reaction
krmahadevancommented, Dec 12, 2022

do you mean the point 3 in that comment isn’t taken care of in your code sample?

Yes.

I’m wondering if there’s a simpler way to log all the test records corresponding to all the invocation-numbers. Since I see that the test failed is not the one retried, I’d like to check if the testng-failed.xml has correct invocation-numbers in the first place.

There does not exist anything today. Which was why I shared a sample that shows you how to do it.

1reaction
krmahadevancommented, Dec 12, 2022

Does it also mean the retry attempt with such a custom generated testng-failed.xml file as an input will not work since it does not have invocation-numbers (asking this since the sample generated testng suite xml does not have invocation-numbers)?

That was a file that I created manually for demonstration purposes. If you are generating the TestNG suite xml file wherein you would like to build the intelligence of a retry of the failed invocation counts, then you would need to ensure that you include these values as well. What I shared is not meant to be used as a “use as is solution” but something that you would need to work on and tweak. So please try it out and then raise any specific issues that you may have encountered.

If this has answered your question, please feel free to close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Execute Failed Test Cases in TestNG - Guru99
Running testng-failed.xml file from Command line. Step 1) To run failed test cases in command prompt. Open the command prompt and go to...
Read more >
Running testng-failed.xml correctly runs failed test in child ...
I have tests distributed across child class and a base class that it extends from. Both the classes are in different packages. DataProviderTest....
Read more >
How to Run Failed test cases using xml report file in TestNG
Selenium WebDriver | Part45 | How to Execute Failed Test Cases in Selenium WebDriver | Retry Logic. Automation Testing Insider.
Read more >
Identifying the list of test cases failed in testng - Stack Overflow
1 Answer 1 · Checks if the file testng-failed.xml exists in the target folder. · If found then a rerun can be done....
Read more >
How to run failed test cases in TestNG & Selenium
Go back to Test3, change the assert value to true and rerun the testng-failed.xml file. This will execute only the failed test case...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found