O'Reilly logo
live online training icon Live Online training

Consumer Driven Contracts - A hands-on guide to Spring Cloud Contract

Not just for Spring applications

Marcin Grzejszczak

You need confidence when pushing new features to a new application or service in a distributed system. You don’t want to set up the whole suite of services on your laptop to click through the feature – it’s often impossible due to the limited resources. Waiting for a couple of hours for the end to end tests to finish, to see whether two applications can talk to each other, seems like a complete waste of time.

Contract testing is a technique that allows you to catch any issues with faulty integration of services at your application build time. Thanks to such testing you can apply the “fail fast” approach and break the build if two applications will not be able to communicate with each other. In this video course you’ll learn how to apply the provider and consumer driven contract testing approaches, for Spring and non-Spring based applications with Spring Cloud Contract. We will write code for JVM and non-JVM services, since Spring Cloud Contract can be used in a polyglot environment.

What you'll learn-and how you can apply it

By the end of this course, you'll understand:

  • What consumer driven contract testing is
  • How to fail fast when your integration is faulty
  • How contract tests can be used with messaging

And you will be able to:

  • Use Spring Cloud Contract to verify whether your current testing customs are correct
  • Leverage Spring Cloud Contract Stub Runner to automatically fetch and run stubs
  • Use Docker to generate and test non JVM based applications

This training course is for you because...

  • You’re a front-end developer that wants to evolve the back-end API without filing tickets and waiting for them to be processed for ages
  • You’re a back-end developer and you would want to know who and how is using your API
  • You’re a tester and you would like to automate and increase the reliability of integration tests
  • You’re a product manager and you would like the project to spend less money on end to end testing and catch bugs earlier

Prerequisites

Course Set-up:

Recommended Follow-up:

About your instructor

  • Marcin Grzejszczak is a software engineer at Pivotal. He has written two books, Mockito Instant and Mockito Cookbook and co-authored the Applied Continuous Delivery Live Lessons with Josh Long. Marcin is co-founder of the Warsaw Cloud Native meetup. Currently he is working as lead of the Spring Cloud Sleuth, Spring Cloud Contract, and Spring Cloud Pipelines projects. You can follow Marcin on Twitter @mgrzejszczak.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Segment 1 Why contract tests matters (60 mins)

  • Generating a HTTP / Messaging consumer Spring Boot project from start.spring.io (5)
  • Writing a test using WireMock (5)
  • Generating a HTTP / Messaging producer Spring Boot project from start.spring.io (5)
  • Writing a HTTP contract test and missing producer implementation (10)
  • Running end to end tests and explain what went wrong (5)
  • Fixing the HTTP tests via contract tests on the consumer side (5)
  • Creating a message sending test & component (8)
  • Creating a contract for the received message (8)
  • Run the end to end tests and explain what went wrong (5)
  • Fix the messaging tests via contract tests (5)

Break (length: 5m)

Segment 2 Doing consumer driven contracts with Spring Cloud Contract (60 mins)

  • Introduction to Contract Tests (5)
  • Introduction to the Beer feature and coding flow of a real life situation (5)
  • TDDing the consumer side (5)
  • Cloning the producer and creating contracts (8)
  • Making the consumer tests pass with Spring Cloud Contract (5)
  • TDD on the level of architecture, refactoring the endpoint (5)
  • PR on the producer and online mode on the consumer side (6)
  • Explanation of how consumer driven contracts work on consumer and producer side (5)
  • Automatic stub generation with rest docs (5)

Break (length: 10m)

Segment 3 Spring Cloud Contract advanced (60 mins)

  • Using Spring Cloud WireMock to create stubs of services we don’t own (15)
  • Using Spring Cloud Contract Stub Runner standalone (15)
  • Starting stubs for polyglot applications (15)
  • Generating tests for polyglot applications (15)