Sample application to demonstrate the use of Producer Driven Contract and Consumer Driven Contract tests with SpringBoot 2.3.0 + Spring Cloud Contract 2.2 - Client/contract consumer sample application.
This application uses:
- Spring Boot 2.3.0
- Spring Cloud Hoxton.SR4
- Spring Cloud Contract 2.2
- Spring Web+Rest
- Lombok
- Java 8
- Gradle (Gradle wrapper)
- JUnit 5 e Mockito
- Open Feign
- StubRunner (will run in local mode, on port 8082)
- WireMock
You can see the server / REST API provider application here: https://github.com/bovino/spring_cloud_contract_server_api_sample
- Adding Docker and maybe Kubernetes support
- Adding continuos integration with Jenkins (or similars)
- Adding code validation with SonarQube (or similars)
- Adding more contract sample with others DSLs instead of only Groovy (Yaml, Java and Kotlin)
- Implement a Consumer-driven sample using an Angular application + Pact
- using a remote StubRunner instead of a local one
- publishing the contracts to a Git repository instead of using Maven local repo
- adding a video-tutorial showing all the steps from the beginning, starting with the generation of the codebase from Spring Initializer
- Do you have other ideas for improvements? Please tell me! Reach out to me on Linkedin: https://www.linkedin.com/in/bovino/
This application uses Gradle (Gradle wrapper) and a few useful commands are:
Before using this application you will need:
- Some IDE with Lombok support (i like IntelliJ)
- Any Rest API client (i like Postman)
- JDK 1.8,0_251 or newer
- Configure your JAVA_HOME environment variable
- You need the ports 8080 (server API), 8081 (client API) and 8082 (local StubRunner) to be free
For further reference, please consider the following sections:
- Official Gradle documentation
- Spring Boot Gradle Plugin Reference Guide
- Create an OCI image
- Spring Web
The following guides illustrate how to use and setup some features more concretely:
- Building a RESTful Web Service
- Serving Web Content with Spring MVC
- Building REST services with Spring
- Spring Cloud Contract Docs - Overview
- Gradle Setup for Spring Cloud Contract
- Spring Cloud Contract Verifier Setup
- Como os testes de contrato melhoram a qualidade dos sistemas distribuídos
- GitHub: Spring Cloud Contract Additional Code Samples
- Dont like testing? Behold the power of GoHorse Process!!
These additional references should also help you: