Search code examples
spring-cloud-contract

Is it possible to test consumer side without stub runner in spring-cloud-contract


Currently I want to test the error handling of calling other micro services in consumer side via spring cloud contract. But there are some troubles blocking me to create stubs in provider side due to it's difficult to share build artifacts in docker CI build.

I'm wondering if possible to just create groovy or yaml contacts in consumer side then using them by wiremock server?


Solution

  • There are ways to achieve it. One, is to clone the producer's code, run ./mvnw clean install -DskipTests or ./gradlew publishToMavenLocal -x test and have the stubs installed without running any tests. Another option is to write your own StubDownloaderBuilder (for Finchley) that will fetch the contracts via Aether as the AetherStubDownloader does, but then will also automatically convert the contracts to WIreMock stubs.

    Of course both approaches are "cheating". You shouldn't use the stubs in your CI system until the producer has actually published the stubs.

    Maybe instead of hacking the system it's better to analyze

    provider side due to it's difficult to share build artifacts in docker CI build.

    and try to fix it? Why is it difficult? What exactly is the problem?