A sample BDD Automation framework using Cucumber7, JUnit 5, Selenide, Allure, Logback, Gradle.
Support running tests in parallel, sharing data among test steps, manage Objects using Spring Dependency Injection and clean up created data using API.
Sample tests against Unsplash web app.
- Cucumber - 7.11.1
- Junit - 5.9.2
- Spring Boot - 2.6.14
- Gradle - 7.4.2
- Selenide - 5.24.2
- Selenide wiki
- Allure - 2.19.0
- Logback - 1.2.11
- AssertJ - 3.20.2
Reference Links:
-
run all tests in parallel, number of threads can be specified in RunCucumberTests.class, junit-platform.properties or command line:
- cucumber.execution.parallel.enabled: set to true to enable parallel execution
- cucumber.execution.parallel.config.fixed.parallelism: integer, set number of threads
- cucumber.execution.execution-mode.feature:
- concurrent (scenarios are executed in parallel on any available thread)
- same_thread (executes scenarios sequentially in the same thread as the parent feature)
$ ./gradlew clean test --info $ ./gradlew clean test -Dcucumber.execution.parallel.enabled=true --info
-
run all tests in
firefox
browser
$ gradlew -Dselenide.browser=firefox clean test --info
-
run tests in Selenium Grid
- enable parallel execution properties in junit-platform.properties
- set these 2 properties in selenide.properties
- selenide.remote.execution = true
- selenide.remote = http://localhost:4444/wd/hub (Grid hub Url)
-
Debug test on IntelliJ IDE. Run Debug RunCucumberTests.java as JUnit Test
After the tests are ran, you can see:
- logs from file appender under
build/logs/log.log
- Allure results
build/allure-results
Represents test context to save/get test data and share it among test steps in one Cucumber scenario.
Example:
scenarioContext.setContext(DataItem.COLLECTION_NAME, collectionName);
String collectionName = (String) scenarioContext.getContext(DataItem.COLLECTION_NAME);
Represents a storage to store test data and handle clean up after each Cucumber scenario.
Example:
dataStorage.setCollectionNames(collectionName);
Allure report will contain framework logs, Selenide browser interaction logs, screenshots and page sources for failing test cases
- Allure CLI should be installed
- Allure results stored in
build/allure-results
- To generate allure report, first navigate to unsplash directory then run command:
$ allure serve
You can find logback configuration here src/test/resources/logback-test.xml
Current configuration contains two appenders: (default log level: INFO)
- ConsoleAppender will output logs to system out stream
- FileAppender will output logs to
build/logs/log.log