AgileTestware

JUnit Integration

Report JUnit test results to HP ALM via Bumblebee.

Overview

JUnit test results are reported to HP ALM via Bumblebee. JUnit generates standard Surefire XML reports which Bumblebee processes and publishes to ALM.

Maven Configuration

Add the Surefire plugin to your pom.xml if not already present:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>3.0.0</version>
  <configuration>
    <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
  </configuration>
</plugin>

Maven Surefire generates XML reports in target/surefire-reports/ by default.

Gradle Configuration

Gradle generates JUnit XML reports in build/test-results/test/ by default. No additional configuration is required.

To customize the output directory:

test {
  reports {
    junitXml.outputLocation = file("$buildDir/junit-reports")
  }
}

Jenkins Pipeline

Configure the Bumblebee Jenkins plugin post-build step to pick up the Surefire reports:

pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        sh 'mvn test'
      }
    }
  }
  post {
    always {
      bumblebeeALMPublisher(
        almServerUrl: 'https://alm.example.com/qcbin',
        almDomain: 'DEFAULT',
        almProject: 'MyProject',
        testResultsPattern: 'target/surefire-reports/*.xml',
        testSetFolder: "Root\\CI\\${env.JOB_NAME}"
      )
    }
  }
}

ALM Test Case Naming

By default, Bumblebee creates ALM test cases using:

  • Test Plan path: Subject\<testClass>
  • Test case name: <testMethod>

For example, com.example.tests.LoginTest#testSuccessfulLogin creates:

  • Folder: Subject\com.example.tests.LoginTest
  • Test case: testSuccessfulLogin

To strip the package prefix, configure a classNameMapping in your alm-mappings.xml. See Field Mapping.

JUnit 5

JUnit 5 is fully supported. The JUnit Platform generates compatible XML reports automatically when using the junit-platform-launcher with the junit-platform-reporting module:

<dependency>
  <groupId>org.junit.platform</groupId>
  <artifactId>junit-platform-reporting</artifactId>
  <version>1.10.0</version>
  <scope>test</scope>
</dependency>

On this page