Hello,
I am having a problem with extent report running parallel tests using testng <test> tag. I am running the same test from different <test> tags. Extent report shows both same testng test methods in one extent test.
POM:
BaseTest
public class BaseTest2 extends Base{
public static ExtentReports reporter;
public ExtentTest loggerParent = null;
public WebDriver driverGRID;
public static ExtentTest logger = null;
@BeforeSuite
public void initializeReport(){
reporter = new ExtentReports("ExtentReport6.html", true, DisplayOrder.OLDEST_FIRST);
}
@BeforeMethod
public void beforeMethod(Method method) {
logger = reporter.startTest(method.getName()+randNum());
loggerParent.appendChild(logger);
}
@BeforeClass
public void beforeClass() throws MalformedURLException {
ITestResult itr = Reporter.getCurrentTestResult();
String className = itr.getInstance().getClass().getName();
loggerParent = reporter.startTest(className+randNum());
loggerParent.log(LogStatus.INFO, "Before class");
}
FirstTest
public class FirstTest extends BaseTest{
@Test
public void test1() {
logger.log(LogStatus.INFO, "My first test");
}
}
SecondTest
public class SecondTest extends BaseTest2 {
@Test
public void test1() {
logger.log(LogStatus.INFO, "My second test");
}
}
TestNG.xml
<!DOCTYPE suite SYSTEM "
https://testng.org/testng-1.0.dtd">
<suite name="Access Regression Suite" parallel="tests">
<test name="Test1">
<classes>
<class name="Grid.FirstTest" />
</classes>
</test>
<test name="Test2">
<classes>
<class name="Grid.FirstTest" />
<class name="Grid.SecondTest" />
</classes>
</test>
</suite>
As you can see in testNG xml file, I have two different test tags but both calling the same test FirstTest. Please see the attached images(extent report) which show test method from FirstTest class is combined into one extent report test.