Serenity BDD is a library that makes it easier to write high quality automated acceptance tests, with powerful reporting and living documentation features. It has strong support for both web testing with Selenium, and API testing using RestAssured.
Serenity strongly encourages good test automation design, and supports several design patterns, including classic Page Objects, the newer Lean Page Objects/ Action Classes approach, and the more sophisticated and flexible Screenplay pattern.
This project shows how to use the newer Lean Page Objects/ Action Classes approach.
The project has build scripts for both Maven and Gradle, and follows the standard directory structure used in most Serenity projects:
src
+ main
+ test
+ java Test runners and supporting code
+ pages Lean page objects and elements
+ interactions Interactions with elements
+ stepdefinitions Cucumber step definitions (glue with gherkin feature files)
+ resources
+ features Feature files
+ cart Feature file subdirectories
add_products_cart.feature
Serenity 2.2.13 introduced integration with WebdriverManager to download webdriver binaries.
To run the sample project, you can either just run the CucumberTestSuite
test runner class, or run either mvn verify
from the command line.
By default, the tests will run using Chrome. You can run them in Firefox by overriding the driver
system property, e.g.
$ mvn clean verify -Ddriver=firefox
The test results will be recorded in the target/site/serenity
directory.
For more information about Serenity BDD, you can read the Serenity BDD Book, the official online Serenity documentation source. Other sources include:
- Byte-sized Serenity BDD - tips and tricks about Serenity BDD
- For regular posts on agile test automation best practices, join the Agile Test Automation Secrets groups on LinkedIn and Facebook
- Serenity BDD Blog - regular articles about Serenity BDD