Table of Contents generated with DocToc
Platform: macOS Mojave
IDE: IntelliJ IDEA 2019.3.1 (Community Edition)
Java: 1.8.0_211
Gradle: 6.1.1
Selenide: 5.6.1 - Web Driver
TestNG: 7.1.0 - Testing Framework
Cucumber: 5.0.0 - Behavior Driven Development (BDD) Tool
Cucumber Reporting: 0.1.16 - Generating Reports From CucumberTestReport.json For Gradle
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── images
│ └── **/*.png
├── src/test
│ ├── java/com/github/ngoanh2n
│ │ ├── common
│ │ │ ├── BasePage.java
│ │ │ ├── BaseTest.java
│ │ │ └── ScenarioHooks.java
│ │ ├── pages
│ │ │ ├── HomePage.java
│ │ │ └── LoginPage.java
│ │ ├── scenarios
│ │ │ └── ExampleTest.java
│ │ └── steps
│ │ ├── HomePageStepsDefinition.java
│ │ └── LoginPageStepsDefinition.java
│ └── resources
│ ├── com/github/ngoanh2n/features
│ │ ├── home
│ │ │ ├── welcome-title.feature
│ │ └── login
│ │ ├── login-failure.feature
│ │ └── login-success.feature
│ ├── log4j.properties
│ └── selenide.properties
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
$ git clone https://github.com/ngoanh2n/selenide-testng-cucumber-example.git
You can change values for your case.
- log4j.properties
Configuring log4j involves assigning the Level, defining Appender, and specifying Layout objects in a configuration file.
- selenide.properties
Configuration settings for Selenide default browser. Settings can be set either via system property or programmatically.
./gradlew clean test
- chrome
- firefox
- ie
- edge
- htmlunit
- phantomjs
- safari
If run safari, you must enable the 'Allow Remote Automation' option in Safari's Develop menu to control Safari via WebDriver.
Able to select browser by passing system property selenide.browser
./gradlew clean test -Dselenide.browser=firefox
You can filter tests by using option --tests
Giving values can be TestPackage
, TestClass
, TestMethod
./gradlew clean test -Dselenide.browser=firefox --tests ExampleTest
Choose feature files to run by passing system property cucumber.filter.tags
./gradlew clean test -Dcucumber.filter.tags="TAG_EXPRESSION"
Available tags in project's features:
@Client
,@Home
,@HomeWelcome
tagged in feature welcome-title.feature@Client
,@Login
,@LoginSuccess
tagged in feature login-success.feature@Client
,@Login
,@LoginFailure
tagged in feature login-failure.feature
A tag expression is an infix boolean expression. Below are some examples:
Tag Expression | Description | Features Filtered |
---|---|---|
@Client |
Features tagged with @Client |
welcome-title, login-success, login-failure |
@Login or @HomeWelcome |
Features tagged with either @Login or @HomeWelcome |
welcome-title, login-success, login-failure |
@Login and @LoginFailure |
Features tagged with both @Login and @LoginFailure |
login-failure |
@Client and not @Login |
Features tagged with @Client that aren’t also tagged with @Login |
welcome-title |
For even more advanced tag expressions you can use parenthesis for clarity, or to change operator precedence:
(@Login or @Home) and (not @LoginFailure)
-> welcome-title, login-success
Note
: After test command finished, results are generated at selenide-testng-cucumber-example/build/cucumber-reports
Open file selenide-testng-cucumber-example/build/cucumber-reports/cucumber-pretty/index.html
, you can see:
Note
: After test command finished, results are generated by gradle-cucumber-reporting
plugin at selenide-testng-cucumber-example/build/cucumber-html-reports
Open file gradle-cucumber-reporting
plugin at selenide-testng-cucumber-example/build/cucumber-html-reports/overview-tags.html
, you can see: