Skip to content

A sample BDD Automation framework using Cucumber7, JUnit 5, Selenide, Gradle, Allure, logback. Support running tests in parallel, sharing data among test steps and manage Objects using Spring Dependency Injection.

Notifications You must be signed in to change notification settings

hoangthach252/Cucumber7JUnit5SelenideSpringGradle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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.

Libraries Used

Reference Links:

Run/Debug tests

  • 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
  • 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

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

About

A sample BDD Automation framework using Cucumber7, JUnit 5, Selenide, Gradle, Allure, logback. Support running tests in parallel, sharing data among test steps and manage Objects using Spring Dependency Injection.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published