Running Serenity Tests
Overview
In this post, we will learn how to run Serenity tests in the project using Maven. Once you have Serenity project setupĀ without any errors, running serenity tests is as easy as running a maven goal.
$ mvn clean verify
From the IDE, you can right click on the project explorer and choose the option in the menu. In real-time, tests would be run in a CI pipeline using Hudson/Jenkins tool. Let’s stick to the development environment
in this post.
Make sure to close all the artifacts of the project before running the tests. For example, you might be viewing the results
of a previous run in a browser. Maven clean is expected to clean some the artifacts of the project esp files under the target
and site directories.
————————————————————————
BUILD FAILURE
————————————————————————
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project
JBehave-Serenity-Example: Failed to clean project:
Maven Failsafe Plugin
The Maven Failsafe Plugin is designed to run integration tests of your projects. More info of the plugin can be found at: https://maven.apache.org/surefire/maven-failsafe-plugin/
You can specify the plugin in your pom.xml. In-case, you built the project from scratch.
<plugin> <artifactId>maven-failsafe-plugin</artifactId> <version>2.19.1</version> <configuration> <includes> <include>**/*Test.java</include> <include>**/*TestSuite.java</include> <include>**/Test*.java</include> <include>**/When*.java</include> </includes> <argLine>-Xmx512m</argLine> <systemPropertyVariables> <webdriver.driver>${webdriver.driver}</webdriver.driver> </systemPropertyVariables> </configuration> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin>
Serenity Test Report
Serenity notifies in the log for the test events like Test start, test pass, test fail etc.
Once all your tests have run, you can view the serenity test reports under the directory:
{Project-Home}targetsiteserenity
index.html would have the consolidated test report.
Serenity provides out-of-the-box test reports when compared to JBehave native reports. Serenity not only produces test results but also living documentation of features, stories etc.
Serenity report gives a detailed view of the test process at each step of the test along with screenshots of the application state during run time of the test.
–
JBehave Tutorials on this website can be found at:
https://www.testingdocs.com/jbehave-framework-tutorial/
For more details on the JBehave framework, visit the official JBehave website at:
http://jbehave.org