I am using maven with testng 6.14.3.
Here is my code structure:
testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<suite name="set-3" parallel="tests" thread-count="10">
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
</listeners>
<test name="Customer Tests">
<groups>
<run>
<include name="abc"/>
</run>
</groups>
<classes>
<class name="apps.Test1_BeforeTest_Of_Test2"></class>
<class name="apps.Test2"></class>
</classes>
</test>
</suite>
Test1_BeforeTest_Of_Test2.java
public class Test1_BeforeTest_Of_Test2{
@BeforeTest(groups = {"abc"})
public void test1Method() throws Exception {
}
@AfterTest(groups={"abc"})
public void test1AfterMethod() throws Exception {
}
}
Test2.java
public class Test2{
@Test(groups = {"abc"})
public void test2Method(){
}
}
During my run, Test1_BeforeTest_Of_Test2
class fails. So, Test2
is marked as skipped.
But, when I look at the testng-failed.xml
that is generated at the end of the run, the failed @BeforeTest class (Test1_BeforeTest_Of_Test2
) is not included/listed:
testng-failed.xml
<?xml version="1.0" encoding="UTF-8"?>
<suite thread-count="10" name="Failed suite [set-3]" parallel="tests">
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter"/>
</listeners>
<test name="Customer Tests(failed)">
<groups>
<run>
<include name="abc"/>
</run>
</groups>
<classes>
<class name="apps.Test2">
<methods>
<include name="test2Method"/>
</methods>
</class>
</classes>
</test>
</suite>
Is this expected behaviour? Or a bug/gap in testng-failed.xml?
Ideally, when we re-run the failed tests, we expect the @BeforeTest to run as well, because it is pre-req for Test 2.