Search code examples
junittestngqaf

QAF - How To update junitreports.xml when running BDDStepFactory2


Im currently using QAF at my job and recently setup a few CICD tests using Azure Devops.

Azure Devops at the moment is only designed to read to Junit .XML results in their reporting dasbboard.

When running a Maven test, TestNG automatically creates a JunitReports folder that has a .xml report in it.

The issue is that when using QAF and using BDDStepFactory2 in my config.xml file, my junit report shows all tests as ignored.

Is there a way I can continue using BDDStepFactory2 and get the Junitresults to show either pass or fails?

EDIT:

The JunitResult is generating, however, this is what it looks like

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by org.testng.reporters.JUnitReportReporter -->
<testsuite skipped="2" hostname=
name="com.qmetry.qaf.automation.step.client.DataDrivenScenario" tests="4" failures="0" timestamp="2021-12-27T16:21:34 EST" time="12.916" errors="0">
  <testcase name="Validate the Home Page" time="7.287" classname="com.qmetry.qaf.automation.step.client.DataDrivenScenario"/>
  <system-out/>
  <testcase name="Validate the Home Page" time="5.629" classname="com.qmetry.qaf.automation.step.client.DataDrivenScenario"/>
  <system-out/>
  <testcase name="scenario" classname="com.qmetry.qaf.automation.step.client.DataDrivenScenario">
    <skipped/>
  </testcase> <!-- scenario -->
  <system-out/>
  <testcase name="scenario" classname="com.qmetry.qaf.automation.step.client.DataDrivenScenario">
    <skipped/>
  </testcase> <!-- scenario -->
  <system-out/>
</testsuite> <!-- com.qmetry.qaf.automation.step.client.DataDrivenScenario-> ```

At the top, the xml is showing skipped="2". Since this is what Azure devops is reading, it is seeming like two of my tests have been skipped.


Solution

  • Most probably issue with TestNG version. Try latest (7.4.0) version of TestNG with latest (3.1.0-RC1) version of QAF.

    <dependency>
     <groupId>com.qmetry</groupId>
     <artifactId>qaf</artifactId>
     <version>3.1.0-RC1</version>
    </dependency>
    <!-- order is important -->
    <dependency>
     <groupId>org.testng</groupId>
     <artifactId>testng</artifactId>
     <version>7.4.0</version>
    </dependency> 
    

    In order to write step information in junit report (just like testng reporter output) enable testng output by setting property.

    report.log.testngoutput=true
    

    Check your test-results directory, You may find junit report for each execution. For instance <project-root>\test-results\<timestamp>\junitreports. In case you don't found junit reports generated, you can enable testng default listeners.