From cf2350ff3f357f0cf9ea8d7dd75cc9069913d4d3 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 12 Sep 2017 11:42:16 +0200 Subject: [PATCH] Updated readme --- README.adoc | 676 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 385 insertions(+), 291 deletions(-) diff --git a/README.adoc b/README.adoc index 0d0b806372..7d7e782472 100644 --- a/README.adoc +++ b/README.adoc @@ -8,104 +8,127 @@ image::https://circleci.com/gh/spring-cloud/spring-cloud-contract.svg?style=svg[ == Spring Cloud Contract -What you always need is confidence in pushing new features into a new application or service in a distributed system. -This project provides support for Consumer Driven Contracts and service schemas in Spring applications, covering a -range of options for writing tests, publishing them as assets, asserting that a contract is kept by producers -and consumers, for HTTP and message-based interactions. +You always need confidence when pushing new features into a new application or service in +a distributed system. To that end, this project provides support for Consumer-driven +Contracts and service schemas in Spring applications, covering a range of options for +writing tests, publishing them as assets, and asserting that a contract is kept by +producers and consumers -- for both HTTP and message-based interactions. === Spring Cloud Contract workshops -If you prefer to learn about the project by doing some tutorials you can check out the workshops under +If you prefer to learn about the project by doing some tutorials, you can check out the +workshops under http://cloud-samples.spring.io/spring-cloud-contract-samples/workshops.html[this link]. === Spring Cloud Contract Verifier == Spring Cloud Contract Verifier Introduction -TIP: The Accurest project was initially started by Marcin Grzejszczak and Jakub Kubrynski (http://codearte.io[codearte.io]) +TIP: The Accurest project was initially started by Marcin Grzejszczak and Jakub Kubrynski +(http://codearte.io[codearte.io]) -Just to make long story short - Spring Cloud Contract Verifier is a tool that enables Consumer Driven Contract (CDC) development of JVM-based applications. It is shipped -with __Contract Definition Language__ (DSL). Contract definitions are used to produce following resources: +Spring Cloud Contract Verifier enables Consumer Driven Contract (CDC) development of +JVM-based applications. It moves TDD to the level of software architecture. -* JSON stub definitions to be used by WireMock when doing integration testing on the client code (__client tests__). -Test code must still be written by hand, test data is produced by Spring Cloud Contract Verifier. -* Messaging routes if you're using one. We're integrating with Spring Integration, Spring Cloud Stream, Spring AMQP and Apache Camel. You can however set your own integrations if you want to -* Acceptance tests (in JUnit or Spock) used to verify if server-side implementation of the API is compliant with the contract (__server tests__). -Full test is generated by Spring Cloud Contract Verifier. +Spring Cloud Contract Verifier ships with _Contract Definition Language_ (CDL). Contract +definitions are used to produce the following resources: -Spring Cloud Contract Verifier moves TDD to the level of software architecture. +* JSON stub definitions to be used by WireMock when doing integration testing on the +client code (_client tests_). Test code must still be written by hand, and test data is +produced by Spring Cloud Contract Verifier. +* Messaging routes, if you're using a messaging service. We integrate with Spring +Integration, Spring Cloud Stream, Spring AMQP, and Apache Camel. You can also set your +own integrations. +* Acceptance tests (in JUnit or Spock) are used to verify if server-side implementation +of the API is compliant with the contract (__server tests__). A full test is generated by +Spring Cloud Contract Verifier. -=== Why? +=== Why a Contract Verifier? -Let us assume that we have a system comprising of multiple microservices: +Assume that we have a system consisting of multiple microservices: image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-contract/{branch}/docs/src/main/asciidoc/images/Deps.png[Microservices Architecture] ==== Testing issues -If we wanted to test the application in top left corner if it can communicate with other services then we could do one of two things: +If we wanted to test the application in top left corner to determine whether it can +communicate with other services, we could do one of two things: -- deploy all microservices and perform end to end tests -- mock other microservices in unit / integration tests +- Deploy all microservices and perform end-to-end tests. +- Mock other microservices in unit/integration tests. -Both have their advantages but also a lot of disadvantages. Let's focus on the latter. +Both have their advantages but also a lot of disadvantages. *Deploy all microservices and perform end to end tests* Advantages: -- simulates production -- tests real communication between services +- Simulates production. +- Tests real communication between services. Disadvantages: -- to test one microservice we would have to deploy 6 microservices, a couple of databases etc. -- the environment where the tests would be conducted would be locked for a single suite of tests (i.e. nobody else would be able to run the tests in the meantime). -- long to run -- very late feedback -- extremely hard to debug +- To test one microservice, we have to deploy 6 microservices, a couple of databases, +etc. +- The environment where the tests run is locked for a single suite of tests (nobody else +would be able to run the tests in the meantime). +- They take a long time to run. +- The feedback comes very late in the process. +- They are extremely hard to debug. -*Mock other microservices in unit / integration tests* +*Mock other microservices in unit/integration tests* Advantages: -- very fast feedback -- no infrastructure requirements +- They provide very fast feedback. +- They have no infrastructure requirements. Disadvantages: -- the implementor of the service creates stubs thus they might have nothing to do with the reality -- you can go to production with passing tests and failing production +- The implementor of the service creates stubs that might have nothing to do with +reality. +- You can go to production with passing tests and failing production. -To solve the aforementioned issues Spring Cloud Contract Verifier with Stub Runner were created. Their main idea is to give you very fast feedback, without the need -to set up the whole world of microservices. If you work on stubs then the only applications you need are those that your application is using directly. +To solve the aforementioned issues, Spring Cloud Contract Verifier with Stub Runner was +created. The main idea is to give you very fast feedback, without the need to set up the +whole world of microservices. If you work on stubs, then the only applications you need +are those that your application directly uses. image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-contract/{branch}/docs/src/main/asciidoc/images/Stubs2.png[Stubbed Services] -Spring Cloud Contract Verifier gives you the certainty that the stubs that you're using were created by the service that you're calling. Also if you can use them it means that they were -tested against the producer's side. In other words - you can trust those stubs. +Spring Cloud Contract Verifier gives you the certainty that the stubs that you use were +created by the service that you're calling. Also, if you can use them, it means that they +were tested against the producer's side. In short, you can trust those stubs. === Purposes The main purposes of Spring Cloud Contract Verifier with Stub Runner are: - - to ensure that WireMock / Messaging stubs (used when developing the client) are doing exactly what actual server-side implementation will do, - - to promote ATDD method and Microservices architectural style, - - to provide a way to publish changes in contracts that are immediately visible on both sides, - - to generate boilerplate test code used on the server side. +- To ensure that WireMock/Messaging stubs (used when developing the client) do exactly +what the actual server-side implementation does. +- To promote ATDD method and Microservices architectural style. +- To provide a way to publish changes in contracts that are immediately visible on both +sides. +- To generate boilerplate test code to be used on the server side. -IMPORTANT: Spring Cloud Contract Verifier's purpose is NOT to start writing business features in the contracts. -Let's assume that we have a business use case of fraud check. If a user can be a fraud for 100 different reasons, -we would assume that you would create 2 contracts. One for the positive and one for the negative fraud case. -Contract tests are used to test contracts between applications and not to simulate full behaviour. +IMPORTANT: Spring Cloud Contract Verifier's purpose is NOT to start writing business +features in the contracts. Assume that we have a business use case of fraud check. If a +user can be a fraud for 100 different reasons, we would assume that you would create 2 +contracts, one for the positive case and one for the negative case. Contract tests are +used to test contracts between applications and not to simulate full behavior. -=== How +=== How It Works -==== Define the contract +This section explores how Spring Cloud Contract Verifier with Stub Runner works. -As consumers we need to define what exactly we want to achieve. We need to formulate our expectations. That's why we write the following contract. +==== Defining the contract -Let’s assume that we’d like to send the request containing the id of the client and the amount he wants to borrow from us. We’d like to send it to the /fraudcheck url via the PUT method. +As consumers of services, we need to define what exactly we want to achieve. We need to +formulate our expectations. That is why we write contracts. + +Assume that you want to send a request containing the ID of a client company and the +amount it wants to borrow from us. You also want to send it to the /fraudcheck url via +the PUT method. [source,groovy,indent=0] ---- @@ -170,11 +193,11 @@ From the Producer perspective, in the autogenerated producer-side test: ==== Client Side -Spring Cloud Contract will generate stubs, which you can use during client side testing. -You will have a WireMock instance / Messaging route up and running that simulates the service Y. +Spring Cloud Contract generates stubs, which you can use during client-side testing. +You get a running WireMock instance/Messaging route that simulates the service. You would like to feed that instance with a proper stub definition. -At some point in time you need to send a request to the Fraud Detection service. +At some point in time, you need to send a request to the Fraud Detection service. [source,groovy,indent=0] ---- @@ -195,18 +218,20 @@ Annotate your test class with `@AutoConfigureStubRunner`. In the annotation prov public class LoanApplicationServiceTests { ---- -After that, during the tests Spring Cloud Contract will automatically find the stubs (simulating the real service) in Maven repository and expose them on configured (or random) port. +After that, during the tests, Spring Cloud Contract automatically finds the stubs +(simulating the real service) in the Maven repository and exposes them on a configured +(or random) port. ==== Server Side -Being a service Y since you are developing your stub, you need to be sure that it's actually resembling your -concrete implementation. You can't have a situation where your stub acts in one way and your application on -production behaves in a different way. +Since you are developing your stub, you need to be sure that it actually resembles your +concrete implementation. You cannot have a situation where your stub acts in one way and +your application behaves in a different way, especially in production. -That's why from the provided stub acceptance tests will be generated that will ensure -that your application behaves in the same way as you define in your stub. +To ensure that your application behaves the way you define in your stub, tests are +generated from the stub you provide. -The autogenerated test would look like this: +The autogenerated test looks like this: [source,java,indent=0] ---- @@ -231,26 +256,33 @@ public void validate_shouldMarkClientAsFraud() throws Exception { } ---- -=== Step by step guide to CDC +=== Step-by-step Guide to Consumer Driven Contracts (CDC) -Let's take an example of Fraud Detection and Loan Issuance process. The business scenario is such that we want to issue loans to people but don't want them to steal the money from us. The current implementation of our system grants loans to everybody. +Consider an example of Fraud Detection and the Loan Issuance process. The business +scenario is such that we want to issue loans to people but do not want them to steal from +us. The current implementation of our system grants loans to everybody. -Let's assume that the `Loan Issuance` is a client to the -`Fraud Detection` server. In the current sprint we are required to develop a new feature - if a client wants to borrow too much money then we mark him as fraud. +Assume that `Loan Issuance` is a client to the `Fraud Detection` server. In the current +sprint, we must develop a new feature: if a client wants to borrow too much money, then +we mark the client as a fraud. -Technical remark - Fraud Detection will have artifact id `http-server`, Loan Issuance `http-client` and both have group id `com.example`. +Technical remark - Fraud Detection has an `artifact-id` of `http-server`, while Loan +Issuance has an artifact-id of `http-client`, and both have a `group-id` of `com.example`. -Social remark - both client and server development teams need to communicate directly and discuss changes while -going through the process. CDC is all about communication. +Social remark - both client and server development teams need to communicate directly and +discuss changes while going through the process. CDC is all about communication. -The https://github.com/spring-cloud/spring-cloud-contract/tree/{branch}/samples/standalone/dsl/http-server[server side code is available here] and https://github.com/spring-cloud/spring-cloud-contract/tree/{branch}/samples/standalone/dsl/http-client[the client side code here]. +The https://github.com/spring-cloud/spring-cloud-contract/tree/{branch}/samples/standalone/dsl/http-server[server +side code is available here] and https://github.com/spring-cloud/spring-cloud-contract/tree/{branch}/samples/standalone/dsl/http-client[the +client code here]. -TIP: In this case the ownership of the contracts lays on the producer side. It means that physically -all the contract are present in the producer's repository +TIP: In this case, the producer owns the contracts. Physically, all the contract are +in the producer's repository. ==== Technical note -If using the *SNAPSHOT* / *Milestone* / *Release Candidate* versions please add the following section to your +If using the *SNAPSHOT* / *Milestone* / *Release Candidate* versions please add the +following section to your build: [source,xml,indent=0,subs="verbatim,attributes",role="primary"] .Maven @@ -323,9 +355,22 @@ repositories { ==== Consumer side (Loan Issuance) -As a developer of the Loan Issuance service (a consumer of the Fraud Detection server): +As a developer of the Loan Issuance service (a consumer of the Fraud Detection server), you might do the following steps: -*start doing TDD by writing a test to your feature* +. Start doing TDD by writing a test for your feature. +. Write the missing implementation. +. Clone the Fraud Detection service repository locally. +. Define the contract locally in the repo of Fraud Detection service. +. Add the Spring Cloud Contract Verifier plugin. +. Run the integration tests. +. File a pull request. +. Create an initial implementation. +. Take over the pull request. +. Write the missing implementation. +. Deploy your app. +. Work online. + +*Start doing TDD by writing a test for your feature.* [source,groovy,indent=0] ---- @@ -343,11 +388,14 @@ public void shouldBeRejectedDueToAbnormalLoanAmount() { } ---- -We've just written a test of our new feature. If a loan application for a big amount is received we should reject that loan application with some description. +Assume that you have written a test of your new feature. If a loan application for a big +amount is received, the system should reject that loan application with some description. -*write the missing implementation* +*Write the missing implementation.* -At some point in time you need to send a request to the Fraud Detection service. Let's assume that we'd like to send the request containing the id of the client and the amount he wants to borrow from us. We'd like to send it to the `/fraudcheck` url via the `PUT` method. +At some point in time, you need to send a request to the Fraud Detection service. Assume +that you need to send the request containing the ID of the client and the amount the +client wants to borrow. You want to send it to the `/fraudcheck` url via the `PUT` method. [source,groovy,indent=0] ---- @@ -357,25 +405,29 @@ ResponseEntity response = FraudServiceResponse.class); ---- -For simplicity we've hardcoded the port of the Fraud Detection service at `8080` and our application is running on `8090`. +For simplicity, the port of the Fraud Detection service is set to `8080`, and the +application runs on `8090`. -If we'd start the written test it would obviously break since we have no service running on port `8080`. +If you start the test at this point, it breaks, because no service currently runs on port +`8080`. -*clone the Fraud Detection service repository locally* +*Clone the Fraud Detection service repository locally.* -We'll start playing around with the server side contract. That's why we need to first clone it. +You can start by playing around with the server side contract. To do so, you must first +clone it. [source,bash,indent=0] ---- git clone https://your-git-server.com/server-side.git local-http-server-repo ---- -*define the contract locally in the repo of Fraud Detection service* +*Define the contract locally in the repo of Fraud Detection service.* -As consumers we need to define what exactly we want to achieve. We need to formulate our expectations. That's why we write the following contract. +As a consumer, you need to define what exactly you want to achieve. You need to formulate +your expectations. To do so, write the following contract: -IMPORTANT: We're placing the contract under `src/test/resources/contracts/fraud` folder. The `fraud` folder -is important cause we'll reference that folder in the producer's test base class name. +IMPORTANT: Place the contract under `src/test/resources/contracts/fraud` folder. The `fraud` folder +is important because the producer's test base class name references that folder. [source,groovy,indent=0] ---- @@ -438,34 +490,39 @@ From the Producer perspective, in the autogenerated producer-side test: */ ---- -The Contract is written using a statically typed Groovy DSL. You might be wondering what are those -`value(client(...), server(...))` parts. By using this notation Spring Cloud Contract allows you to -define parts of a JSON / URL / etc. which are dynamic. In case of an identifier or a timestamp you -don't want to hardcode a value. You want to allow some different ranges of values. That's why for -the consumer side you can set regular expressions matching those values. You can provide the body -either by means of a map notation or String with interpolations. +The Contract is written using a statically typed Groovy DSL. You might wonder what about +those `value(client(...), server(...))` parts. By using this notation, Spring Cloud +Contract lets you define parts of a JSON block, a URL, etc., which are dynamic. In case +of an identifier or a timestamp, you need not hardcode a value. You want to allow some +different ranges of values. To enable ranges of values, you can set regular expressions +matching those values for the consumer side. You can provide the body by means of either +a map notation or String with interpolations. https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html#_contract_dsl[Consult the docs for more information.] We highly recommend using the map notation! -TIP: It's really important that you understand the map notation to set up contracts. Please read the -http://groovy-lang.org/json.html[Groovy docs regarding JSON] +TIP: You must understand the map notation in order to set up contracts. Please read the +http://groovy-lang.org/json.html[Groovy docs regarding JSON]. -The aforementioned contract is an agreement between two sides that: +The previously shown contract is an agreement between two sides that: -- if an HTTP request is sent with -** a method `PUT` on an endpoint `/fraudcheck` -** JSON body with `client.id` matching the regular expression `[0-9]{10}` and `loanAmount` equal to `99999` -** and with a header `Content-Type` equal to `application/vnd.fraud.v1+json` -- then an HTTP response would be sent to the consumer that -** has status `200` -** contains JSON body with the `fraudCheckStatus` field containing a value `FRAUD` and the `rejectionReason` field having value `Amount too high` -** and a `Content-Type` header with a value of `application/vnd.fraud.v1+json` +- if an HTTP request is sent with all of +** a `PUT` method on the `/fraudcheck` endpoint, +** a JSON body with a `client.id` that matches the regular expression `[0-9]{10}` and +`loanAmount` equal to `99999`, +** and a `Content-Type` header with a value of `application/vnd.fraud.v1+json`, +- then an HTTP response is sent to the consumer that +** has status `200`, +** contains a JSON body with the `fraudCheckStatus` field containing a value `FRAUD` and +the `rejectionReason` field having value `Amount too high`, +** and a `Content-Type` header with a value of `application/vnd.fraud.v1+json`. -Once we're ready to check the API in practice in the integration tests we need to just install the stubs locally +Once you are ready to check the API in practice in the integration tests, you need to +install the stubs locally. -*add the Spring Cloud Contract Verifier plugin* +*Add the Spring Cloud Contract Verifier plugin.* -We can add either Maven or Gradle plugin - in this example we'll show how to add Maven. First we need to add the `Spring Cloud Contract` BOM. +We can add either a Maven or a Gradle plugin. In this example, you see how to add Maven. +First, add the `Spring Cloud Contract` BOM. [source,xml,indent=0] ---- @@ -482,7 +539,7 @@ We can add either Maven or Gradle plugin - in this example we'll show how to add ---- -Next, the `Spring Cloud Contract Verifier` Maven plugin +Next, add the `Spring Cloud Contract Verifier` Maven plugin [source,xml,indent=0] ---- @@ -497,12 +554,14 @@ Next, the `Spring Cloud Contract Verifier` Maven plugin ---- -Since the plugin was added we get the `Spring Cloud Contract Verifier` features which from the provided contracts: +Since the plugin was added, you get the `Spring Cloud Contract Verifier` features which, +from the provided contracts: - generate and run tests - produce and install stubs -We don't want to generate tests since we, as consumers, want only to play with the stubs. That's why we need to skip the tests generation and execution. When we execute: +You do not want to generate tests since you, as the consumer, want only to play with the +stubs. You need to skip the test generation and execution. When you execute: [source,bash,indent=0] ---- @@ -510,7 +569,7 @@ cd local-http-server-repo ./mvnw clean install -DskipTests ---- -In the logs we'll see something like this: +In the logs, you see something like this: [source,bash,indent=0] ---- @@ -528,20 +587,23 @@ In the logs we'll see something like this: [INFO] Installing /some/path/http-server/target/http-server-0.0.1-SNAPSHOT-stubs.jar to /path/to/your/.m2/repository/com/example/http-server/0.0.1-SNAPSHOT/http-server-0.0.1-SNAPSHOT-stubs.jar ---- -This line is extremely important +The following line is extremely important: [source,bash,indent=0] ---- [INFO] Installing /some/path/http-server/target/http-server-0.0.1-SNAPSHOT-stubs.jar to /path/to/your/.m2/repository/com/example/http-server/0.0.1-SNAPSHOT/http-server-0.0.1-SNAPSHOT-stubs.jar ---- -It's confirming that the stubs of the `http-server` have been installed in the local repository. +It confirms that the stubs of the `http-server` have been installed in the local +repository. -*run the integration tests* +*Run the integration tests.* -In order to profit from the Spring Cloud Contract Stub Runner functionality of automatic stub downloading you have to do the following in our consumer side project (`Loan Application service`). +In order to profit from the Spring Cloud Contract Stub Runner functionality of automatic +stub downloading, you must do the following in your consumer side project (`Loan +Application service`): -Add the `Spring Cloud Contract` BOM +Add the `Spring Cloud Contract` BOM: [source,xml,indent=0] ---- @@ -558,7 +620,7 @@ Add the `Spring Cloud Contract` BOM ---- -Add the dependency to `Spring Cloud Contract Stub Runner` +Add the dependency to `Spring Cloud Contract Stub Runner`: [source,xml,indent=0] ---- @@ -569,7 +631,10 @@ Add the dependency to `Spring Cloud Contract Stub Runner` ---- -Annotate your test class with `@AutoConfigureStubRunner`. In the annotation provide the group id and artifact id for the Stub Runner to download stubs of your collaborators. Also provide the offline work switch since you're playing with the collaborators offline (optional step). +Annotate your test class with `@AutoConfigureStubRunner`. In the annotation, provide the +`group-id` and `artifact-id` for the Stub Runner to download the stubs of your +collaborators. (Optional step) Because you're playing with the collaborators offline, you +can also provide the offline work switch. [source,groovy,indent=0] ---- @@ -580,7 +645,7 @@ Annotate your test class with `@AutoConfigureStubRunner`. In the annotation prov public class LoanApplicationServiceTests { ---- -Now if you run your tests you'll see sth like this: +Now, when you run your tests, you see something like this: [source,bash,indent=0] ---- @@ -593,21 +658,26 @@ Now if you run your tests you'll see sth like this: 2016-07-19 14:22:27.737 INFO 41050 --- [ main] o.s.c.c.stubrunner.StubRunnerExecutor : All stubs are now running RunningStubs [namesAndPorts={com.example:http-server:0.0.1-SNAPSHOT:stubs=8080}] ---- -Which means that Stub Runner has found your stubs and started a server for app with group id `com.example`, artifact id `http-server` with version `0.0.1-SNAPSHOT` of the stubs and with `stubs` classifier on port `8080`. +This output means that Stub Runner has found your stubs and started a server for your app +with group id `com.example`, artifact id `http-server` with version `0.0.1-SNAPSHOT` of +the stubs and with `stubs` classifier on port `8080`. -*file a PR* +*File a pull request.* -What we did until now is an iterative process. We can play around with the contract, install it locally and work on the consumer side until we're happy with the contract. +What you have done until now is an iterative process. You can play around with the +contract, install it locally, and work on the consumer side until the contract works as +you wish. -Once we're satisfied with the results and the test passes publish a PR to the server side. Currently the consumer side work is done. +Once you are satisfied with the results and the test passes, publish a pull request to +the server side. Currently, the consumer side work is done. ==== Producer side (Fraud Detection server) As a developer of the Fraud Detection server (a server to the Loan Issuance service): -*initial implementation* +*Create an initial implementation.* -As a reminder here you can see the initial implementation +As a reminder, you can see the initial implementation here: [source,java,indent=0] ---- @@ -617,7 +687,7 @@ return new FraudCheckResult(FraudCheckStatus.OK, NO_REASON); } ---- -*take over the PR* +*Take over the pull request.* [source,bash,indent=0] ---- @@ -625,7 +695,7 @@ git checkout -b contract-change-pr master git pull https://your-git-server.com/server-side-fork.git contract-change-pr ---- -You have to add the dependencies needed by the autogenerated tests +You must add the dependencies needed by the autogenerated tests: [source,xml,indent=0] ---- @@ -636,7 +706,7 @@ You have to add the dependencies needed by the autogenerated tests ---- -In the configuration of the Maven plugin we passed the `packageWithBaseClasses` property +In the configuration of the Maven plugin, pass the `packageWithBaseClasses` property [source,xml,indent=0] ---- @@ -651,14 +721,16 @@ In the configuration of the Maven plugin we passed the `packageWithBaseClasses` ---- -IMPORTANT: We've decided to use the "convention based" naming by setting the `packageWithBaseClasses` property. -That means that 2 last packages will be combined into a name of the base test class. In our case the contracts -were placed under `src/test/resources/contracts/fraud`. Since we don't have 2 packages starting from the `contracts` -folder we're picking only one which is `fraud`. We're adding the `Base` suffix and we're capitalizing `fraud`. -That gives us the `FraudBase` test class name. +IMPORTANT: This example uses "convention based" naming by setting the +`packageWithBaseClasses` property. Doing so means that the two last packages combine to +make the name of the base test class. In our case, the contracts were placed under +`src/test/resources/contracts/fraud`. Since you do not have two packages starting from +the `contracts` folder, pick only one, which should be `fraud`. Add the `Base` suffix and +capitalize `fraud`. That gives you the `FraudBase` test class name. -That's because all the generated tests will extend that class. Over there you can set up your Spring Context or -whatever is necessary. In our case we're using http://rest-assured.io/[Rest Assured MVC] to start the server side `FraudDetectionController`. +All the generated tests extend that class. Over there, you can set up your Spring Context +or whatever is necessary. In this case, use http://rest-assured.io/[Rest Assured MVC] to +start the server side `FraudDetectionController`. [source,java,indent=0] ---- @@ -693,7 +765,7 @@ public class FraudBase { } ---- -Now, if you run the `./mvnw clean install` you would get sth like this: +Now, if you run the `./mvnw clean install`, you get something like this: [source,bash,indent=0] ---- @@ -703,7 +775,9 @@ Tests in error: ContractVerifierTest.validate_shouldMarkClientAsFraud:32 » IllegalState Parsed... ---- -That's because you have a new contract from which a test was generated and it failed since you haven't implemented the feature. The autogenerated test would look like this: +This error occurs because you have a new contract from which a test was generated and it +failed since you have not implemented the feature. The auto-generated test would look +like this: [source,java,indent=0] ---- @@ -728,13 +802,19 @@ public void validate_shouldMarkClientAsFraud() throws Exception { } ---- -As you can see all the `producer()` parts of the Contract that were present in the `value(consumer(...), producer(...))` blocks got injected into the test. +As you can see, all the `producer()` parts of the Contract that were present in the +`value(consumer(...), producer(...))` blocks got injected into the test. -What's important here to note is that on the producer side we also are doing TDD. We have expectations in form of a test. This test is shooting a request to our own application to an URL, headers and body defined in the contract. It also is expecting very precisely defined values in the response. In other words you have is your `red` part of `red`, `green` and `refactor`. Time to convert the `red` into the `green`. +Note that, on the producer side, you are also doing TDD. The expectations are expressed +in the form of a test. This test sends a request to our own application with the URL, +headers, and body defined in the contract. It also is expecting precisely defined values +in the response. In other words, you have the `red` part of `red`, `green`, and +`refactor`. It is time to convert the `red` into the `green`. -*write the missing implementation* +*Write the missing implementation.* -Now since we now what is the expected input and expected output let's write the missing implementation. +Because you know the expected input and expected output, you can write the missing +implementation: [source,java,indent=0] ---- @@ -747,11 +827,13 @@ return new FraudCheckResult(FraudCheckStatus.OK, NO_REASON); } ---- -If we execute `./mvnw clean install` again the tests will pass. Since the `Spring Cloud Contract Verifier` plugin adds the tests to the `generated-test-sources` you can actually run those tests from your IDE. +When you execute `./mvnw clean install` again, the tests pass. Since the `Spring Cloud +Contract Verifier` plugin adds the tests to the `generated-test-sources`, you can +actually run those tests from your IDE. -*deploy your app* +*Deploy your app.* -Once you've finished your work it's time to deploy your change. First merge the branch +Once you finish your work, you can deploy your change. First, merge the branch: [source,bash,indent=0] ---- @@ -760,13 +842,14 @@ git merge --no-ff contract-change-pr git push origin master ---- -Then we assume that your CI would run sth like `./mvnw clean deploy` which would publish both the application and the stub artifcats. +Your CI might run something like `./mvnw clean deploy`, which would publish both the +application and the stub artifacts. -==== Consumer side (Loan Issuance) final step +==== Consumer Side (Loan Issuance) Final Step As a developer of the Loan Issuance service (a consumer of the Fraud Detection server): -*merge branch to master* +*Merge branch to master.* [source,bash,indent=0] ---- @@ -774,11 +857,13 @@ git checkout master git merge --no-ff contract-change-pr ---- -*work online* +*Work online.* -Now you can disable the offline work for Spring Cloud Contract Stub Runner and provide where the repository with your stubs is placed. At this moment the stubs of the server side will be automatically downloaded from Nexus / Artifactory. -You can switch off the value of the `workOffline` parameter in your annotation. Below you can see an -example of achieving the same by changing the properties. +Now you can disable the offline work for Spring Cloud Contract Stub Runner and indicate +where the repository with your stubs is located. At this moment the stubs of the server +side are automatically downloaded from Nexus/Artifactory. You can switch off the value of +the `workOffline` parameter in your annotation. The following code shows an example of +achieving the same thing by changing the properties. [source,yaml,indent=0] ---- @@ -787,19 +872,20 @@ stubrunner: repositoryRoot: http://repo.spring.io/libs-snapshot ---- -And that's it! +That's it! === Dependencies -The best way to add the dependencies is to just use the proper `starter` dependency. +The best way to add dependencies is to use the proper `starter` dependency. -For `stub-runner` use `spring-cloud-starter-stub-runner` and when you're using a plugin just add +For `stub-runner`, use `spring-cloud-starter-stub-runner`. When you use a plugin, add `spring-cloud-starter-contract-verifier`. -=== Additional links +=== Additional Links -Below you can find some resources related to Spring Cloud Contract Verifier and Stub Runner. Note that some can be outdated since the Spring Cloud Contract Verifier project -is under constant development. +Here are some resources related to Spring Cloud Contract Verifier and Stub Runner. Note +that some may be outdated, because the Spring Cloud Contract Verifier project is under +constant development. ==== Spring Cloud Contract video @@ -816,21 +902,30 @@ video::sAAklvxmPmk[youtube,start=538,width=640,height=480] === Samples -Here you can find some https://github.com/spring-cloud-samples/spring-cloud-contract-samples[samples]. +You can find some samples at +https://github.com/spring-cloud-samples/spring-cloud-contract-samples[samples]. == Links -Here you can find interesting links related to Spring Cloud Contract Verifier: +The following links may be helpful when working with Spring Cloud Contract Verifier: -- https://github.com/spring-cloud/spring-cloud-contract/[Spring Cloud Contract Github Repository] -- https://github.com/spring-cloud-samples/spring-cloud-contract-samples/[Spring Cloud Contract Samples] -- https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html[Spring Cloud Contract Documentation] -- https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html/deprecated[Accurest Legacy Documentation] -- https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html/#spring-cloud-contract-stub-runner[Spring Cloud Contract Stub Runner Documentation] -- https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html/#stub-runner-for-messaging[Spring Cloud Contract Stub Runner Messaging Documentation] -- https://gitter.im/spring-cloud/spring-cloud-contract[Spring Cloud Contract Gitter] -- https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract-maven-plugin/[Spring Cloud Contract Maven Plugin] -- https://www.youtube.com/watch?v=sAAklvxmPmk[Spring Cloud Contract WJUG Presentation by Marcin Grzejszczak] +* https://github.com/spring-cloud/spring-cloud-contract/[Spring Cloud Contract Github +Repository] +* https://github.com/spring-cloud-samples/spring-cloud-contract-samples/[Spring Cloud +Contract Samples] +* https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html[Spring Cloud +Contract Documentation] +* https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html/deprecated[Accurest +Legacy Documentation] +* https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html/#spring-cloud-contract-stub-runner[Spring +Cloud Contract Stub Runner Documentation] +* https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html/#stub-runner-for-messaging[Spring +Cloud Contract Stub Runner Messaging Documentation] +* https://gitter.im/spring-cloud/spring-cloud-contract[Spring Cloud Contract Gitter] +* https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract-maven-plugin/[Spring +Cloud Contract Maven Plugin] +* https://www.youtube.com/watch?v=sAAklvxmPmk[Spring Cloud Contract WJUG Presentation by +Marcin Grzejszczak] === Spring Cloud Contract WireMock @@ -840,18 +935,17 @@ Here you can find interesting links related to Spring Cloud Contract Verifier: == Spring Cloud Contract WireMock -Modules giving you the possibility to use -http://wiremock.org[WireMock] in a Spring Boot application. Check out the +The Spring Cloud Contract WireMock modules let you use http://wiremock.org[WireMock] in a +Spring Boot application. Check out the https://github.com/spring-cloud/spring-cloud-contract/tree/{branch}/samples[samples] for more details. -If you have a Spring Boot application that uses Tomcat as an embedded -server, for example (the default with `spring-boot-starter-web`), then -you can simply add `spring-cloud-contract-wiremock` to your classpath -and add `@AutoConfigureWireMock` in order to be able to use Wiremock -in your tests. Wiremock runs as a stub server and you can register -stub behaviour using a Java API or via static JSON declarations as -part of your test. Here's a simple example: +If you have a Spring Boot application that uses Tomcat as an embedded server (which is +the default with `spring-boot-starter-web`), you can add +`spring-cloud-contract-wiremock` to your classpath and add `@AutoConfigureWireMock` in +order to be able to use Wiremock in your tests. Wiremock runs as a stub server and you +can register stub behavior using a Java API or via static JSON declarations as part of +your test. The following code shows an example: [source,java,indent=0] ---- @@ -875,16 +969,20 @@ public class WiremockForDocsTests { } ---- -To start the stub server on a different port use `@AutoConfigureWireMock(port=9999)` (for example), and for a random port use the value 0. The stub server port will be bindable in the test application context as "wiremock.server.port". Using `@AutoConfigureWireMock` adds a bean of type `WiremockConfiguration` to your test application context, where it will be cached in between methods and classes having the same context, just like for normal Spring integration tests. +To start the stub server on a different port use (for example), +`@AutoConfigureWireMock(port=9999)`. For a random port, use a value of `0`. The stub +server port can be bound in the test application context with the "wiremock.server.port" +property. Using `@AutoConfigureWireMock` adds a bean of type `WiremockConfiguration` to +your test application context, where it will be cached in between methods and classes +having the same context, the same as for Spring integration tests. === Registering Stubs Automatically -If you use `@AutoConfigureWireMock` then it will register WireMock -JSON stubs from the file system or classpath, by default from -`file:src/test/resources/mappings`. You can customize the locations -using the `stubs` attribute in the annotation, which can be a resource -pattern (ant-style) or a directory, in which case `**/*.json` is -appended. Example: +If you use `@AutoConfigureWireMock`, it registers WireMock JSON stubs from the file +system or classpath (by default, from `file:src/test/resources/mappings`). You can +customize the locations using the `stubs` attribute in the annotation, which can be an +Ant-style resource pattern or a directory. In the case of a directory, `**/*.json` is +appended. The following code shows an example: ---- @RunWith(SpringRunner.class) @@ -903,35 +1001,32 @@ public class WiremockImportApplicationTests { } ---- -NOTE: Actually WireMock always loads mappings from -`src/test/resources/mappings` *as well as* the custom locations in the -stubs attribute. To change this behaviour you have to also specify a -files root as described next. +NOTE: Actually, WireMock always loads mappings from `src/test/resources/mappings` *as +well as* the custom locations in the stubs attribute. To change this behavior, you can +also specify a files root as described in the next section of this document. === Using Files to Specify the Stub Bodies -WireMock can read response bodies from files on the classpath or file -system. In that case you will see in the JSON DSL that the response -has a "bodyFileName" instead of a (literal) "body". The files are -resolved relative to a root directory `src/test/resources/\__files` by -default. To customize this location you can set the `files` attribute -in the `@AutoConfigureWireMock` annotation to the location of the -parent directory (i.e. the place `__files` is a -subdirectory). You can use Spring resource notation to refer to -`file:...` or `classpath:...` locations (but generic URLs are not -supported). A list of values can be given and WireMock will resolve -the first file that exists when it needs to find a response body. +WireMock can read response bodies from files on the classpath or the file system. In that +case, you can see in the JSON DSL that the response has a `bodyFileName` instead of a +(literal) `body`. The files are resolved relative to a root directory (by default, +`src/test/resources/\__files`). To customize this location you can set the `files` +attribute in the `@AutoConfigureWireMock` annotation to the location of the parent +directory (in other words, `__files` is a subdirectory). You can use Spring resource +notation to refer to `file:...` or `classpath:...` locations. Generic URLs are not +supported. A list of values can be given, in which case WireMock resolves the first file +that exists when it needs to find a response body. -NOTE: when you configure the `files` root, then it affects the -automatic loading of stubs as well (they come from the root location -in a subdirectory called "mappings"). The value of `files` has no +NOTE: When you configure the `files` root, it also affects the +automatic loading of stubs, because they come from the root location +in a subdirectory called "mappings". The value of `files` has no effect on the stubs loaded explicitly from the `stubs` attribute. === Alternative: Using JUnit Rules -For a more conventional WireMock experience, using JUnit `@Rules` to -start and stop the server, just use the `WireMockSpring` convenience -class to obtain an `Options` instance: +For a more conventional WireMock experience, you can use JUnit `@Rules` to start and stop +the server. To do so, use the `WireMockSpring` convenience class to obtain an `Options` +instance, as shown in the followin example: [source,java,indent=0] ---- @@ -961,18 +1056,20 @@ public class WiremockForDocsClassRuleTests { } ---- -The use `@ClassRule` means that the server will shut down after all the methods in this class. +The `@ClassRule` means that the server shuts down after all the methods in this class +have been run. === Relaxed SSL Validation for Rest Template -WireMock allows you to stub a "secure" server with an "https" URL protocol. If your application wants to -contact that stub server in an integration test, then it will find that the SSL certificates are not -valid (it's the usual problem with self-installed certificates). The best option is often to just -re-configure the client to use "http", but if that's not open to you then you can ask Spring to configure -an HTTP client that ignores SSL validation errors (just for tests). +WireMock lets you stub a "secure" server with an "https" URL protocol. If your +application wants to contact that stub server in an integration test, it will find that +the SSL certificates are not valid (the usual problem with self-installed certificates). +The best option is often to re-configure the client to use "http". If that's not an +option, you can ask Spring to configure an HTTP client that ignores SSL validation errors +(do so only for tests, of course). -To make this work with minimum fuss you need to be using the Spring Boot `RestTemplateBuilder` in your app, -e.g. +To make this work with minimum fuss, you need to be using the Spring Boot +`RestTemplateBuilder` in your app, as shown in the following example: [source,java,indent=0] ---- @@ -982,10 +1079,11 @@ e.g. } ---- -This is because the builder is passed through callbacks to initalize it, so the SSL validation can be set up -in the client at that point. This will happen automatically in your test if you are using the -`@AutoConfigureWireMock` annotation (or the stub runner). If you are using the JUnit `@Rule` approach you need -to add the `@AutoConfigureHttpClient` annotation as well: +You need `RestTemplateBuilder` because the builder is passed through callbacks to +initialize it, so the SSL validation can be set up in the client at that point. This +happens automatically in your test if you are using the `@AutoConfigureWireMock` +annotation or the stub runner. If you use the JUnit `@Rule` approach, you need to add the +`@AutoConfigureHttpClient` annotation as well, as shown in the following example: [source,java,indent=0] ---- @@ -1001,15 +1099,16 @@ public class WiremockHttpsServerApplicationTests { } ---- -If you are using `spring-boot-starter-test` then you will have the Apache HTTP client on the classpath and it will -be selected by the `RestTemplateBuilder` and configured to ignore SSL errors. If you are using the default `java.net` -client you don't need the annotation (but it won't do any harm). There is no support currently for other clients, but -it may be added in future releases. +If you are using `spring-boot-starter-test`, you have the Apache HTTP client on the +classpath and it is selected by the `RestTemplateBuilder` and configured to ignore SSL +errors. If you use the default `java.net` client, you do not need the annotation (but it +won't do any harm). There is no support currently for other clients, but it may be added +in future releases. === WireMock and Spring MVC Mocks -Spring Cloud Contract provides a convenience class that can load JSON WireMock stubs into a -Spring `MockRestServiceServer`. Here's an example: +Spring Cloud Contract provides a convenience class that can load JSON WireMock stubs into +a Spring `MockRestServiceServer`. The following code shows an example: [source,java,indent=0] ---- @@ -1036,33 +1135,29 @@ public class WiremockForDocsMockServerApplicationTests { } ---- -The `baseUrl` is prepended to all mock calls, and the `stubs()` -method takes a stub path resource pattern as an argument. So in this -example the stub defined at `/stubs/resource.json` is loaded into the -mock server, so if the `RestTemplate` is asked to visit -`http://example.org/` it will get the responses as declared -there. More than one stub pattern can be specified, and each one can -be a directory (for a recursive list of all ".json"), or a fixed -filename (like in the example above) or an ant-style pattern. The JSON -format is the normal WireMock format which you can read about in the -WireMock website. +The `baseUrl` value is prepended to all mock calls, and the `stubs()` method takes a stub +path resource pattern as an argument. In the preceding example, the stub defined at +`/stubs/resource.json` is loaded into the mock server. If the `RestTemplate` is asked to +visit `http://example.org/`, it gets the responses as being declared at that URL. More +than one stub pattern can be specified, and each one can be a directory (for a recursive +list of all ".json"), a fixed filename (as in the example above), or an Ant-style +pattern. The JSON format is the normal WireMock format, which you can read about in the +http://wiremock.org/docs/stubbing/[WireMock website]. -Currently we support Tomcat, Jetty and Undertow as Spring Boot -embedded servers, and Wiremock itself has "native" support for a -particular version of Jetty (currently 9.2). To use the native Jetty -you need to add the native wiremock dependencies and exclude the -Spring Boot container if there is one. +Currently, the Spring Cloud Contract Verifier supports Tomcat, Jetty, and Undertow as +Spring Boot embedded servers, and Wiremock itself has "native" support for a particular +version of Jetty (currently 9.2). To use the native Jetty, you need to add the native +Wiremock dependencies and exclude the Spring Boot container (if there is one). -=== Generating Stubs using RestDocs - -https://projects.spring.io/spring-restdocs[Spring RestDocs] can be -used to generate documentation (e.g. in asciidoctor format) for an -HTTP API with Spring MockMvc or Rest Assured. At the same time as you -generate documentation for your API, you can also generate WireMock -stubs, by using Spring Cloud Contract WireMock. Just write your normal -RestDocs test cases and use `@AutoConfigureRestDocs` to have stubs -automatically in the restdocs output directory. For example: +=== Generating Stubs using REST Docs +https://projects.spring.io/spring-restdocs[Spring REST Docs] can be used to generate +documentation (for example in Asciidoctor format) for an HTTP API with Spring MockMvc or +Rest Assured. At the same time that you generate documentation for your API, you can also +generate WireMock stubs by using Spring Cloud Contract WireMock. To do so, write your +normal REST Docs test cases and use `@AutoConfigureRestDocs` to have stubs be +automatically generated in the REST Docs output directory. The following code shows an +example: [source,java,indent=0] ---- @@ -1084,20 +1179,19 @@ public class ApplicationTests { } ---- -From this test will be generated a WireMock stub at -"target/snippets/stubs/resource.json". It matches all GET requests to -the "/resource" path. +This test generates a WireMock stub at "target/snippets/stubs/resource.json". It matches +all GET requests to the "/resource" path. -Without any additional configuration this will create a stub with a -request matcher for the HTTP method and all headers except "host" and -"content-length". To match the request more precisely, for example to -match the body of a POST or PUT, we need to explicitly create a -request matcher. This will do two things: 1) create a stub that only -matches the way you specify, 2) assert that the request in the test -case also matches the same conditions. +Without any additional configuration, this tests creates a stub with a request matcher +for the HTTP method and all headers except "host" and "content-length". To match the +request more precisely (for example, to match the body of a POST or PUT), we need to +explicitly create a request matcher. Doing so has two effects: -The main entry point for this is `WireMockRestDocs.verify()` which can -be used as a substitute for the `document()` convenience method. For +* Creating a stub that matches only in the way you specify. +* Asserting that the request in the test case also matches the same conditions. + +The main entry point for this feature is `WireMockRestDocs.verify()`, which can be used +as a substitute for the `document()` convenience method, as shown in the following example: [source,java,indent=0] @@ -1122,15 +1216,14 @@ public class ApplicationTests { } ---- -So this contract is saying: any valid POST with an "id" field will get -back an the same response as in this test. You can chain together -calls to `.jsonPath()` to add additional matchers. The -https://github.com/jayway/JsonPath[JayWay documentation] can help you -to get up to speed with JSON Path if it is unfamiliar to you. +This contract specifies that any valid POST with an "id" field receives the response +defined in this test. You can chain together calls to `.jsonPath()` to add additional +matchers. If JSON Path is unfamiliar, The https://github.com/jayway/JsonPath[JayWay +documentation] can help you get up to speed. -Instead of the `jsonPath` and `contentType` convenience methods, you -can also use the WireMock APIs to verify the request matches the -created stub. Example: +Instead of the `jsonPath` and `contentType` convenience methods, you can also use the +WireMock APIs to verify that the request matches the created stub, as shown in the +following example: [source,java,indent=0] ---- @@ -1147,10 +1240,9 @@ created stub. Example: } ---- -The WireMock API is rich - you can match headers, query parameters, -and request body by regex as well as by json path - so this can useful -to create stubs with a wider range of parameters. The above example -will generate a stub something like this: +The WireMock API is rich. You can match headers, query parameters, and request body by +regex as well as by JSON path. These features can be used to create stubs with a wider +range of parameters. The above example generates a stub resembling the following example: .post-resource.json [source,json] @@ -1174,32 +1266,33 @@ will generate a stub something like this: } ---- -NOTE: You can use either the `wiremock()` method or the `jsonPath()` -and `contentType()` methods to create request matchers, but not both. +NOTE: You can use either the `wiremock()` method or the `jsonPath()` and `contentType()` +methods to create request matchers, but you can't use both approaches. -On the consumer side, you can make the `resource.json` generated above -available on the classpath (by https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html#_publishing_stubs_as_jars[publishing stubs as JARs] for example). -After that, you can create a stub using WireMock in a -number of different ways, including as described above using -`@AutoConfigureWireMock(stubs="classpath:resource.json")`. +On the consumer side, you can make the `resource.json` generated earlier in this section +available on the classpath (by +https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html#_publishing_stubs_as_jars[publishing +stubs as JARs], for example). After that, you can create a stub using WireMock in a +number of different ways, including by using +`@AutoConfigureWireMock(stubs="classpath:resource.json")`, as described earlier in this +document. -=== Generating Contracts using RestDocs +=== Generating Contracts by Using REST Docs -Another thing that can be generated with Spring RestDocs is the Spring Cloud -Contract DSL file and documentation. If you combine that with Spring Cloud -WireMock then you're getting both the contracts and stubs. +You can also generate Spring Cloud Contract DSL files and documentation with Spring REST +Docs. If you do so in combination with Spring Cloud WireMock, you get both the contracts +and the stubs. Why would you want to use this feature? Some people in the community asked questions -about situation in which they would like to move to DSL based contract definition -but they already have a lot of Spring MVC tests. Using this feature allows you to generate -the contract files that you can later modify and move to proper folders so that the -plugin picks them up. +about a situation in which they would like to move to DSL-based contract definition, +but they already have a lot of Spring MVC tests. Using this feature lets you generate +the contract files that you can later modify and move to folders (defined in your +configuration) so that the plugin finds them. -TIP: You might wonder why this functionality is in the WireMock module. -Come to think of it, it does make sense since it makes little sense to generate -only contracts and not generate the stubs. That's why we suggest to do both. +TIP: You might wonder why this functionality is in the WireMock module. The functionality +is there because it makes sense to generate both the contracts and the stubs. -Let's imagine the following test: +Consider the following test: [source,java] ---- @@ -1219,10 +1312,10 @@ Let's imagine the following test: .andDo(document("index", SpringCloudContractRestDocs.dslContract())); ---- -This will lead in the creation of the stub as presented in the previous -section, contract will get generated and a documentation file too. +The preceding test creates the stub presented in the previous section, generating both +the contract and a documentation file. -The contract will be called `index.groovy` and look more like this. +The contract is called `index.groovy` and might look like the following example: [source,groovy] ---- @@ -1256,12 +1349,13 @@ Contract.make { } ---- -the generated document (example for Asciidoc) will contain a formatted contract -(the location of this file would be `index/dsl-contract.adoc`). +The generated document (formatted in Asciidoc in this case) contains a formatted +contract. The location of this file would be `index/dsl-contract.adoc`. == Documentation -You can read more about Spring Cloud Contract Verifier by reading the {documentation_url}[docs] +You can read more about Spring Cloud Contract Verifier by reading the +{documentation_url}[docs] == Contributing