Updated the fail on no contracts option
This commit is contained in:
@@ -1015,6 +1015,45 @@ stubsMode = StubRunnerProperties.StubsMode.REMOTE,
|
||||
----
|
||||
====
|
||||
|
||||
[[features-stub-runner-fail-on-no-stubs]]
|
||||
=== Fail On No Stubs
|
||||
|
||||
By default Stub Runner will fail if no stubs were found. In order to change that behaviour, just set to `false` the `failOnNoStubs` property in the annotation or call the `withFailOnNoStubs(false)` method on a JUnit Rule or Extension.
|
||||
|
||||
====
|
||||
[source,java,indent=0,subs="verbatim,attributes",role="primary"]
|
||||
.Annotation
|
||||
----
|
||||
@AutoConfigureStubRunner(
|
||||
stubsMode = StubRunnerProperties.StubsMode.REMOTE,
|
||||
repositoryRoot = "stubs://file://location/to/the/contracts",
|
||||
ids = "com.example:some-producer",
|
||||
failOnNoStubs = false)
|
||||
----
|
||||
|
||||
[source,java,indent=0,subs="verbatim,attributes",role="secondary"]
|
||||
.JUnit 4 Rule
|
||||
----
|
||||
@Rule
|
||||
public StubRunnerRule rule = new StubRunnerRule()
|
||||
.downloadStub("com.example:some-producer")
|
||||
.repoRoot("stubs://file://location/to/the/contracts")
|
||||
.stubsMode(StubRunnerProperties.StubsMode.REMOTE)
|
||||
.withFailOnNoStubs(false);
|
||||
----
|
||||
|
||||
[source,java,indent=0,subs="verbatim,attributes",role="secondary"]
|
||||
.JUnit 5 Extension
|
||||
----
|
||||
@RegisterExtension
|
||||
public StubRunnerExtension stubRunnerExtension = new StubRunnerExtension()
|
||||
.downloadStub("com.example:some-producer")
|
||||
.repoRoot("stubs://file://location/to/the/contracts")
|
||||
.stubsMode(StubRunnerProperties.StubsMode.REMOTE)
|
||||
.withFailOnNoStubs(false);
|
||||
----
|
||||
====
|
||||
|
||||
[[features-stub-runner-common]]
|
||||
=== Common Properties
|
||||
|
||||
|
||||
@@ -308,6 +308,16 @@ closure to set it up.
|
||||
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`.
|
||||
|
||||
There is also the `contractRepository { ... }` closure that contains the following properties
|
||||
|
||||
* `repositoryUrl`: the URL to the repository with contract definitions
|
||||
* `username` : Repository username
|
||||
* `password` : Repository password
|
||||
* `proxyPort` : the port of the proxy
|
||||
* `proxyHost` : the host of the proxy
|
||||
* `cacheDownloadedContracts` : If set to `true` then will cache the folder where non snapshot contract artifacts got downloaded. Defaults to `true`.
|
||||
|
||||
You can also turn on the following experimental features in the plugin:
|
||||
|
||||
|
||||
@@ -1441,4 +1441,11 @@ If you want to fetch contracts or stubs from a given location without cloning a
|
||||
[[how-to-generate-stubs-at-runtime]]
|
||||
== How can I Generate Stubs at Runtime
|
||||
|
||||
If you want to generate stubs at runtime for contracts, it's enough to switch the `generateStubs` property in the `@AutoConfigureStubRunner` annotation, or call the `withGenerateStubs()` method on the JUnit Rule or Extension. You can read more about this in <<project-features.adoc#features-stub-runner-generate-stubs-at-runtime, this section>> of the documentation.
|
||||
If you want to generate stubs at runtime for contracts, it's enough to switch the `generateStubs` property in the `@AutoConfigureStubRunner` annotation, or call the `withGenerateStubs(true)` method on the JUnit Rule or Extension. You can read more about this in <<project-features.adoc#features-stub-runner-generate-stubs-at-runtime, this section>> of the documentation.
|
||||
|
||||
[[how-to-use-the-failonnostubs-feature]]
|
||||
== How can I Make The Build Pass if There Are No Contracts or Stubs
|
||||
|
||||
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.
|
||||
@@ -222,6 +222,7 @@ extends `com.example.base.BaseClass`. This setting takes precedence over
|
||||
`packageWithBaseClasses` and `baseClassForTests`.
|
||||
* `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`.
|
||||
|
||||
If you want to download your contract definitions from a Maven repository, you can use
|
||||
the following options:
|
||||
|
||||
Reference in New Issue
Block a user