Running API tests with Serenity
Serenity BDD is an open source library that aims to make the idea of living documentation a reality. It also uses the test results to produce illustrated, narrative reports that document and describe what your application does and how it works.
Getting Started
This page explains how to setup the API testing framework built with Java and Serenity BDD.
Prerequisites
Set an environment variable BASE_URL
(e.g. if testing locally set it to http://localhost:9000
) or use the export BASE_URL=http://localhost:9000
command.
Running the tests
To run all tests please navigate to ./api-tests
path and execute the following command:
- Unix
- Windows
./mvnw clean verify
mvnw.cmd clean verify
To run the Smoke tests independently, use:
- Unix
- Windows
./mvnw clean verify -Dcucumber.options="--tags @Smoke"
mvnw.cmd clean verify -Dcucumber.options="--tags @Smoke"
To run the Functional tests independently, use:
- Unix
- Windows
./mvnw clean verify -Dcucumber.options="--tags @Functional"
mvnw.cmd clean verify -Dcucumber.options="--tags @Functional"
To run tests by other tags and ignore tests that contain @Ignore tags use:
- Unix
- Windows
./mvnw clean verify -Dcucumber.options="--tags ~@Ignore --tags @YourTag"
mvnw.cmd clean verify -Dcucumber.options="--tags ~@Ignore --tags @YourTag"
Test Report
As a result of the test execution - serenity-maven-plugin
will automatically generate the test report - ./api-tests/target/site/serenity/index.html
.
Note
To manually aggregate the Serenity report execute the following command under ./api-tests
directory:
- Unix
- Windows
./mvnw serenity:aggregate
mvnw.cmd serenity:aggregate