In this tutorial, we will create a test in TestNG in order to validate a simple browser interaction using BrowserStack for cloud testing.
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).
- Install Java
- Install all dependencies using "mvn"
This tutorial is based on BrowserStack's own tutorial for TestNG.
You may start by cloning the repository https://github.com/browserstack/testng-browserstack .
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.
If you wish to map the test method to an existing Test issue, or to create links to requirements whenever importing the results, please have a look at the tutorial Testing using TestNG in Java which provides the necessary instructions in order to setup TestNG for this purpose.
You need to configure the BrowserStack user/key along with desired browser capabilities/devices. We need to update the
Test(s) can be run in parallel using the maven "parallel" task.
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).
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 on a "browser" basis.
For each browser, a different "context" will appear along with the respective result.
In BrowserStack you can see some info about it.