Added failOnInProgress

with this change your plugin can fail the build if you have any in progress contracts

fixes gh-1156
This commit is contained in:
Marcin Grzejszczak
2019-08-08 14:15:24 +02:00
parent 875ac13427
commit 909930a6f4
11 changed files with 207 additions and 5 deletions

View File

@@ -166,6 +166,8 @@ include::{verifier_core_path}/src/test/resources/yml/contract.yml[tags=in_progre
----
====
You can set the value of the `failOnInProgress` Spring Cloud Contract plugin property to ensure that your build will break when at least one contract in progress remains in your sources.
[[contract-dsl-passing-values-from-files]]
==== Passing Values from Files

View File

@@ -309,6 +309,7 @@ JAR is available offline, remotely, and so on).
* `deleteStubsAfterTest`: If set to `false`, do not remove any downloaded
contracts from temporary directories.
* `failOnNoContracts`: When enabled, will throw an exception when no contracts were found. Defaults to `true`.
* `failOnInProgress`: If set to true then if any contracts that are in progress are found, will break the build. On the producer side you need to be explicit about the fact that you have contracts in progress and take into consideration that you might be causing false positive test execution results on the consumer side.. Defaults to `true`.
There is also the `contractRepository { ... }` closure that contains the following properties

View File

@@ -1448,4 +1448,11 @@ If you want to generate stubs at runtime for contracts, it's enough to switch th
If you want Stub Runner not to fail if no stubs were found, it's enough to switch the `generateStubs` property in the `@AutoConfigureStubRunner` annotation, or call the `withFailOnNoStubs(false)` method on the JUnit Rule or Extension. You can read more about this in <<project-features.adoc#features-stub-runner-fail-on-no-stubs, this section>> of the documentation.
If you want the plugins not to fail the build when no contracts were found, you can set the `failOnNoStubs` flag in Maven or call the `contractRepository { failOnNoStubs(false) }` Closure in Gradle.
If you want the plugins not to fail the build when no contracts were found, you can set the `failOnNoStubs` flag in Maven or call the `contractRepository { failOnNoStubs(false) }` Closure in Gradle.
[[how-to-mark-contract-in-progress]]
== How can I Mark that a Contract Is in Progress
If a contract is in progress, it means that the on the producer side tests will not be generated, but the stub will be. You can read more about this in <<project-features.adoc#contract-dsl-in-progress, this section>> of the documentation.
In a CI build, before going to production, you would like to ensure that no in progress contracts are there on the classpath. That's because you may lead to false positives. That's why, by default, in the Spring Cloud Contract plugin, we set the value of `failOnInProgress` to `true`. If you want to allow such contracts when tests are to be generated, just set the flag to `false`.

View File

@@ -225,6 +225,7 @@ extends `com.example.base.BaseClass`. This setting takes precedence over
* `contractsProperties`: A map that contains properties to be passed to Spring Cloud Contract
components. Those properties might be used by (for example) built-in or custom Stub Downloaders.
* `failOnNoContracts`: When enabled, will throw an exception when no contracts were found. Defaults to `true`.
* `failOnInProgress`: If set to true then if any contracts that are in progress are found, will break the build. On the producer side you need to be explicit about the fact that you have contracts in progress and take into consideration that you might be causing false positive test execution results on the consumer side.. Defaults to `true`.
If you want to download your contract definitions from a Maven repository, you can use
the following options: