DEV Community


Posted on • Updated on


Serenity running in parallel - Serenity part 4/4

I'm back with the last part of Serenity, you can definitely check the previous parts in here:
Serenity part 1
Serenity part 2
Serenity part 3

In this blog post, we will go through the setup step for how to run serenity parallel tests with cucumber using maven fail safe plugin with cucumber-jvm-parallel-plugin.

You can definitely check the serenity book for details.

What you will need to do is simply this:

1.POM file:

maven failsafe plugin defined for running parallel test for each test class.


Enter fullscreen mode Exit fullscreen mode
                            <!-- Mandatory -->
                            <!-- List of package names to scan for glue code. -->

Enter fullscreen mode Exit fullscreen mode

cucumber jvm parallel plugin to generate runners when you execute test.
Without it , the parallel test won't work.

2.Features file defined for the test:
In this test we will run the test for facebook login page and qcCoccoc login page.

  • feature file for facebook login
  Scenario Outline: User login successfully with correct
    Given Navigate to facebook login page
    When Login facebook with '<phone>' and '<password>'
    Then Should navigate to facebook homepage
Enter fullscreen mode Exit fullscreen mode
  • feature file for qcCoccoc login

  Scenario Outline: Login successfully with email and password
    Given Navigate to quang cao coc coc login site
    When Login with '<email>' and '<password>'
    Then Should navigate to home page site
Enter fullscreen mode Exit fullscreen mode

3.Tests defined in cucumber format:

  • For facebook login page:
    private pages.facebook.LoginPage loginPage_facebook;

    @Given("^Navigate to facebook login page$")
    public void navigateToFacebookLoginPage() {



    @When("^Login facebook with '(.*)' and '(.*)'$")
    public void loginFacebookWithPhoneAndPassword(String phone, String password) {



    @Then("^Should navigate to facebook homepage$")
    public void shouldNavigateToFacebookHomepage() {

        WebDriverWait wait = new WebDriverWait(getDriver(),2);


Enter fullscreen mode Exit fullscreen mode

First user navigate to facebook login page, then after fill in the credential details, we will assert whether the url still contain "login"
text or not.

-For qcCoccoc login page, the step is pretty the same:

public class LoginPage extends BaseTest {

    private pages.qcCocCoc.LoginPage loginPage_pageobject;"^Navigate to quang cao coc coc login site$")
    public void navigateToQuangCaoCocCocLoginSite() {;


    @When("^Login with '(.*)' and '(.*)'$")
    public void loginWithEmailAndPassword(String email, String password) {



    @Then("^Should navigate to home page site$")
    public void shouldNavigateToHomePageSite() {
        WebDriverWait wait = new WebDriverWait(getDriver(),2);


    @Then("^Should prompt with '(.*)'$")
    public void shouldPromptWithErrormessage(String errorMessage) {

        softAssertImpl.assertThat("Verify message error",loginPage_pageobject.getMessageError().contains(errorMessage),true);


Enter fullscreen mode Exit fullscreen mode

4.Run the tests:

  • To run the test simply using mvn command line

mvn clean verify -Dcucumber.options="--tags @Login"

This will run the cucumber test has tag @Login

  • To run only the facebook test with serenity report, run command line:

mvn clean verify -Dtest=ui.cucumber.facebook.AcceptanceTest serenity:aggregate

Alt Text

You can check out the source code in github

Leave a heart or comment if you have any!!


Notes: If you feel this blog help you and want to show the appreciation, feel free to drop by :

This will help me to contributing more valued contents.

Top comments (2)

raydebug profile image

Can you show an example for running Serenity UI testing in Jenkins which starts the springboot application in localhost(Jenkins)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.