Skip to content

Latest commit

 

History

History
144 lines (104 loc) · 3.32 KB

presentation.adoc

File metadata and controls

144 lines (104 loc) · 3.32 KB

Consumer Driven Contracts - a workshop

Introduction

Let’s exercise, hack and talk about

Consumer Driven Contracts.

consumer - communicate - producer

Exercise-01 - Run the tests

  • Get the code:

    • checkout repo
      git@github.com:ollin/cdc-workshop.git

    • cd into cdc-workshop

  • Check your setup:

    • run ./gradlew check (on windows: ./gradlew.bat)

  • Run the tests:

    • run ./gradlew clean test (on windows: ./gradlew.bat)

Project Overview

projects - producer - consumer

Directory Structure

✔ ~/dev/src/github.com/ollin/cdc-workshop [master|✚ 2]
15:59 $ tree -L 2
.
├── address-service     # <-- producer
│   ├── build
│   ├── build.gradle
│   ├── README.adoc
│   └── src
├── build.gradle        # <-- build file for both
├── gradle
│   └── wrapper
├── gradlew
├── gradlew.bat
├── invoice-service     # <-- consumer
│   ├── build
│   ├── build.gradle
│   ├── README.adoc
│   ├── src
│   └── target
├── out
│   └── production
├── presentation
│   ├── build
│   ├── build.gradle
│   └── src
├── README.adoc
└── settings.gradle

Consumers test

cdc-workshop/invoice-service/src/test/java/net/nautsch/invoice/pact/AddressServiceAdapterTest.java
...
link:../../../../invoice-service/src/test/java/net/nautsch/invoice/pact/AddressServiceAdapterTest.java[role=include]
...

Exercise-02 - Add street to consumer

The Consumer needs a street for an address.

Add the field "street" as an expected result.

Hint: Change the pact consumer test (AddressServiceAdapterTest) first.

consumer - extended

Run the tests and see it fail.

Try to fix the tests.

Let’s discuss.

Exercise-03 - Tolerant pact-Tests

net.nautsch.address.Addresses
...
link:../../../../address-service/src/main/java/net/nautsch/address/Addresses.java[role=include]
...

Change the production code! Jan Wloka to Bernd Wloka.

Whats wrong with the address acceptance test? Fix it!

Run the tests.

Why does the pact test pass? And the acceptance test did not?

Let’s discuss.

Exercise-04 - Split the teams

known dependencies
known dependencies

A little bit of theory

concept pact two parts
Source: pact.io

What are pact tests good for? Let’s discuss.