AgileTestware

TestNG Integration

Report TestNG test results to HP ALM via Bumblebee.

Overview

TestNG generates JUnit-format XML reports that Bumblebee processes and publishes to HP ALM.

Maven Configuration

Add the TestNG dependency and configure Surefire to use TestNG:

<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>7.8.0</version>
  <scope>test</scope>
</dependency>
 
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>3.0.0</version>
  <configuration>
    <suiteXmlFiles>
      <suiteXmlFile>testng.xml</suiteXmlFile>
    </suiteXmlFiles>
  </configuration>
</plugin>

TestNG XML Report Location

TestNG generates reports in:

target/surefire-reports/
  junitreports/
    TEST-com.example.tests.LoginTest.xml
    TEST-com.example.tests.SearchTest.xml

Configure the Bumblebee plugin to look in target/surefire-reports/junitreports/.

TestNG Listeners

For more control over ALM result mapping, add a custom TestNG listener that annotates test results with ALM-specific attributes:

@Listeners(ALMResultListener.class)
public class MyTestClass extends ALMTestBase {
    @Test
    @ALMTestCase(id = "1234")
    public void testLoginFlow() {
        // test implementation
    }
}

Contact [email protected] for the ALMResultListener library.

Cucumber with TestNG

For Cucumber tests running via TestNG:

  1. Use the Cucumber TestNG runner (AbstractTestNGCucumberTests)
  2. Configure Cucumber to generate JUnit XML reports:
@CucumberOptions(
  plugin = {"junit:target/cucumber-reports/cucumber.xml"}
)
public class CucumberTestRunner extends AbstractTestNGCucumberTests {}

Point Bumblebee to target/cucumber-reports/*.xml.

Jenkins Pipeline

post {
  always {
    bumblebeeALMPublisher(
      almServerUrl: 'https://alm.example.com/qcbin',
      almDomain: 'DEFAULT',
      almProject: 'MyProject',
      testResultsPattern: 'target/surefire-reports/junitreports/*.xml',
      testSetFolder: "Root\\CI\\${env.JOB_NAME}"
    )
  }
}

On this page