ngoanh2n / selenide-junit5-allure-example

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub stars GitHub forks

Table of Contents

Example of Selenide, JUnit5, Allure

Frameworks

Gradle: 8.6 - Build Tool
Selenide: 7.2.1 - WebDriver
JUnit5: 5.10.2 - Testing Framework
Allure: 2.25.0 - Report Framework

Structure

├── gradle
│   ├── config
│   │   ├── allure.gradle
│   │   ├── compilation.gradle
│   │   ├── dependencies.gradle
│   │   └── test.gradle
│   ├── wrapper
│   │   ├── gradle-wrapper.jar
│   │   └── gradle-wrapper.properties
│   ├── helpers.gradle
│   └── versions.gradle
├── images
│   └── **/*.png
├── src/test
│   ├── java/com/github/ngoanh2n/example
│   │   ├── common
│   │   │   ├── AbstractPage.java
│   │   │   └── AbstractTest.java
│   │   ├── models
│   │   │   └── Account.java
│   │   ├── pages
│   │   │   ├── shared
│   │   │   │   └── Header.java
│   │   │   ├── LoginPage.java
│   │   │   └── PortalPage.java
│   │   └── scripts
│   │       └── ExampleTest.java
│   └── resources
│       ├── account.yml
│       ├── allure.properties
│       ├── categories.json
│       ├── junit-platform.properties
│       ├── log4j.properties
│       └── selenide.properties
├── .gitignore
├── README.md
├── build.gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle

Usages

Configurations

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

Settings can be set either via system property or programmatically.

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.

allure.properties

For configuring all Allure properties by passing classpath.

categories.json

For defining categories to group tests. Below is a sample category.

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

Test Execution

Browser

Use JVM System Property selenide.browser to pass expected browser.
Giving values can be: [chrome, edge, firefox, safari, ie].

gradlew test -Dselenide.browser=firefox

Note: If run safari, you must enable the Allow Remote Automation option in Safari's Develop menu to control Safari via WebDriver.

Filter

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

gradlew test -Dselenide.browser=firefox --tests ExampleTest.passedTest

Refer to Test Filtering for more information.

Allure Report

Add task allureReport to your test command.
It generates from build/allure-results to build/allure/allureReport.

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

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 selenide-junit5-allure-example/build/allure/allureReport

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 security.fileuri.strict_origin_policy
  • 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 Automation Test in Java

License:MIT License


Languages

Language:Java 100.0%