Skip to main content
No Result Found

Integrate Automate Jenkins Plugin with Reporting Frameworks

Integrate Automate Jenkins plugin with test reporting frameworks for deeper integration.

Introduction

This document is an extension of Integrate BrowserStack Automate with Jenkins document; please refer it before continuing with this document.

This document would guide you to integrate BrowserStack Automate test results with the below test reporting frameworks:

  • Java - TestNG
  • Java - JUnit
  • NodeJS - WebdriverIO
  • NodeJS - Protractor

Integrating with the above test reporting frameworks is a two step process:

  1. Generating test reports
  2. Embedding test reports

Generating test reports

Follow the below steps to generate test reports.

A prerequisite for embedding test reports is that the Java project must be built with Maven and use TestNG for testing.

To configure your project:

Add the following dependencies to your pom.xml file:

<dependency>
    <groupId>com.browserstack</groupId>
    <artifactId>automate-testassist</artifactId>
    <version>1.1.0</version>
</dependency>

Add the following repositories to your pom.xml file:

<repositories>
  <repository>
    <id>sonatype-nexus-snapshots</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
  </repository>
</repositories>
<pluginRepositories>
  <pluginRepository>
   <id>sonatype-nexus-snapshots</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
  </pluginRepository>
</pluginRepositories>

Add the following plugin to your pom.xml file:

<build>
    <plugins>
      <plugin>
        <groupId>com.browserstack</groupId>
        <artifactId>automate-maven-plugin</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <configuration>
            <source>${jdk.source.version}</source>
            <target>${jdk.target.version}</target>
            <complianceLevel>${jdk.source.version}</complianceLevel>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>test-compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
</build>

You must define the Maven properties, jdk.source.version and jdk.target.version to match your project’s Java versions.

A prerequisite for embedding test reports is that the Java project must be built with Maven and use JUnit for testing.

To configure your project:

Add the following dependencies to your pom.xml file:

<dependency>
    <groupId>com.browserstack</groupId>
    <artifactId>automate-testassist</artifactId>
    <version>1.1.0</version>
</dependency>

Add the following repositories to your pom.xml file:

<repositories>
  <repository>
    <id>sonatype-nexus-snapshots</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
  </repository>
</repositories>
<pluginRepositories>
  <pluginRepository>
   <id>sonatype-nexus-snapshots</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
  </pluginRepository>
</pluginRepositories>

Add the following plugin to your pom.xml file:

<build>
    <plugins>
      <plugin>
        <groupId>com.browserstack</groupId>
        <artifactId>automate-maven-plugin</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <configuration>
            <source>${jdk.source.version}</source>
            <target>${jdk.target.version}</target>
            <complianceLevel>${jdk.source.version}</complianceLevel>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>test-compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
</build>

You must define the Maven properties, jdk.source.version and jdk.target.version to match your project’s Java versions.

To configure WebdriverIO project, add wdio-browserstack-reporter as a dependency in your package.json file.

{
  "dependencies": {
    "wdio-browserstack-reporter": "~0.1.1"
  }
}

Add browserstack as a reporter in your conf file.

// wdio.conf.js
module.exports = {
    // ...
    reporters: ['browserstack'],
    reporterOptions: {
        browserstack: {
            outputDir: './'
        }
    },
    // ...
};

outputDir (optional): defines a directory location for storing browserstack report files. See the wdio-browserstack-reporter GitHub repository is the link for the GitHub repository.

To configure Protractor project, add protractor-browserstack-reporter as a dependency in your package.json file.

{
  "dependencies": {
    "protractor-browserstack-reporter": "~0.1.1"
  }
}

Add browserstack-protractor-reporter as a plugin in your conf file.

// conf.js
'plugins': [{
  'package': "browserstack-protractor-reporter"
}]

outputDir (optional): defines a directory location for storing browserstack report files.

See the protractor BrowserStack reporter GitHub repository.

Embedding test reports

The below steps for embedding test reports are the same for Java JUnit, Java TestNG, NodeJS Protractor, and NodeJS WebdriverIO.

Embedding of the report can be configured by either using Jenkins UI or using a Jenkinsfile.

Once you have completed the above steps, you can configure your Jenkins CI server to embed all the BrowserStack Selenium reports and logs in Jenkins.

  1. Click on Add post-build action in Post-build Actions: Click Add post-build action

  2. Click on Publish JUnit test result report: browserstack automate jenkins plugin publish test report

  3. In the Test report XMLs,
    • Enter *target/surefire-reports/TEST-*.xml for TestNG and JUnit
    • Enter **/browserstack-reports/REPORT-*.xml for WebdriverIO and Protractor
  4. In the Additional test report features section, add Embed BrowserStack Report. Embedding BrowserStack reports in additional test report features section

Use the following code in your Jenkinsfile

junit testDataPublishers: [[$class: 'AutomateTestDataPublisher']], testResults: 'target/surefire-reports/TEST-*.xml'

This is a post build step and should be added after the browserstack block in the Jenkinsfile.

With this integration, you can now view the results of your Selenium Webdriver tests within Jenkins.

Conclusion

By following the steps outlined in this guide, you should have a seamless integration between your existing automation in Jenkins, your Selenium tests, and the BrowserStack Selenium grid. This will help you leverage all the benefits of test automation along with the scale and coverage offered by BrowserStack.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle