In this tutorial, we will create a JUnit Test Case in Java, using the Appium library for automation of Android applications.
The following automated test is taken from the tutorials for Android provided by Appium.
This example is found in the public Github repository in https://github.com/appium/tutorial/tree/master/projects/java_android. It also provides examples for other languages.
- The Android emulator should be started with a compatible virtual device.
- Appium must be running in the machine with Android SDK.
We will make a simple update to the pom.xml file in order to generate a JUnit xml report.
The class implementing the automated tests needs to be updated in order to properly set up the IP of the Appium server, along with the required Android version.
The sample project contains two classes with automated Tests. Below is one of them:
Tests can be run using Maven.
Since the previous command generates multiple JUnit XML files, we may need to merge them into a single XML file so it can be submitted into a Test Execution more easily. That can be achieved by using the junit-merge utility.
After successfully running the Test cases and generating the aggregated JUnit XML report (e.g., results.xml), it can be imported to Xray (by using either the REST API or the Import Execution Results action within the Test Execution).
Each JUnit's Test Case is mapped to a Generic Test in Jira, and the Generic Test Definition field contains the name of the package, the class and the method name that implements the Test Case. The summary of each Test issue is filled out from the name of the method corresponding to the JUnit Test.
The Execution Details of the Generic Test contains information about the Test Suite, which in this case corresponds to the Test Case class, including its namespace.