-
Notifications
You must be signed in to change notification settings - Fork 435
Spring Cloud Contract 1.0.0 M2 Release Notes
For changes in earlier milestones, please refer to:
With this feature the @AutoConfigureStubRunner
annotation can pass additional information. Example
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureStubRunner(ids = {"com.example:http-server-dsl:+:stubs:8080"}, workOffline = true)
public class LoanApplicationServiceTests {
What needs to be migrated when going from M1 -> M2 are the property values. We used to have the subproperty stubs
in the props:
stubrunner.stubs:
ids: 'com.example:http-server-dsl:+:stubs:8080'
repositoryRoot: http://repo.spring.io/libs-snapshot
Now this subproperty is removed
stubrunner:
ids: 'com.example:http-server-dsl:+:stubs:8080'
repositoryRoot: http://repo.spring.io/libs-snapshot
So *wherever you have the property stubrunner.stubs
you have to migrate it to stubrunner
.
The downloaded WireMock stubs could be registered in any Spring Cloud discovery we support. Due to this one could start the Stub Runner Boot server for the end to end tests of the tested application and all stubs of its collaborators would be automatically downloaded and registered in a Service Discovery. Related issue
Example of a class with proper annotations
@SpringBootApplication
@EnableStubRunnerServer
@EnableEurekaClient
@AutoConfigureStubRunner
public class StubRunnerBootEurekaExample {
public static void main(String[] args) {
SpringApplication.run(StubRunnerBootEurekaExample.class, args);
}
}
Once executed with the following props:
-Dstubrunner.repositoryRoot=http://repo.spring.io/snapshots (1)
-Dstubrunner.cloud.stubbed.discovery.enabled=false (2)
-Dstubrunner.ids=org.springframework.cloud.contract.verifier.stubs:loanIssuance,org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer,org.springframework.cloud.contract.verifier.stubs:bootService (3)
-Dstubrunner.idsToServiceIds.fraudDetectionServer=someNameThatShouldMapFraudDetectionServer (4)
(1) - we tell Stub Runner where all the stubs reside
(2) - we don't want the default behaviour where the discovery service is stubbed. That's why the stub registration will be picked
(3) - we provide a list of stubs to download
(4) - we provide a list of artifactId to serviceId mapping
You will download the stubs and register them in Eureka.