A sample gradle base project which uses jUnit5 for running tests, logback library for logging, Selenide for browser manipulations and Allure framework for reporting.
- will run all the test inside
src/test/tests
.$ gradlew clean test --tests tests.* -i
- will run all the test inside
src/test/tests
on Prod env.$ gradlew clean test --tests tests.* -i -Denv=prod
- will run all the test inside
src/test/tests
on Prod env infirefox
browser.$ gradlew clean test --tests tests.* -i -Denv=prod -Dselenide.browser=firefox
After the tests are ran, you can see:
- jUnit test reports under
build/reports/tests/index.html
- logs from sifter appender under
build/logs/test_case_name.log
- screenshots and saved page sources from Selenide
build/reports/tests
- Allure results
build/allure-results
- Allure report
build/reports/allure-report
- Allure CLI should be installed
- Allure results stored in
build/allure-results
- Allure report stored in
build/reports/allure-report
- To open allure report
$ allure open path_to_allure_report_folder
- Allure report will contain Selenide browser interaction history, screenshots/page sources for failing test cases
- Each test case will have log file attached as an attachment
Selenide provides a lot of things out of the box, no extra configuration required for sample project. In case you would like to do custom configuration you can find an example in AppConfiguration.class.
- Default browser is
chrome
- By default Selenide puts screenshots and .html to folder
build/reports/tests
- To change the browser you can use
-Dselenide.browser=firefox
You can find logback configuration here src/test/resources
Current configuration contains two appenders:
- ConsoleAppender will output logs to system out stream
- SiftingAppender will output logs to separate
build/logs/${testCaseName}.log
for each test case
Path src/main/pages
This class makes generic configuration for the framework and allows us to run tests on different environments by passing system property.
./gradlew clean test --tests tests.* -i -Denv=prod
Initialize application configuration Before test run
Creates separate logger before each test case and attaches log file to allure report after each test case
Represents test run context storage which allows to save/get data and share it between test cases/test classes during test run.
Example:
RunContext.put("key", 123);
int value = RunContext.get("key", Integer.class);