Skip to content

refactorizando-web/spring-cloud-contract-sample

Repository files navigation

Spring Cloud Contract example

Introduction

This is a simple example about how to use Spring Cloud Contract with a consumer and a producer.

You can take a look into the article in :

How does it work?

The idea behind Spring Cloud Contract is to verify the contract and help us develop Consumer Driven Contracts (CDC). If the producer changes or breaches the contract, Spring Cloud Contract will be aware of it. Then the test will fail.

This example has two different projects, the first is the producer, and the second is the consumer or client.

To verify the contract you must perform in the producer project

mv clean install

With the following command, you will generate a * -stub.jar. This check will be used by the consumer to verify the contract. if something has changed, client service will fail.

How does it run?

Both are Spring Boot projects so if you want to run you can run the next command:

mvn spring-boot:run

To verify contracts first is generate a stub in producer target folder, to make this run the next command:

mvn clean install

after that you can run test in your consumer project, you will see in your test a call to the stub generated. So run the next command in your consumer project:

mvn clean install or mvn test

About

An example about use Consumer Drive Contract with Spring Cloud Contract

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published