Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

In this tutorial, we will create a test in TestNG in order to validate a simple browser interaction using BrowserStack for cloud testing.

...

Info
titlePlease note

Within this tutorial, only one Test Execution will be used; it will contain one Test Run with all the results for the different used browsers. Thus, the overall test run status will be affected by the results made for all the browsers.

Instead of this approach, a different one could be creating a Test Execution per each browser; this would require some adaptions in order to produce a XML report per each used browser. This approach would give the ability to take advantage of Test Environments (more info in Working with Test Environments).


Requirements

  • Install Java
  • Install all dependencies using "mvn"

Description

This tutorial is based on BrowserStack's own tutorial for TestNG.

...

The test, which validates a simple search using Google, is implemented in a SingleTest class which extends BrowserStackTestNGTest helper class. The later provides setup related logic, including loading BrowserStack credentials from a configuraiton file.

...

You need to configure the BrowserStack user/key along with desired browser capabilities/devices. We need to update the config/single.conf.json and config/parallel.conf.json files.

Code Block
languagejs
titleconfig/parallel.conf.json
{
  "server": "hub-cloud.browserstack.com",
  "user": "<user>",
  "key": "<key>",

  "capabilities": {
    "browserstack.debug": true
  },

  "environments": {
    "chrome": {
      "browser": "chrome"
    },
    "firefox": {
      "browser": "firefox"
    },
    "safari": {
      "browser": "safari"
    },
    "ie": {
      "browser": "internet explorer"
    }
  }
}

...

No Format
mvn test -P parallel


After successfully running the tests and generating the TestNG XML report (e.g. testng-results.xml), it can be imported to Xray (either by the REST API or through the Import Execution Results action within the Test Execution).

Image Added


TestNG's tests are mapped to Generic Tests in Jira, and the Generic Test Definition field contains the namespace, the name of the class, and the method name that implements the Test case.

The execution screen details will not only provide information on the overall test run result, but also for each stepon a "browser" basis.

For each devicebrowser, a different "context" will appear along with the respective step resultsresult.

Image RemovedImage Added


In BrowserStack you can see some info about it.

Image Added

References