lundi 8 février 2021

How to retrieve test method status, and other values in IReporter implementation

it's required to retrieve test method status, actual result, expected result & other attributes in IReporter implementation. is it possible to use ITestResult to pass required data to generateReport() method in IReporter implementation? any other suggestion would be appreciated.

sample test class as follows,

    public void methodOne() {

        //Values I want to pass to generateReport
        String testString01;
        String testString02;
        String testString03;

        //Status of the method one - pass/fail
        Assert.assertTrue(true);
    }

testNG xml as follows,

<?xml version="1.0" encoding="UTF-8"?>
<suite name="TestRunner" verbose="1" configfailurepolicy="continue">

    <listeners>
        <listener class-name="com.wsdscd.util.TestNGEmailableReport2"/>
    </listeners>
    <test name="TestRunner">
        <classes>
            <class name="com.dsfscce.tests.poc.POC"></class>
        </classes>
    </test>
</suite>

IReporter implementation as follows,

public class TestNGEmailableReport2 implements IReporter {

    @Override
    public void generateReport(List<XmlSuite> xml, List<ISuite> suites, String outdir) {

//required to retrieve data method data here
//required to retrive suite information here 
}}

Aucun commentaire:

Enregistrer un commentaire