Overview
Serenity is a framework for BDD, promoting the separation between steps implementation and the actual specification in each test case.
In this tutorial, we will create some tests using Serenity along with JUnit in Java and we will use Xray just to have visibility of the test results.
Description
The following automated tests are taken from Serenity demo tutorials here.
Please note
The original example can be found in the public Github repository from Serenity.
The serenity configuration file should be updated in order to use the correct driver; in our case we'll use "chrome".
Steps are implemented in auxiliary classes such as the ones provided below.
The sample project contains several features specification, with the automated Tests. Below are two of them:
Tests can be run using Maven.
mvn clean test
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.
junit-merge -o results.xml -d target/site/serenity/
After successfully running the Test cases and generating the aggregated JUnit XML report (e.g., results.xml), it can be imported to Xray (either by the REST API or through 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 with 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.