A sample BDD Automation framework using Cucumber6, JUnit 5, Selenide, Gradle, Allure, logback.
Support running tests in parallel, sharing data among test steps and manage Page Objects using Dependency Injection.
Sample tests against Unsplash web app.
- Junit - 5.7.2
- Gradle - 7.6
- Cucumber - 6.11.0
- Selenide - 5.24.0
- Selenide wiki
- PicoContainer - 6.11.0
- Allure - 2.14.0
- Allure-Selenide - 2.14.0
- Allure-Cucumber - 2.14.0
- Logback - 1.2.5
- AssertJ - 3.20.2
Reference Links:
-
run all tests in parallel, number of threads can be specified in CukesTestRunner or junit-platform.properties or from command:
$ gradlew -Dcucumber.execution.parallel.config.fixed.parallelism=3 clean test --info
-
run all tests with specific tag.
$ gradlew -Dcucumber.filter.tags=@id-002 clean test --info
-
run all tests in
firefox
browser.$ gradlew -Dselenide.browser=firefox clean test --info
-
Debug test on IntelliJ IDE. Trigger Debug using CukesTestRunner.java.
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.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