Slide 1

Slide 1 text

Contract Testing with PACT @[email protected] 1

Slide 2

Slide 2 text

Slide 3

Slide 3 text

Demo Time: There's a Bug @[email protected] 3

Slide 4

Slide 4 text

Today... Today... Today... Today... Today... Integration Testing Integration vs. Integrated Testing Testing Locally? -> Contract Testing Better Contract Testing with Pact Pact Broker Can I deploy? @[email protected] 4

Slide 5

Slide 5 text

Integration Testing @[email protected] 5

Slide 6

Slide 6 text

Slide 7

Slide 7 text

Slide 8

Slide 8 text

Difficulties Difficulties Difficulties Difficulties Difficulties Test environment needed Spin up on demand? Test Data Management! @[email protected] 8

Slide 9

Slide 9 text

Integration vs. Integrated Testing @[email protected] 9

Slide 10

Slide 10 text

Integrated Test Integrated Test Integrated Test Integrated Test Integrated Test @[email protected] 10

Slide 11

Slide 11 text

Slide 12

Slide 12 text

Integration Test Integration Test Integration Test Integration Test Integration Test @[email protected] 12

Slide 13

Slide 13 text

Integrated Integrated Integrated Integrated Integrated Pros Comprehensive "Smoke-Test" Cons Slow All parts must be running Hard to maintain Hard to pin failures Test Data Management Integration Integration Integration Integration Integration Pros Easier to maintain Test can run locally Usually faster Test data setup easier Cons No complete workflow Pros & Cons Pros & Cons Pros & Cons Pros & Cons Pros & Cons @[email protected] 13

Slide 14

Slide 14 text

Testing Locally? @[email protected] 14

Slide 15

Slide 15 text

Slide 16

Slide 16 text

Slide 17

Slide 17 text

Slide 18

Slide 18 text

Across Service Boundaries Across Service Boundaries Across Service Boundaries Across Service Boundaries Across Service Boundaries @[email protected] 18

Slide 19

Slide 19 text

Slide 20

Slide 20 text

Better Contract Testing with Pact https://pact.io/ @[email protected] 20

Slide 21

Slide 21 text

Slide 22

Slide 22 text

Demo Time: Let's Find the Bug! @[email protected] 22

Slide 23

Slide 23 text

Advantages Advantages Advantages Advantages Advantages Both parts can be tested independently and locally Pact ensures consistency between tests @[email protected] 23

Slide 24

Slide 24 text

Pact Broker, Can I Deploy?, ... @[email protected] 24

Slide 25

Slide 25 text

Pact Broker Pact Broker Pact Broker Pact Broker Pact Broker Server Software Records versions of consumers and verified providers https://pactflow.io/ Or run docker image @[email protected] 25

Slide 26

Slide 26 text

Usage Usage Usage Usage Usage 1. Consumer CI build Run Pact tests Publish Pact Triggers Provider Tests 2. Provider CI build Runs Pact verification If the pact verification fails, the build fails Can I deploy? Deploy 3. Back to the Consumer CI build Can I deploy? Deploy @[email protected] 26

Slide 27

Slide 27 text

Can I Deploy? Can I Deploy? Can I Deploy? Can I Deploy? Can I Deploy? Consumer Provider Verified 22 56 true 23 56 true 23 57 false 23 58 true 24 58 true 25 58 false @[email protected] 27

Slide 28

Slide 28 text

$ pact-broker record-deployment --pacticipant Bar --version 56 \ --environment production Consumer Provider Verified 22 56 (production) true 23 56 (production) true 23 57 false 23 58 true 24 58 true 25 58 false @[email protected] 28

Slide 29

Slide 29 text

$ pact-broker can-i-deploy --pacticipant Foo --version 23 \ --to-environment production Computer says yes \o/ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT# ---------|------------|----------|------------|----------|-------- Foo | 23 | Bar | 56 | true | 1 $ pact-broker can-i-deploy --pacticipant Foo --version 24 \ --to-environment production Computer says no ¯_(ツ)_/¯ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT# ---------|------------|----------|------------|----------|-------- Foo | 24 | Bar | 56 | false | 1 @[email protected] 29

Slide 30

Slide 30 text

To Recap... @[email protected] 30

Slide 31

Slide 31 text

Pact can help you find communication problems early You probably still need some integration tests (and even integrated tests) @[email protected] 31

Slide 32

Slide 32 text

About David About David About David About David About David Trainer, Coach, Developer https://davidtanzer.net @[email protected] Slides: speakerdeck.com/dtanzer/

Slide 33

Slide 33 text

Press [ESC] to exit presentation... Presented with Presented with Presented with Presented with Presented with marmota.app @[email protected] 33

Slide 34

Slide 34 text

No content