Load Testing with Serenity BDD and Cucumber
In this tutorial, you'll learn how to reuse existing tests written with Serenity BDD and Cucumber for load testing.
Get Step SaaS for free to follow this tutorialPrerequisites
- Access to a Step cluster: Get started quickly by setting up a free SaaS cluster in the Step Portal, or, if preferred, follow the Installation page to configure your own on-premise cluster.
- Maven: Follow the official Maven documentation to install Maven
Test scenario
For the sake of this tutorial, we’ll simulate 10 parallel users visiting our demo online store. The typical visit that we’ll simulate consists of the following actions: navigate to the online store, search for a product, and open the product details.
Checkout the sample
Clone the Sample project from GitHub:
git clone https://github.com/exense/step-samples
Navigate to the sample directory:
cd step-samples/automation-packages/load-testing-serenity/
Project structure
The project follows a standard Maven structure.
Project descriptor
At the root of the folder, you’ll find the project descriptor pom.xml
which contains following high-level dependencies:
- Serenity BDD
- Cucumber
- Step
The pom.xml
also contains the declaration and configuration of the Step Maven plugin which delegates the execution of the test to Step during the verify
phase.
Define the URL of your Step cluster and your API key (refer to Generate an API Key) in following section:
<properties>
...
<step.url>https://your-step-cluster.stepcloud.ch/</step.url>
<step.auth-token>Your API key</step.auth-token>
<step.step-project-name>Common</step.step-project-name>
</properties>
Load test descriptor
The main file of the project is located in src/main/resources/automation-package.yaml
. It corresponds to the Automation Package descriptor of Step, which describes the load test scenario as YAML:
schemaVersion: 1.0.0
name: "load-testing-serenity"
plans:
- name: "Demo Serenity Load Test"
root:
threadGroup:
# Run the sequence with 10 VUs
users: 10
# Perform 1000 iterations per user
iterations: 1000
children:
# Call the keyword executeAllFeatures defined in the class SerenityKeywords
- callKeyword:
keyword: "executeAllFeatures"
Serenity test
The automation package references the executeAllFeatures
keyword, defined in the SerenityKeywords Java class, which invokes the standard JUnit test defined in SerenityTestRunner.java
.
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
plugin = {"html:reports/cucumber-html-report.html",
"json:reports/cucumber.json"}
,features= {"classpath:features"}
,glue = {"step.examples.serenity.stepdefinition"}
,monochrome = true
)
public class SerenityTestRunner {
}
Execute locally
Optionally, you can run the test locally:
mvn clean compile test
automation-package.yaml
, launching all virtual users in parallel on your local machine. Depending on your machine’s capacity, you may want to adjust the load test parameters before executing the test.
Execute in Step
To trigger the remote execution in Step, run the following maven command:
mvn verify -DskipTests
The test is executed in Step according to the plan specified in automation-package.yaml
. The maven project is configured to wait for the execution to complete.
The command outputs a direct link to the execution report in Step:
[INFO] Execution(s) started in Step:
[INFO] - 'Demo Serenity Load Test' (https://your-step-cluster.stepcloud.ch/#/executions/6708c4ecf7255b00b3a39220)
[INFO] Waiting for execution(s) to complete...
Analyze the result
Open the execution report in Step by clicking the direct link printed by the command above.
In the Performance tab, you can explore detailed performance metrics:
There you’ll find all metrics related to the Cucumber steps.
Review the transaction statistics
At the bottom of the Performance view, you’ll find an aggregation of performance metrics for the selected time frame:
Do more
Step lets you reuse automation artifacts across the whole DevOps cycle, and load testing is just one aspect of it. The same Serenity tests could be easily reused for large-scale E2E tests, synthetic monitoring, and robotics.
This article demonstrates how to connect Grafana to data generated by Step.
This article demonstrates how to set up distributed system monitoring using Keyword executions, and analyze the results as measurements.
This tutorial demonstrates how to automate interaction with Microsoft Office applications using the Office Interop Assembly.
This article provides documentation for how to integrate JUnit tests into Step.
This tutorial demonstrates how Step can be used to monitor services, availability and performance metrics.
This tutorial demonstrates how to utilize the AutoIt C# binding to automate interactions with Windows applications.
This article demonstrates the automation of mobile applications on Android using the Appium framework.
This article defines three Keywords which will be used in browser-based automation scenarios, using Step and Selenium, as general drivers.
This tutorial shows you how to efficiently set up a browser-based load test using existing Cypress tests in the Step automation platform.
In this short tutorial, we show how to quickly implement a simple browser-based load test based on Cypress scripts in Step.
This tutorial shows you how to set up a browser-based load test using existing Playwright tests in the Step UI.
This article explains Keywords in Step and demonstrates how to create simple ones.
This tutorial demonstrates the design, execution, and analysis of functional tests using the web interface of Step.
This tutorial will demonstrate how to use Step and Selenium to automate various browser tasks.
This tutorial demonstrates how to use Step and Cypress to automate various browser tasks.
This tutorial demonstrates how Selenium automation tests can be turned into full synthetic monitoring using Step.
In this tutorial, you'll learn how to reuse existing Cypress tests to quickly set up and run a browser-based load test using the automation as code approach.
This tutorial demonstrates how Cypress automation tests can be turned into full synthetic monitoring using the automation as code approach.
In this tutorial, you'll learn how to reuse existing Cypress tests to quickly set up and run a browser-based load test using the Step UI.
This tutorial demonstrates how to leverage existing Selenium tests to set up and execute browser-based load tests, following a full code-based approach.
This tutorial demonstrates how to set up a browser-based load test in the Step UI using existing Selenium tests.
This tutorial demonstrates how Playwright automation tests can be turned into full synthetic monitoring using Step.
This tutorial demonstrates how Cypress automation tests can be turned into full synthetic monitoring using the Step UI.
This tutorial will demonstrate how to use Step and Playwright to automate various browser tasks.
In this tutorial, you'll learn how to reuse existing Playwright tests written in Java to quickly set up and run a browser-based load test using the automation as code approach.
Quickly integrate K6 based load-tests in your DevOps workflow
This tutorial demonstrates how Playwright tests can be reused for synthetic monitoring of a productive environment in a DevOps workflow
This tutorial demonstrates how Playwright tests can be reused for synthetic monitoring of a productive environment in a DevOps workflow
In this tutorial you'll learn how to quickly set up a protocol-based load test with okhttp
Learn how to set up continuous end-to-end testing across several applications based on Playwright tests in your DevOps pipeline using Step
Learn how to quickly set up continuous browser-based load testing using Playwright tests in your DevOps pipeline
Want to hear our latest updates about automation?
Don't miss out on our regular blog posts - Subscribe now!