Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arafkarsh/ms-test-quickstart
Microservice Test Automation Example for SpringBootTest 3.3.4, JUnit 5, TestNG 7, Spock 3, GitHub CoPilot, DiffBlue Cover, RestAssured 5, Cucumber 6, Selenium 4, Mockito 3, WireMock 3, Pact 4. All the testing frameworks are required to fully automate the testing for Microservices-based Apps.
https://github.com/arafkarsh/ms-test-quickstart
copilot copilot-tutorial cucumber diffblue-cover junit5 mockito pact selenium spock springboot3 springboot334 springboottest testng-framework wiremock
Last synced: 5 days ago
JSON representation
Microservice Test Automation Example for SpringBootTest 3.3.4, JUnit 5, TestNG 7, Spock 3, GitHub CoPilot, DiffBlue Cover, RestAssured 5, Cucumber 6, Selenium 4, Mockito 3, WireMock 3, Pact 4. All the testing frameworks are required to fully automate the testing for Microservices-based Apps.
- Host: GitHub
- URL: https://github.com/arafkarsh/ms-test-quickstart
- Owner: arafkarsh
- License: apache-2.0
- Created: 2023-06-11T07:05:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-01T07:25:15.000Z (19 days ago)
- Last Synced: 2025-01-01T08:21:17.558Z (19 days ago)
- Topics: copilot, copilot-tutorial, cucumber, diffblue-cover, junit5, mockito, pact, selenium, spock, springboot3, springboot334, springboottest, testng-framework, wiremock
- Language: Java
- Homepage: http://www.arafkarsh.com
- Size: 5.73 MB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# AI Driven - Test Generation for Microservices
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=arafkarsh_ms-test-quickstart&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=arafkarsh_ms-test-quickstart)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=arafkarsh_ms-test-quickstart&metric=bugs)](https://sonarcloud.io/summary/new_code?id=arafkarsh_ms-test-quickstart)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=arafkarsh_ms-test-quickstart&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=arafkarsh_ms-test-quickstart)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=arafkarsh_ms-test-quickstart&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=arafkarsh_ms-test-quickstart)- SpringBoot - 3.4.1
- Spring Security - 6.4.2
- Jakarta EE - 10
- Java - 21+
- Open API Swagger Docs - 2.7.0
- Google Gson - 2.11.0Thorough automation in application testing is crucial for guaranteeing the dependability and optimal
performance of cloud-native applications, particularly when prioritizing a rapid time-to-market
approach through Continuous Deployment.The approach includes unit testing, integration testing, contract testing, and end-to-end testing.
- Unit testing: A unit test exercises the smallest piece of testable software in the application to determine whether it behaves as expected.
- Component Testing: A component test limits the scope of the exercised software to a portion of the system under test, manipulating the system through internal code interfaces and using test doubles to isolate the code under test from other components.
- Contract testing, facilitated by tools like Pact, ensures that services adhere to the agreed-upon API contracts.
- Integration testing: An Integration Contract test is a test at the boundary of an external service verifying that it meets the contract expected by a consuming service.
- End-to-end testing: An end-to-end test verifies that a system meets external requirements and achieves its goals, testing the entire system from end to end.![Microservices Testing Frameworks](https://raw.githubusercontent.com/arafkarsh/ms-test-quickstart/master/diagrams/Microservices-Testing-Tools.jpg)
## Testing Categories for Microservices
![Microservices Testing Categories](https://raw.githubusercontent.com/arafkarsh/ms-test-quickstart/master/diagrams/Microservices-Testing-Strategies-2.jpg)
| | Testing Category | Tools |
|-----|------------------------------|--------------------------------------------|
| 0 | Testing Platforms | Junit, Spock, TestNG |
| 1 | Unit Testing | Junit, Spock, TestNG |
| 2 | Component Testing | SpringBoot, Cucumber, RestAssured, Mockito |
| 3 | Integration Contract Testing | SpringBoot, Mockito, WireMock, Pact |
| 4 | Integration Testing | SpringBoot, WireMock |
| 5 | UI Testing / E2E Testing | Selenium + Cucumber |## To Run the SpringBoot Application
### Setup the Env Variable for Decrypting the Password Key
Run the follwing command line option
```
$ source encrypt your-db-password your-encrypton-key
```
![Passowrd-Gen](https://raw.githubusercontent.com/arafkarsh/ms-test-quickstart/master/diagrams/Password-Gen.jpg)Your encryption key will be set in the following Environment variable. SpringBoot Will automatically
pickup the encryption key from this environment variable.
```
JASYPT_ENCRYPTOR_PASSWORD=your-encrypton-key
```Update the property file in the local file
```
spring.datasource.password=ENC(kkthRIyJ7ogLJP8PThfXjqko33snTUa9lY1GkyFpzr7KFRVhRVXLOMwNSIzr4EjFGAOWLhWTH5cAWzRzAfs33g==)
```
AND
the property template in src/main/resources/app.props.tmpl
```
spring.datasource.password=ENC(kkthRIyJ7ogLJP8PThfXjqko33snTUa9lY1GkyFpzr7KFRVhRVXLOMwNSIzr4EjFGAOWLhWTH5cAWzRzAfs33g==)
```
You can use the following REST Endpoint to encrypt the sensitive data. This will work only after setting
the environment variable JASYPT_ENCRYPTOR_PASSWORD and creating the first DB password
using the command line options.
![Passowrd-REST](https://raw.githubusercontent.com/arafkarsh/ms-test-quickstart/master/diagrams/ms-test-encrypt.jpg)### 1. Junit (5.10.2) - 134 Test Cases
| 1 | Testing Framework | Version | Test Cases |
|-----|-------------------|---------|------------|
| 1.1 | JUnit 5 | 5.10.2 | 62 |
| 1.2 | SpringBootTest 3 | 3.3.4 | 01 |
| 1.3 | RestAssured 5 | 5.4.0 | 29 |
| 1.4 | Mockito 5 | 5.12.0 | 21 |
| 1.5 | WireMock 3 | 3.6.0 | 12 |
| 1.6 | Cucumber 7 | 7.18.0 | 03 |
| 1.7 | Selenium 4 | 4.12.0 | 02 |
| 1.8 | Pact 4 | 4.0.10 | 03 |### 2. Spring Spock (2.4.0) - 45 Test Cases
| 2 | Testing Framework | Version | Test Cases |
|-----|-------------------|---------|------------|
| 2.1 | Spock 2 | 2.4.0 | 21 |
| 2.2 | SpringBootTest 3 |3.3.4 | 02 |
| 2.3 | RestAssured 5 | 5.4.0 | 08 |
| 2.4 | Mockito 5 | 5.12.0 | 02 |
| 2.5 | WireMock 3 | 3.6.0 | 07 |
| 2.6 | Cucumber 7 | 7.18.0 | 03 |
| 2.7 | Selenium 4 | 4.12.0 | 02 |
| 2.8 | Pact 4 | 4.0.10 | 00 |### 3. TestNG (7.10.2) - 35 Test Cases
| 3 | Testing Framework | Version | Test Cases |
|-----|-------------------|---------|------------|
| 3.1 | TestNG 7 | 7.10.2 | 18 |
| 3.2 | SpringBootTest 3 | 3.3.4 | 02 |
| 3.3 | RestAssured 5 | 5.4.0 | 05 |
| 3.4 | Mockito 5 | 5.12.0 | 02 |
| 3.5 | WireMock 3 | 3.6.0 | 03 |
| 3.6 | Cucumber 7 | 7.18.0 | 03 |
| 3.7 | Selenium 4 | 4.12.0 | 02 |
| 3.8 | Pact | NA | No Support |### 4. Assertions Libraries
| 4 | Testing Framework | Version |
|-----|-------------------|---------|
| 4.1 | Hamcrest 2 | 2.2.0 |
| 4.2 | Google Truth | 1.0.1 |
| 4.3 | AssertJ 3 | 3.26.3 |### 5. Other Utilities
| 5 | Other Libraries | Version |
|-----|-----------------|----------|
| 5.1 | Apache Commons | 3.17.0 |
| 5.2| Apache Http Client | 5.4.1 |
| 5.3 | Apache Http Core | 5.3.1 |
| 5.2 | Google GSON | 2.8.7 |
| 5.3 | Google Guava | 33.3.1.1-jre |
| 5.4 | Faster XML | 2.18.0 |### 6. Logging Framework
| 6 | Logging Libraries | Version |
|---|-------------------|----------|
| 6.1 | SL4J | 2.0.16 |
| 6.2 | Logback | 1.5.8|
| 6.3 | Log stash | 8.0 |### 7. Swagger Documentation
| 7 | Open API Libraries | Version |
|-----|--------------------|---------|
| 7.1 | Open API Webmvc | 2.6.0 |
| 7.2 | Open API Common | 1.8.0 |Order Microservice is part of an eCommerce Application. The objective of selecting this Microservice
is to demonstrate various testing frameworks. As Order is a complex service with internal (Ex. Inventory,
Warhouse, Shipping etc) and external (Payment) service integration and it has all the requirements
to use various testing frameworks. The objective is to demonstrate various testing frameworks.Order Service REST Endpoints are documented using Open API v3.
You can access the API's using http://localhost:9081/test-service/api/v1/swagger-ui.html![MS-Test-Quick-Start-1 based on Open API v3](https://raw.githubusercontent.com/arafkarsh/ms-test-quickstart/master/diagrams/ms-test-qs-order.jpg)
![MS-Test-Quick-Start-2 based on Open API v3](https://raw.githubusercontent.com/arafkarsh/ms-test-quickstart/master/diagrams/ms-test-qs-core.jpg)
Other Services
1. Payment External Service
2. Shipping Service
3. Inventory Service
4. Warehouse ServiceCurrently Order Service has a Mock Implementation of these services.
Now let us focus on Microservices Testing Strategies.
![Microservice Testing Strategies](https://raw.githubusercontent.com/arafkarsh/ms-test-quickstart/master/diagrams/Microservices-Testing-Strategies-1.jpg)
The following Test Categories helps you to automate the testing for Microservices based development
resulting in ZERO End-2-End Testing.All the tests will be fully automated as part of your CI/CD pipeline.
## Dependencies
- Spring Boot 3 (3.3.4)
- Maven SureFire Plugin 2 (3.0.0-M7)## Testing Frameworks
![Microservices Testing Frameworks](https://raw.githubusercontent.com/arafkarsh/ms-test-quickstart/master/diagrams/Microservices-Testing-Tools.jpg)
Copyright (c) 2021-25, Apache 2.0 License, Author: Araf Karsh Hamid