E-commerce App - Exploring QA strategies for microservices with Synchronous and Asynchronous communication
The initial objective of this project was to further study the differences in the development and implementation of quality strategies for microservices with synchronous and asynchronous communication. I decided to do all the development of the application and the tests from scratch to be able to better observe some details in practice.
- Shop
- Inventory
- Shipment
The docker-compose file contains the pre-requisites to run the application: MongoDB and Kafka
It's also neccessary to generate some depencies jars from the modules:
mvn clean install
Now, you can bring up the docker-compose:
docker-compose up -d
Then, you can run the application modules:
Run Inventory:
mvn -f inventory/ spring-boot:run
Run Shop:
mvn -f shop/ spring-boot:run
Run Shipment:
mvn -f shipment/ spring-boot:run
- Unit Tests: Junit5 and Mockito
- Integration tests: Spring Boot Test, WireMock and EmbeddedKafka (when testing asynchronous events)
- Quality Metrics:
- Mutation Tests/Mutation Coverage: PITest
- Code Coverage: Jacoco
- Technical Debt, Code Smells and other complementary metrics : Sonar Cloud
- Contract tests: Pact framework
- Continuous Integration: This project uses Github Action for Continuous Integration, where it executes all the tests and Sonar Cloud Analysis for every pull request, making easier the process of integration of every new code, also facilitating the process of Code Review.
- Development:
- Spring Boot
- Java
- Maven
- Kafka
- MongoDB
- Github Actions
- Docker
This project contains contract tests using Pact. In order to run it, first you need to bring up the pact broker. To run the pact-broker using Docker, execute:
docker-compose -f pactbroker_dockercompose/docker-compose.yml up -d
Then you can go to the producer module and execute the contract tests, to generate the contracts. The pact files will be written in the target/pact folder. It is configured to automatically publish the pacts into the pact broker.
mvn -f {folder}/ -Dtest=**/contract/*ConsumerPact test
If you want to manually publish the pacts into the pact broker, you can execute the following command:
mvn pact:publish
Then you can run the contract tests in the provider side, where it is already configured to get it from the pact broker
mvn -f {folder}/ -Dtest=**/contract/*ProviderPact test
-
Install and activate Intellij plugin to format on IDE:
-
There is a swagger documentation configured for each module. After running the desired module, you can navigate to: http://localhost:{port}/swagger-ui/
-
Check code Style:
mvn spotless::check (in the sub-module directory)
- Apply code Style:
mvn spotless::apply (in the sub-module directory)