Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cmccarthyirl/spring-cucumber-junit-parallel-test-harness
Spring, Cucumber, Java 17, JUnit 5, Logback and Extent Spark Reports basic test harness. Rest Assured and Selenium test examples provided
https://github.com/cmccarthyirl/spring-cucumber-junit-parallel-test-harness
allure-report cucumber extent-reports jdk17 junit-platform junit5 parallel rest-assured selenium spark-reports spring test-automation test-harness
Last synced: about 22 hours ago
JSON representation
Spring, Cucumber, Java 17, JUnit 5, Logback and Extent Spark Reports basic test harness. Rest Assured and Selenium test examples provided
- Host: GitHub
- URL: https://github.com/cmccarthyirl/spring-cucumber-junit-parallel-test-harness
- Owner: cmccarthyIrl
- License: mit
- Created: 2020-09-24T18:59:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-29T02:45:07.000Z (5 months ago)
- Last Synced: 2024-08-29T11:21:12.416Z (5 months ago)
- Topics: allure-report, cucumber, extent-reports, jdk17, junit-platform, junit5, parallel, rest-assured, selenium, spark-reports, spring, test-automation, test-harness
- Language: Java
- Homepage:
- Size: 222 KB
- Stars: 9
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE.txt
Awesome Lists containing this project
README
# Spring Cucumber JUnit Parallel Test Harness
[![test](https://github.com/cmccarthyIrl/spring-cucumber-junit-parallel-test-harness/actions/workflows/test.yml/badge.svg)](https://github.com/cmccarthyIrl/spring-cucumber-junit-parallel-test-harness/actions/workflows/test.yml)
# Index
Start
| Maven
| Quickstart |
Run
| JUnit
| JUnit Suites
| Command Line
| IDE Support
| Java JDK
| Troubleshooting |
Report
| Configuration
| Environment Switching
| Extent HTML Reports
| Logging |
Advanced
| Before / After Hooks
| JSON Transforms
| Contributing |
# Maven
The Framework uses [Spring Boot Test](https://spring.io/guides/gs/testing-web/)
, [Cucumber](https://cucumber.io/)
, [Rest Assured](https://rest-assured.io/) and [Selenium](https://www.selenium.dev/) client implementations.Spring ``:
```xml
...
org.springframework.amqp
spring-rabbit
${spring-rabbit.version}
org.springframework.boot
spring-boot-starter-test
org.springframework
spring-test
...```
Cucumber & Rest Assured ``:
```xml
...
rest-assured
io.rest-assured
${restassured.version}
cucumber-java
io.cucumber
cucumber-spring
io.cucumber
cucumber-junit-platform-engine
io.cucumber
...```
Selenium ``:
```xml
...
org.seleniumhq.selenium
selenium-java
${selenium-version}
org.seleniumhq.selenium
selenium-server
${selenium-version}
...```
# Quickstart
- [Intellij IDE](https://www.jetbrains.com/idea/) - `Recommended`
- [Java JDK 17](https://jdk.java.net/java-se-ri/11)
- [Apache Maven](https://maven.apache.org/docs/3.6.3/release-notes.html)# JUnit 5
By using the [JUnit](https://junit.org/junit5/docs/current/user-guide/) and
the [Cucumber JVM](https://cucumber.io/docs/installation/java/) `@Cucumber` Annotation Type we can specify our Cucumber
Options like so :```properties
cucumber.execution.parallel.enabled=true
cucumber.execution.parallel.config.strategy=fixed
cucumber.execution.parallel.config.fixed.parallelism=5
cucumber.plugin=io.qameta.allure.cucumber6jvm.AllureCucumber6Jvm,com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:,pretty,json:target/cucumber/report.json,
```Right click the `WeatherRunnerTest` or class and select `Run`
```java
@Cucumber
public class WeatherRunnerTest {
}
```# Command Line
Normally you will use your IDE to run a `*.feature` file directly or via the `*Test.java` class. With the `Test` class,
we can run tests from the command-line as well.Note that the `mvn test` command only runs test classes that follow the `*Test.java` naming convention.
You can run a single test or a suite or tests like so :
```
mvn test -Dtest=WeatherRunnerTest
``````
mvn test -Dtest=JunitSuiteTest
```Note that the `mvn clean install` command runs all test Classes that follow the `*Test.java` naming convention
```
mvn clean install
```# IDE Support
To minimize the discrepancies between IDE versions and Locales the `` is set to `UTF-8`
```xml
...
UTF-8
UTF-8
...```
# Java JDK
The Java version to use is defined in the `maven-compiler-plugin`
```xml
...
...
org.apache.maven.plugins
maven-compiler-plugin
11
11
...
...```
# Configuration
The `AbstractTestDefinition` class is responsible for specifying each Step class as `@SpringBootTest` and
its `@ContextConfiguration`> All the `Step Classes` in the Framework should `extend` the `AbstractTestDefinition` class
```java
@ContextConfiguration(classes = {FrameworkContextConfiguration.class})
@SpringBootTest
public class AbstractTestDefinition {
}
```The `FrameworkContextConfiguration` class is responsible for specifying the Spring `@Configuration`, modules to scan,
properties to use etc```java
@EnableRetry
@Configuration
@ComponentScan({
"com.cmccarthy.ui","com.cmccarthy.common"
})
@PropertySource("application.properties")
public class FrameworkContextConfiguration {
}
```# Environment Switching
There is only one thing you need to do to switch the environment - which is to set `` property in the
Master POM.> By default, the value of `spring.profiles.active` is defined in the `application.properties` file which inherits its
> value from the Master POM property `````xml
...
prod
true
prod
...```
You can then specify the profile to use when running Maven from the command line like so:
```
mvn clean install -P dev
```Below is an example of the `application.properties` file.
```properties
spring.profiles.active=@activatedProperties@
```# Extent Spark Reports
The Framework uses [Spark Reports Framework](http://www.extentreports.com/docs/versions/4/java/spark-reporter.html) to
generate the HTML Test ReportsThe example below is a report generated by Extent Reports open-source library.
# Allure Reports
The Framework uses [Allure Reports](https://docs.qameta.io/allure/) to generate the HTML Test Reports
The example below is a report generated by Allure Reports open-source library.
To generate the above report navigate to the root directory of the module under test and execute the following command
`mvn allure:serve` or `mvn allure:generate` (for an offline report)
# Logging
The Framework uses [Logback](https://logback.qos.ch/) You can instantiate the logging service in any Class
like so```java
private final Logger logger=LoggerFactory.getLogger(WikipediaPageSteps.class);
```you can then use the logger like so :
```java
logger.info("This is a info message");
logger.warn("This is a warning message");
logger.debug("This is a info message");
logger.error("This is a error message");
```# Before / After Hooks
The [Log4j2](https://logging.apache.org/log4j/2.x/) logging service is initialized from the `Hooks.class`
```java
public class Hooks {@Autowired
private HookUtils hookUtil;@After
public void afterScenario(Scenario scenario) {
hookUtil.endOfTest(scenario);
}
}
```# JSON Transforms
[Rest Assured IO](https://rest-assured.io/) is used to map the `Response` Objects to their respective `POJO` Classes
```xml
io.rest-assured
rest-assured
3.0.0```
# Troubleshooting
- Execute the following commands to resolve any dependency issues
1. `cd ~/install directory path/spring-cucumber-junit-parallel-test-harness`
2. `mvn clean install -DskipTests`# Contributing
Spotted a mistake? Questions? Suggestions?
[Open an Issue](https://github.com/cmccarthyIrl/spring-cucumber-junit-parallel-test-harness/issues)