Provider Contract Testing with Stubs in Artifactory in a Non-JVM World

In this flow, we assume that:spring-doc.cn

  • The API Producer and API Consumer are non-JVM applications.spring-doc.cn

  • The contract definitions are written in YAML.spring-doc.cn

  • The Stub Storage is Artifactory or Nexus.spring-doc.cn

  • Spring Cloud Contract Docker (SCC Docker) and Spring Cloud Contract Stub Runner Docker (SCC Stub Runner Docker) images are used.spring-doc.cn

You can read more about how to use Spring Cloud Contract with Docker here.spring-doc.cn

Here, you can read a blog post about how to use Spring Cloud Contract in a polyglot world.spring-doc.cn

Here, you can find a sample of a NodeJS application that uses Spring Cloud Contract both as a producer and a consumer.spring-doc.cn

Producer Flow

At a high level, the producer:spring-doc.cn

  1. Writes contract definitions (for example, in YAML).spring-doc.cn

  2. Sets up the build tool to:spring-doc.cn

    1. Start the application with mocked services on a given port.spring-doc.cn

      If mocking is not possible, you can set up the infrastructure and define tests in a stateful way.spring-doc.cn

    2. Run the Spring Cloud Contract Docker image and pass the port of a running application as an environment variable. The SCC Docker image:spring-doc.cn

Upon test completion, stubs get uploaded to a stub storage site (such as Artifactory or Git).spring-doc.cn

The following UML diagram shows the producer flow:spring-doc.cn

flows-provider-non-jvm-producer

Consumer Flow

At a high level, the consumer:spring-doc.cn

  1. Sets up the build tool to:spring-doc.cn

  2. Run the application tests against the running stubs.spring-doc.cn

The following UML diagram shows the consumer flow:spring-doc.cn

flows-provider-non-jvm-consumer