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

Serenity BDD: What is it? Where is it used?
Screenshot_20170905-130232.png

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.

http://www.thucydides.info/docs/serenity/

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 5: Continuous Integration of Serenity test suite using Jenkins

In this blog you will see how to do continuous Integration of Sample ADF Maven application and the Sample Serenity test suite developed for the ADF application. The samples are already attached to the previous blogs. Please follow the below steps to achieve this.
Jenkins Installation
Go to the below link and download the windows install for Jenkins
https://jenkins.io/doc/book/installing/
Run the .msi file and setup Jenkins. Please refer to my later blog for complete setup steps, issues you might run into while installing and possible solutions to the issues.

If the Jenkins is successfully installed on your windows machine, you will see something like the below screen.

Install and Configure Plugins
Below are the steps to be followed to configure a plugin in Jenkins.
Click on the Manage Jenkins link on the left side of the dashboard as shown below

Click on the Manage plugins

Select the Available tab and search for the required plugin using Filter, select the plugin and click on Install without restart or Download now and install after restart. Once successfully installed restart the jenkins and the plugins should appear under Installed tab.

To configure the installed plugins click on the Manage Jenkins > Configure System as shown below or the plugins can be configured in the jobs.

For this exercise we will be using the below plugins, more about the plugins and their configuration can be found in the links.
Bitbucket Plugin (Click here)
This plugin integrates Bitbucket with Jenkins and trigger the build process whenever there is a code update pushed to the repository. The configuration required on the bitbucket is to setup a webhook. To add a webhook follow the below steps and the screenshot.
Login to your bitbucket > Select the repository > Click on Settings > Select Webhooks > Click on Add WebHook button

Enter the Webhook details as shown below, the URL i have below is the ngrok generated URL.(https://xyz123.ngrok.io/bitbucket-hook/). Make sure to have /bitbucket-hook/ appended to the URL.

If the Jenkins server is on the localhost, bitbucket is unable to connect to it. Use ngrok a free service which facilitate exposing your localhost to the internet by assigning a public URL. To get the URL download the ngrok and run the ngrok.exe and enter command .
C:/ngrok http (jenkins port) as shown below to generate the new URL.

The rest of the plugin can be configured in the Jenkins job.

Deploy WebLogic Plugin (Click here)
This plugin deploys any artifacts built on Jenkins to a weblogic target (managed server, cluster …) as an application or a library component. Below is configuration i have for the plugin in the Manage Jenkins>Configure System.

I have the below sample code in my configuration file, the sample plugin-configuration.xml file can be found in the above link.





soa_server1
localhost 7001 weblogic welcome1 BY_LOGIN


HTML Publisher plugin (Click here)
This plugin publishes and archives the HTML reports generated by your build.This plugin can be configured in the job.

Setup Jobs

Build and Deploy ADF Maven Sample application
To setup a new Job click on the New Item and select type of project.

Select Freestyle project or Maven project to configure a build job for our ADF Maven Sample, for this exercise we select Maven Project.

Name the Maven project and select the source course management as Git

Enter the repository URL, Credentials and branches to build.
(Note: Make sure you have the webhook configured for this repository in bitbucket , for more details on how to set up webhook refer to the bitbucket plugin above )

Check the checkbox Build when a change is pushed to bitbucket, this will trigger the build when changes are pushed to bitbucket. Webhook is configured for this purpose to alert jenkins and trigger the build.

In the build section specify the pom.xml of the project which needs to be built and the Maven goals, make sure the settings file is pointing to your local .m2 repo settings.xml

The pom.xml location in our case is the Jenkins workspace as the code is cloned and updated from bitbucket at that location.

Select when to run Post Steps

Click on Add post-build action dropdown which is located at the end of the page and select Deploy the artifact to Weblogic environment.

In the Post-build Actions section enter the details of the server where the artifact(EAR file) needs to be deployed and location of the artifact as shown below.

Save the changes.

Build the project
Project can be built using build now link in the project dashboard as shown below or by pushing the updates to the project as we have selected the Checkbox Build when a change is pushed to bitbucket. Make sure to update the project and push the change for the build to automatically trigger (I have made a simple change in ReadMe.txt file and pushed the change using sourcetree client to test my build). The build History will show all the builds which have successfully completed or failed.

To further see the build summary click on the build under the build history, this will open the build page as shown below.

To see the build log click on the console output as shown below.

To see the weblogic deployment log click on the Weblogic Deployments as shown below.

Build ADF Serenity Test Suite Maven project and Publish HTML Report
Create a new Maven project for our ADF Serenity Test Suite similar to the above ADF Maven Sample we just created.

Below is the screen for the Repository setup
(Note: Make sure you have the webhook configured for this repository in bitbucket , for more details on how to set up webhook refer to the bitbucket plugin above )

Below is the screen for the build configuration.

Click on Add post-build action dropdown which is located at the end of the page and select Publish HTML Reports. You will see this option only when you have the HTML Publisher plugin successfully installed in your Jenkins.

In the post-build actions section Configure the Publish HTML Reports plugin as shown in the below screen. Specify the location where the report needs to be archived and Index page which needs to be published on the dashboard.

Save the changes and test the build by using build now link or by pushing the changes to project in the repository which will trigger the build.

Now that we have setup and tested the builds for the Sample projects ADF Maven Sample and ADF Serenity Test Suite, we will now create a pipeline to build the projects.

Setup Pipeline

Jenkins Pipeline is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins, it orchestrates long running activities which can span multiple build slaves.

In this example we will setup a simple pipeline to build ADF Serenity Test suite whenever ADF Maven Sample application is built due to project updates pushed to bitbucket, to setup a pipeline click on New Item from the jenkins dashboard and select Pipeline as shown below.

To know more about Jenkins pipeline and how to script a pipeline refer to the below link.
https://jenkins.io/doc/book/pipeline/

The new simple pipeline has a build trigger and ADF_Maven_Build_Deploy project is placed on watch list, the pipeline build is triggered whenever there is a new ADF_Maven_Build_Deploy build.

Other alternative is to use Poll SCM to build the pipeline in timely manner or on demand as shown below.

We script the Pipeline as shown below to build the ADF_Serenity_TestSuite , you can use the Pipeline Syntax link to generate scripts if you have just started.

hareesha muppalaneni

hareesha muppalaneni

Developer at Fusion Applied
Hareesha has more than 6 years of professional software development experience and has worked on developing solutions for federal agencies during her career. She is ADF 12C Certified Implementation Specialist and is experienced with agile software development techniques. Her current focus is building solutions using Oracle ADF 11g and 12c, Serenity BDD test automation and CI/CD.
hareesha muppalaneni

Leave a Reply

Be the First to Comment!

avatar
  Subscribe  
Notify of