Fork me on GitHub

spring-cloud-contract:generateTests

Full name:

org.springframework.cloud:spring-cloud-contract-maven-plugin:4.0.1:generateTests

Description:

From the provided directory with contracts generates the acceptance tests on the producer side.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: test.
  • Binds by default to the lifecycle phase: generate-test-sources.

Optional Parameters

Name Type Since Description
<assertJsonSize> boolean - Incubating feature. You can check the size of JSON arrays. If not turned on explicitly will be disabled.
Default value is: false.
User property is: spring.cloud.contract.verifier.assert.size.
<baseClassForTests> String - (no description)
<baseClassMappings> List - A way to override any base class mappings. The keys are regular expressions on the package name of the contract and the values FQN to a base class for that given expression. Example of a mapping .*.com.example.v1..* -> com.example.SomeBaseClass When a contract's package matches the provided regular expression then extending class will be the one provided in the map - in this case com.example.SomeBaseClass.
User property is: baseClassMappings.
<basePackageForTests> String - (no description)
<contractDependency> Dependency - (no description)
User property is: contractDependency.
<contractsDirectory> File - (no description)
Default value is: ${project.basedir}/src/test/resources/contracts.
User property is: spring.cloud.contract.verifier.contractsDirectory.
<contractsMode> StubRunnerProperties$StubsMode - Picks the mode in which stubs will be found and registered.
Default value is: CLASSPATH.
User property is: contractsMode.
<contractsPath> String - The path in the JAR with all the contracts where contracts for this particular service lay. If not provided will be resolved to groupid/artifactid. Example: If groupid is com.example and artifactid is service then the resolved path will be /com/example/artifactid
User property is: contractsPath.
<contractsProperties> Map - Map of properties that can be passed to custom StubDownloaderBuilder.
User property is: contractsProperties.
<contractsRepositoryPassword> String - The password to be used to connect to the repo with contracts.
User property is: contractsRepositoryPassword.
<contractsRepositoryProxyHost> String - The proxy host to be used to connect to the repo with contracts.
User property is: contractsRepositoryProxyHost.
<contractsRepositoryProxyPort> Integer - The proxy port to be used to connect to the repo with contracts.
User property is: contractsRepositoryProxyPort.
<contractsRepositoryUrl> String - The URL from which a contracts should get downloaded. If not provided but artifactid / coordinates notation was provided then the current Maven's build repositories will be taken into consideration.
User property is: contractsRepositoryUrl.
<contractsRepositoryUsername> String - The user name to be used to connect to the repo with contracts.
User property is: contractsRepositoryUsername.
<deleteStubsAfterTest> boolean - If set to false will NOT delete stubs from a temporary folder after running tests.
Default value is: true.
User property is: deleteStubsAfterTest.
<excludedFiles> List - Patterns that should not be taken into account for processing.
<failOnInProgress> boolean - 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.
Default value is: true.
User property is: failOnInProgress.
<failOnNoContracts> boolean - When enabled, this flag will tell stub runner to throw an exception when no stubs / contracts were found.
Default value is: true.
User property is: failOnNoContracts.
<generatedTestResourcesDir> File - (no description)
Default value is: ${project.build.directory}/generated-test-resources/contracts.
<generatedTestSourcesDir> File - (no description)
Default value is: ${project.build.directory}/generated-test-sources/contracts.
<ignoredFiles> List - Patterns for which Spring Cloud Contract Verifier should generate @Ignored tests.
<imports> String[] - Imports that should be added to generated tests.
<includedFiles> List - Patterns that should be taken into account for processing.
User property is: includedFiles.
<incrementalContractTests> boolean - If set to true then tests are created only when contracts have changed since last build.
Default value is: true.
User property is: incrementalContractTests.
<mavenTestSkip> boolean - (no description)
Default value is: false.
User property is: maven.test.skip.
<nameSuffixForTests> String - (no description)
<packageWithBaseClasses> String - A package that contains all the base clases for generated tests. If your contract resides in a location src/test/resources/contracts/com/example/v1/ and you provide the packageWithBaseClasses value to com.example.contracts.base then we will search for a test source file that will have the package com.example.contracts.base and name ExampleV1Base. As you can see it will take the two last folders to and attach Base to its name.
User property is: packageWithBaseClasses.
<ruleClassForTests> String - (no description)
<skip> boolean - (no description)
Default value is: false.
User property is: spring.cloud.contract.verifier.skip.
<staticImports> String[] - Static imports that should be added to generated tests.
<testFramework> TestFramework - (no description)
Default value is: JUNIT5.
<testMode> TestMode - (no description)
Default value is: MOCKMVC.

Parameter Details

<assertJsonSize>

Incubating feature. You can check the size of JSON arrays. If not turned on explicitly will be disabled.
  • Type: boolean
  • Required: No
  • User Property: spring.cloud.contract.verifier.assert.size
  • Default: false

<baseClassForTests>

(no description)
  • Type: java.lang.String
  • Required: No

<baseClassMappings>

A way to override any base class mappings. The keys are regular expressions on the package name of the contract and the values FQN to a base class for that given expression. Example of a mapping .*.com.example.v1..* -> com.example.SomeBaseClass When a contract's package matches the provided regular expression then extending class will be the one provided in the map - in this case com.example.SomeBaseClass.
  • Type: java.util.List
  • Required: No
  • User Property: baseClassMappings

<basePackageForTests>

(no description)
  • Type: java.lang.String
  • Required: No

<contractDependency>

(no description)
  • Type: org.apache.maven.model.Dependency
  • Required: No
  • User Property: contractDependency

<contractsDirectory>

(no description)
  • Type: java.io.File
  • Required: No
  • User Property: spring.cloud.contract.verifier.contractsDirectory
  • Default: ${project.basedir}/src/test/resources/contracts

<contractsMode>

Picks the mode in which stubs will be found and registered.
  • Type: org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties$StubsMode
  • Required: No
  • User Property: contractsMode
  • Default: CLASSPATH

<contractsPath>

The path in the JAR with all the contracts where contracts for this particular service lay. If not provided will be resolved to groupid/artifactid. Example: If groupid is com.example and artifactid is service then the resolved path will be /com/example/artifactid
  • Type: java.lang.String
  • Required: No
  • User Property: contractsPath

<contractsProperties>

Map of properties that can be passed to custom StubDownloaderBuilder.
  • Type: java.util.Map
  • Required: No
  • User Property: contractsProperties

<contractsRepositoryPassword>

The password to be used to connect to the repo with contracts.
  • Type: java.lang.String
  • Required: No
  • User Property: contractsRepositoryPassword

<contractsRepositoryProxyHost>

The proxy host to be used to connect to the repo with contracts.
  • Type: java.lang.String
  • Required: No
  • User Property: contractsRepositoryProxyHost

<contractsRepositoryProxyPort>

The proxy port to be used to connect to the repo with contracts.
  • Type: java.lang.Integer
  • Required: No
  • User Property: contractsRepositoryProxyPort

<contractsRepositoryUrl>

The URL from which a contracts should get downloaded. If not provided but artifactid / coordinates notation was provided then the current Maven's build repositories will be taken into consideration.
  • Type: java.lang.String
  • Required: No
  • User Property: contractsRepositoryUrl

<contractsRepositoryUsername>

The user name to be used to connect to the repo with contracts.
  • Type: java.lang.String
  • Required: No
  • User Property: contractsRepositoryUsername

<deleteStubsAfterTest>

If set to false will NOT delete stubs from a temporary folder after running tests.
  • Type: boolean
  • Required: No
  • User Property: deleteStubsAfterTest
  • Default: true

<excludedFiles>

Patterns that should not be taken into account for processing.
  • Type: java.util.List
  • Required: No

<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.
  • Type: boolean
  • Required: No
  • User Property: failOnInProgress
  • Default: true

<failOnNoContracts>

When enabled, this flag will tell stub runner to throw an exception when no stubs / contracts were found.
  • Type: boolean
  • Required: No
  • User Property: failOnNoContracts
  • Default: true

<generatedTestResourcesDir>

(no description)
  • Type: java.io.File
  • Required: No
  • Default: ${project.build.directory}/generated-test-resources/contracts

<generatedTestSourcesDir>

(no description)
  • Type: java.io.File
  • Required: No
  • Default: ${project.build.directory}/generated-test-sources/contracts

<ignoredFiles>

Patterns for which Spring Cloud Contract Verifier should generate @Ignored tests.
  • Type: java.util.List
  • Required: No

<imports>

Imports that should be added to generated tests.
  • Type: java.lang.String[]
  • Required: No

<includedFiles>

Patterns that should be taken into account for processing.
  • Type: java.util.List
  • Required: No
  • User Property: includedFiles

<incrementalContractTests>

If set to true then tests are created only when contracts have changed since last build.
  • Type: boolean
  • Required: No
  • User Property: incrementalContractTests
  • Default: true

<mavenTestSkip>

(no description)
  • Type: boolean
  • Required: No
  • User Property: maven.test.skip
  • Default: false

<nameSuffixForTests>

(no description)
  • Type: java.lang.String
  • Required: No

<packageWithBaseClasses>

A package that contains all the base clases for generated tests. If your contract resides in a location src/test/resources/contracts/com/example/v1/ and you provide the packageWithBaseClasses value to com.example.contracts.base then we will search for a test source file that will have the package com.example.contracts.base and name ExampleV1Base. As you can see it will take the two last folders to and attach Base to its name.
  • Type: java.lang.String
  • Required: No
  • User Property: packageWithBaseClasses

<ruleClassForTests>

(no description)
  • Type: java.lang.String
  • Required: No

<skip>

(no description)
  • Type: boolean
  • Required: No
  • User Property: spring.cloud.contract.verifier.skip
  • Default: false

<staticImports>

Static imports that should be added to generated tests.
  • Type: java.lang.String[]
  • Required: No

<testFramework>

(no description)
  • Type: org.springframework.cloud.contract.verifier.config.TestFramework
  • Required: No
  • Default: JUNIT5

<testMode>

(no description)
  • Type: org.springframework.cloud.contract.verifier.config.TestMode
  • Required: No
  • Default: MOCKMVC