## Spring Cloud Contract Maven Plugin

## spring-cloud-contract:generateTests

Full name:

org.springframework.cloud:spring-cloud-contract-maven-plugin:2.2.0.BUILD-SNAPSHOT: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`.
contractsSnapshotCheckSkip | `boolean` | `-` | Deprecated. - with 2.1.0 this option is redundant Default value is: `false`. User property is: `contractsSnapshotCheckSkip`.
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.
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`.
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`.
skipTests | `boolean` | `-` | (no description) Default value is: `false`. User property is: `skipTests`.
staticImports | `String[]` | `-` | Static imports that should be added to generated tests.
testFramework | `TestFramework` | `-` | (no description) Default value is: `JUNIT`.
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`

contractsSnapshotCheckSkip:

Deprecated. - with 2.1.0 this option is redundant
If `true` then will not assert whether a stub / contract JAR was downloaded from local or remote location.

- Type: `boolean`
- Required: `No`
- User Property: `contractsSnapshotCheckSkip`
- Default: `false`

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`

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`

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`

skipTests:

(no description)

- Type: `boolean`
- Required: `No`
- User Property: `skipTests`
- 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: `JUNIT`

testMode:

(no description)

- Type: `org.springframework.cloud.contract.verifier.config.TestMode`
- Required: `No`
- Default: `MOCKMVC`