Extent report plus parallel test (parallel = "tests")

48 views
Skip to first unread message

MCD dotCom

unread,
Sep 25, 2022, 7:36:05 PM9/25/22
to testng-users
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:
        <!-- https://mvnrepository.com/artifact/com.relevantcodes/extentreports -->
        <dependency>
            <groupId>com.relevantcodes</groupId>
            <artifactId>extentreports</artifactId>
            <version>2.41.2</version>
        </dependency>

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. 

one.pngtwo.pngthree.png

⇜Krishnan Mahadevan⇝

unread,
Oct 2, 2022, 5:28:32 AM10/2/22
to testng...@googlegroups.com
Please post your query on the extent reports forum. TestNG does not own/maintain extent reports.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/7f42e86f-6c60-4550-93d3-1e13361d6462n%40googlegroups.com.

MCD dotCom

unread,
Oct 2, 2022, 2:07:19 PM10/2/22
to testng-users
Thank you!
Reply all
Reply to author
Forward
0 new messages