Skip to content

hoangthach252/cucumber6-junit5-selenide-gradle

Repository files navigation

Automation Framework using Cucumber JVM6 + JUnit5 + Selenide + Gradle + Allure + logback

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.

Libraries Used

Reference Links:

Run/Debug tests

  • 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

ScenarioContext

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);

DataStorage

Represents a storage to store test data and handle clean up after each Cucumber scenario.

Example: dataStorage.setCollectionNames(collectionName);

Allure reports

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

Logback configuration

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