## Spring Cloud Contract Maven Plugin

## spring-cloud-contract:generateTests

Full name:

org.springframework.cloud:spring-cloud-contract-maven-plugin:1.1.6.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) Default value is: `org.springframework.cloud.contract.verifier.tests`.
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`.
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`.
contractsRepositoryUrl | `String` | `-` | The URL from which a JAR containing the 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`.
contractsWorkOffline | `boolean` | `-` | If `true` then JAR with contracts will be taken from local maven repository Default value is: `false`. User property is: `contractsWorkOffline`.
excludedFiles | `List` | `-` | Patterns that should not be taken into account for processing
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
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`
- Default: `org.springframework.cloud.contract.verifier.tests`

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`

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`

contractsRepositoryUrl:

The URL from which a JAR containing the 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`

contractsWorkOffline:

If `true` then JAR with contracts will be taken from local maven repository

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

excludedFiles:

Patterns that should not be taken into account for processing

- Type: `java.util.List`
- Required: `No`

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`

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`