3

Is there any way to re-run failed tests using TestNG when same set of tests are run in different threads? I see there people use Retry listeners [https://stackoverflow.com/a/36320794/2020491 ] as in this link. But this does not seem to be working when i run same set of tests in multiple threads.

Below is my testng.xml where in com.example.SampleTest i have 2 tests in which 1 fails. i get the below result when run

=============================================== SampleTest Total tests run: 5, Failures: 2, Skips: 1 ===============================================

The one with test name="ONE", failed test runs for the second time but failed test is not run the second time for test with name="TWO" (when the class names are different for both the tests then this works as expected)

<suite name="SampleTest" verbose="1" parallel="tests" thread-count="1"><test name="ONE">
    <classes>
        <class name="com.example.SampleTest" />
    </classes>
</test>
<test name="TWO">
    <classes>
        <class name="com.example.SampleTest" />
    </classes>
</test>

<listeners>
    <listener class-name="com.example.TestListener"/>
    <listener class-name="com.example.RetryListener"/>
</listeners> </suite>

Below is my class file

@Test
public void testOne(){
    Assert.assertTrue(false);
}

@Test
public void testTwo(){
    Assert.assertTrue(true);
}
Community
  • 1
  • 1
user2649233
  • 912
  • 4
  • 14
  • 28
  • As you are using the same class in 2 tests, I suppose the retry analyzer has some problems to determine the good test method. You should open an issue on github.com/cbeust/testng/issues with a full runnable sample. – juherr Nov 16 '16 at 12:40
  • @JulienHerr Issue is created with github [https://github.com/cbeust/testng/issues/1241 ] – user2649233 Nov 16 '16 at 13:27

0 Answers0