Test Automation and CI using Serenity BDD & Jenkins for an Oracle ADF Application: Part 4 of 5

Serenity BDD: What is it? Where is it used?

Serenity BDD is an open source library that helps developers and testers write maintainable automated acceptance and regression tests faster. It also uses the test results to produce illustrated, narrative reports that document and describe what your application does and how it works. A developer can build Serenity test suites using Maven, Gradle, or Ant. Serenity BDD provides strong support for automated web tests using Selenium 2. To learn more about the basic concepts of Behaviour Driven Development or BDD please refer to the link below.


In this blog series we explain how to

Part 1: Install Serenity BDD and configure the environment
Part 2: Build sample Serenity project/test suite using maven
Part 3: Configure an existing ADF Application using maven
Part 4: Create Serenity test suite for the maven-based Oracle ADF application
Part 5: Continuous Integration of Serenity test suite using Jenkins

Part 4: Create Serenity test suite for the maven-based Oracle ADF application

In this blog you can learn how to write a simple Serenity test for a sample ADF application. I am also providing the attachments for sample ADF application and serenity test suite created to test it in this blog.

Sample ADF application
The Sample ADF application has a simple screen showing the parent child tables with users and user roles. The serenity test we write is to check for a user and navigate through the user roles. The screen below shows the Sample ADF application screen we use for the testing purpose.

Structuring the tests

In Serenity BDD all the captured requirements are converted into structured tests and steps. This tends to make the tests clearer, more flexible and easier to maintain.The main advantage of this structuring is, tests can be defined at very early stages even before the development starts. Below screen shows the test suite created for testing the sample ADF application.

In Serenity the tests and steps are structured using the below annotations which are available in serenity library.

We use the annotation @Steps for the Serenity step library(class), which is a reusable library with collection of steps and can be referenced from many tests.

This annotation is used to define a single step in the library, the step will appear in the generated HTML report as a step with the same name.

Below is the example of step library from the Sample with many methods annotated with @Step.

The step library is referenced in the Test as shown below with the annotation @Steps.

To learn more about step libraries (sharing, reusing libs) please refer to the link below.

This annotation is used to mark the start of a new test, a single test can use multiple step libraries and also can share a single step library. Multiple tests can be written in a single class file.

This annotation is used to provide a title for the test, the test title appears in the HTML report generated when we run the test suite as shown below.

@DefaultUrl annotation is used to define/pass the default Url when page object method open() is called to access the url through a browser window.

@FindBy annotation finds the element on the page which is equivalent to the selenium code snippet (driver.findElement(By.id(“xyz”));

Below are the methods referred in the step library for each step,
Serenity BDD provides strong support for automated web tests using Selenium 2, hence we have selenium webdriver style coding in the methods.

Running the sample integration test produces the below HTML report

Click on the test to see detailed steps execution status and you can also see all the method names under @step annotation appears as a step in the report.

Download Sample Project

hareesha muppalaneni