Skip to content

Example project using Selenide, JUnit5, Allure for Test Automation in Java

License

Notifications You must be signed in to change notification settings

elgrassa/selenide-junit5-allure-example

 
 

Repository files navigation

Twitter Follow GitHub followers GitHub forks GitHub stars GitHub watchers

License: MIT badge-jdk Build Status

Selenide, JUnit5, Allure Example

Table of Contents generated with DocToc

Environment

Gradle: 6.1.1
Java: 1.8.0_211
IDE: IntelliJ IDEA 2019.3.1 (Community Edition)

Frameworks/Libraries

Selenide: 5.6.1 - Web Driver
JUnit5 - Platform: 1.6.0 - Testing Launcher
JUnit5 - Jupiter: 5.6.0 - Testing Framework
JUnit5 - Vintage: 5.6.0 - Test Engine
Allure: 2.13.1 - Test Report
Allure Gradle: 2.8.1 - Gradle Plugin

Project Structure

├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── images
│   └── **/*.png
├── src/test
│   ├── java/com/github/ngoanh2n/sjae
│   │   ├── common
│   │   │   ├── BasePage.java
│   │   │   └── BaseTest.java
│   │   ├── components
│   │   │   └── Header.java
│   │   ├── pages
│   │   │   ├── LoginPage.java
│   │   │   └── PortalPage.java
│   │   └── scenarios
│   │       └── ExampleTest.java
│   └── resources
│       ├── allure.properties
│       ├── categories.json
│       ├── junit-platform.properties
│       ├── log4j.properties
│       └── selenide.properties
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle

How To Use

Clone Repository

$ git clone https://github.com/ngoanh2n/selenide-junit5-allure-example.git

Configuration Files

You can change values for your case.

  1. log4j.properties

    Configuring log4j involves assigning the Level, defining Appender, and specifying Layout objects in a configuration file.

  2. selenide.properties

    Configuration settings for Selenide default browser. Settings can be set either via system property or programmatically.

  3. junit-platform.properties

    If a properties file with this name is present in the root of the classpath, it will be used as a source for configuration parameters. If multiple files are present, only the first one detected in the classpath will be used.

  4. allure.properties

    Configuring all Allure properties by passing classpath.

  5. categories.json for Allure Report

    Defining categories to group tests.
    Category structure:

    {
      "name": "{Category name}",
      "matchedStatuses": "{One or more statuses of tests}",
      "traceRegex": "{Exception name}",
      "messageRegex": "{The content or description of Exeception}"
    }

    Define a category by the following:

    • matchedStatuses -> The status of test, one in skipped, passed, broken, failed, unknown
    • traceRegex -> Find the exception caused status to the test
    • messageRegex -> Get content or description shortly or fully
    • name -> Set category name based on above keys

Run Tests With Gradle

./gradlew clean test allureReport

Task allureReport: Build report from selenide-junit5-allure-example/build/allure-results folder

Perform On Browsers

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

Filter Tests

You can filter tests by using option --tests
Giving values can be TestPackage, TestClass, TestMethod

./gradlew clean test -Dselenide.browser=firefox --tests ExampleTest.passedTest allureReport

Allure Report

Note: If your test command contains task allureReport, when tests finished you can see below message in terminal likes.

> Task :allureReport
Report successfully generated to /Users/ngoanh2n/Desktop/Work/guides-test-automation/selenide-junit5-allure-example/build/reports/allure-report

Open your browser with above path by Firefox
Note: If you see Allure report is displayed likes below image. Then you have to do by the following:.

  • Go to about:config in new tab
  • Search for privacy.file_unique_origin
  • Finally, change value to false, and refresh tab Allure Report

Otherwise, you can see below.

Overview

Categories

Behaviors

About

Example project using Selenide, JUnit5, Allure for Test Automation in Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%