SlideShare a Scribd company logo
1 of 29
Daria Golub, August 2020
Testing microservices.
Contract testing
Is it our job?
Part of being professional is
crafting a high-quality product
Motivation
Developer testing turns human
checking into machine checking,
thus, by definition, resulting in
testable software and freeing up
time for more interesting and
intellectually demanding testing
activities
Cost vs Quality
Martin Fowler. Is High Quality Software Worth the Cost?
https://martinfowler.com/articles/is-quality-worth-cost.html
cruft - the difference between the current code and
how it would ideally be.
• Neglecting internal quality leads to
rapid build up of cruft
• This cruft slows down feature
development
• Even a great team produces cruft,
but by keeping internal quality high,
is able to keep it under control
• High internal quality keeps cruft to a
minimum, allowing a team to add
features with less effort, time, and
cost.
High quality software is cheaper
to produce
Testing objectives
Approach “Testing to Critique”
• Will the user be delighted by the software?
• Is the scope reasonable?
• Has any function been forgotten?
Developer mindset Tester mindset
Testing objectives
Approach “Testing to Support”
• Support sustainable pace
• Support the team’s ability to work fast and without fear
• Provide confidence and fast feedback loop
• Provides quality feedback loop
Agile testing
Reactive to proactive
• Make sure that testing activities are taken into account during planning
• Testing should be included in estimations
• Help PO to specify desired functionality through defining test cases
• Pair programming/testing to avoid bias
Agile testing
Pair programming / testing. TDD
Writing tests
Writing
feature
Testing pyramid
Single function/method
Single service.
All collaborators subbed/mocked
Several services
Full coverage from UI
Unit tests
Best practices
• Calculate code coverage. Baseline to be defined by the team / for each
component
• PR should not bring down code coverage
• Every new/changed code should be covered with tests
• Cover not only happy flow, but also corner cases and alternative/exception
flows
Unit tests. Coverage
Service tests
Pros and Cons
run independently
give fast feedback
are stable
are easy to maintain
do not give us confidence to release.
Integration tests, E2E tests
Contract testing
Contract testing
is a technique for testing an integration point by checking each application
in isolation to ensure the messages it sends or receives conform to a
shared understanding that is documented in a "contract".
• Captures the interactions that are
exchanged between 2 service
• Stores them in a contract
• Each party verifies adherence to the
contract
Contract testing
Consumer driven contract testing. PACT
Pact is a code-first tool for testing HTTP and message integrations using contract
tests
Consumer side
During the consumer tests, each
request made to a Pact mock
provider is recorded into the
contract file, along with its
expected response.
How PACT works
Provider side
A Pact simulated consumer then
replays each request against the
real provider, and compares the
actual and expected responses.
How PACT works
Contract tests
run independently
give fast feedback
are stable
are easy to maintain
give confidence to release
What is PACT not good for?
• Testing APIs where the team maintaining the other side of the integration will not
also being using Pact
• Testing APIs where the consumers cannot be individually identified (eg. public
APIs).
• Testing providers where the consumer and provider teams do not have good
communication channels.
• Performance and load testing.
• Functional testing of the provider
• Testing "pass through" APIs, where the provider merely passes on the request
contents to a downstream service without validating them.
Matching. Best practices
Request matching
• Exact matching for the expectations for a request (as you are in control)
• Don’t use random or generated data (it can look like contract has changed)
Matching. Best practices
Response matching
• Response matching should be as loose as possible.
• Don’t test exact values!
• Use matching features like:
• Type matching
• Regular expressions
Implementation steps
Consumer
• Implement consumer test which will generate pact
• Publish pact to pact broker with consumer’s version and tag
Documentation:
https://docs.pact.io/
Implementation steps
Provider
• Implement provider test which will will get latest pact from pact broker
• Publish verification results with provider’s version and tag
Can I deploy?
• Add step to the CI/CD build which will check if latest version of Consumer /
Provider was verified
https://docs.pact.io/pact_broker/client_cli/readme
Docker image: pactfoundation/pact-cli:latest
Recommended literature
• Building Microservices by Sam Newman. Chapter 7 “Testing”
• Developer Testing by Alexander Tarlinder
• The Art of Unit Testing
• https://docs.pact.io/
• https://martinfowler.com/articles/is-quality-worth-cost.html

More Related Content

What's hot

Continuous Performance Testing with Taurus and Jmeter
Continuous Performance Testing with Taurus and JmeterContinuous Performance Testing with Taurus and Jmeter
Continuous Performance Testing with Taurus and JmeterAgile Testing Alliance
 
50+ ways to improve tester - programmer relationship
50+ ways to improve tester - programmer relationship50+ ways to improve tester - programmer relationship
50+ ways to improve tester - programmer relationshipAgile Testing Alliance
 
API Testing – Keeping a Check on Agile Software Development
API Testing – Keeping a Check on Agile Software DevelopmentAPI Testing – Keeping a Check on Agile Software Development
API Testing – Keeping a Check on Agile Software DevelopmentSoftware Testing Solution
 
Micro Service automation by Srijit Jain
Micro Service automation by Srijit JainMicro Service automation by Srijit Jain
Micro Service automation by Srijit JainSoftware Testing Board
 
Continuous integration testing fundamentals
Continuous integration testing fundamentalsContinuous integration testing fundamentals
Continuous integration testing fundamentalsCygnet Infotech
 
A Top Down Approach to End-to-End Testing
A Top Down Approach to End-to-End TestingA Top Down Approach to End-to-End Testing
A Top Down Approach to End-to-End TestingSmartBear
 
WiKi Based Automation Testing: Fitness & DevOps
WiKi Based Automation Testing: Fitness & DevOpsWiKi Based Automation Testing: Fitness & DevOps
WiKi Based Automation Testing: Fitness & DevOpsAgile Testing Alliance
 
QA Automation testing - Cloud deployed workflow application
QA Automation testing - Cloud deployed workflow applicationQA Automation testing - Cloud deployed workflow application
QA Automation testing - Cloud deployed workflow applicationZado Technologies
 
Augmented Reality & Software Testing - Sourabh d
Augmented Reality & Software Testing - Sourabh dAugmented Reality & Software Testing - Sourabh d
Augmented Reality & Software Testing - Sourabh dAgile Testing Alliance
 
Enabling agility with continuous integration testing
Enabling agility with continuous integration testingEnabling agility with continuous integration testing
Enabling agility with continuous integration testingIBM Rational software
 
Continuous Delivery without Significant Test Automation
Continuous Delivery without Significant Test AutomationContinuous Delivery without Significant Test Automation
Continuous Delivery without Significant Test AutomationMaaret Pyhäjärvi
 
Ashwini - Effective use of CI by QA
Ashwini - Effective use of CI by QAAshwini - Effective use of CI by QA
Ashwini - Effective use of CI by QAvodQA
 
Presentation on 3 Pillars of DevOps - Kovair DevOps
Presentation on 3 Pillars of DevOps - Kovair DevOpsPresentation on 3 Pillars of DevOps - Kovair DevOps
Presentation on 3 Pillars of DevOps - Kovair DevOpsKovair
 
Automation testing strategy, approach & planning
Automation testing  strategy, approach & planningAutomation testing  strategy, approach & planning
Automation testing strategy, approach & planningSivaprasanthRentala1975
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automationMacharla Pradeep
 
How to Perform Test Automation With Gauge & Selenium Framework
How to Perform Test Automation With Gauge & Selenium Framework How to Perform Test Automation With Gauge & Selenium Framework
How to Perform Test Automation With Gauge & Selenium Framework Sarah Elson
 

What's hot (20)

Continuous Performance Testing with Taurus and Jmeter
Continuous Performance Testing with Taurus and JmeterContinuous Performance Testing with Taurus and Jmeter
Continuous Performance Testing with Taurus and Jmeter
 
50+ ways to improve tester - programmer relationship
50+ ways to improve tester - programmer relationship50+ ways to improve tester - programmer relationship
50+ ways to improve tester - programmer relationship
 
API Testing – Keeping a Check on Agile Software Development
API Testing – Keeping a Check on Agile Software DevelopmentAPI Testing – Keeping a Check on Agile Software Development
API Testing – Keeping a Check on Agile Software Development
 
Micro Service automation by Srijit Jain
Micro Service automation by Srijit JainMicro Service automation by Srijit Jain
Micro Service automation by Srijit Jain
 
Continuous integration testing fundamentals
Continuous integration testing fundamentalsContinuous integration testing fundamentals
Continuous integration testing fundamentals
 
ATAGTR2017 Blockchain Based Testing
ATAGTR2017 Blockchain Based TestingATAGTR2017 Blockchain Based Testing
ATAGTR2017 Blockchain Based Testing
 
A Top Down Approach to End-to-End Testing
A Top Down Approach to End-to-End TestingA Top Down Approach to End-to-End Testing
A Top Down Approach to End-to-End Testing
 
WiKi Based Automation Testing: Fitness & DevOps
WiKi Based Automation Testing: Fitness & DevOpsWiKi Based Automation Testing: Fitness & DevOps
WiKi Based Automation Testing: Fitness & DevOps
 
QA Automation testing - Cloud deployed workflow application
QA Automation testing - Cloud deployed workflow applicationQA Automation testing - Cloud deployed workflow application
QA Automation testing - Cloud deployed workflow application
 
Augmented Reality & Software Testing - Sourabh d
Augmented Reality & Software Testing - Sourabh dAugmented Reality & Software Testing - Sourabh d
Augmented Reality & Software Testing - Sourabh d
 
Enabling agility with continuous integration testing
Enabling agility with continuous integration testingEnabling agility with continuous integration testing
Enabling agility with continuous integration testing
 
Continuous Delivery without Significant Test Automation
Continuous Delivery without Significant Test AutomationContinuous Delivery without Significant Test Automation
Continuous Delivery without Significant Test Automation
 
App Testing Experts
App Testing ExpertsApp Testing Experts
App Testing Experts
 
Ashwini - Effective use of CI by QA
Ashwini - Effective use of CI by QAAshwini - Effective use of CI by QA
Ashwini - Effective use of CI by QA
 
47 b 9e3-b98
47 b 9e3-b9847 b 9e3-b98
47 b 9e3-b98
 
Presentation on 3 Pillars of DevOps - Kovair DevOps
Presentation on 3 Pillars of DevOps - Kovair DevOpsPresentation on 3 Pillars of DevOps - Kovair DevOps
Presentation on 3 Pillars of DevOps - Kovair DevOps
 
Automation testing strategy, approach & planning
Automation testing  strategy, approach & planningAutomation testing  strategy, approach & planning
Automation testing strategy, approach & planning
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automation
 
Testing and qa services
Testing and qa servicesTesting and qa services
Testing and qa services
 
How to Perform Test Automation With Gauge & Selenium Framework
How to Perform Test Automation With Gauge & Selenium Framework How to Perform Test Automation With Gauge & Selenium Framework
How to Perform Test Automation With Gauge & Selenium Framework
 

Similar to Testing microservices, contract testing

Quality at the speed of digital
Quality   at the speed of digitalQuality   at the speed of digital
Quality at the speed of digitalrajni singh
 
Testing Microservices
Testing MicroservicesTesting Microservices
Testing MicroservicesNagarro
 
An Ultimate Guide to Continuous Testing in Agile Projects.pdf
An Ultimate Guide to Continuous Testing in Agile Projects.pdfAn Ultimate Guide to Continuous Testing in Agile Projects.pdf
An Ultimate Guide to Continuous Testing in Agile Projects.pdfKMSSolutionsMarketin
 
Top Software panies to Outsource.pdfTesting Com
Top Software panies to Outsource.pdfTesting ComTop Software panies to Outsource.pdfTesting Com
Top Software panies to Outsource.pdfTesting ComMindfire LLC
 
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanQA or the Highway
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentnikhil sreeni
 
Testing Strategy To Test A Ticketing Platform
Testing Strategy To Test A Ticketing PlatformTesting Strategy To Test A Ticketing Platform
Testing Strategy To Test A Ticketing PlatformKnoldus Inc.
 
How to scale your Test Automation
How to scale your Test AutomationHow to scale your Test Automation
How to scale your Test AutomationKlaus Salchner
 
PMI-ACP Lesson 06 Quality
PMI-ACP Lesson 06 QualityPMI-ACP Lesson 06 Quality
PMI-ACP Lesson 06 QualityThanh Nguyen
 
Software Testing PPT | Software All Testing
Software Testing PPT | Software All TestingSoftware Testing PPT | Software All Testing
Software Testing PPT | Software All Testingsankalpkumarsahoo174
 
Webapp Automation Testing of performance marketing and media platform
Webapp Automation Testing of performance marketing and media platformWebapp Automation Testing of performance marketing and media platform
Webapp Automation Testing of performance marketing and media platformKnoldus Inc.
 
Top 5 automation testing tools to gear up website development
Top 5 automation testing tools to gear up website developmentTop 5 automation testing tools to gear up website development
Top 5 automation testing tools to gear up website developmentBJIT Ltd
 
! Testing for agile teams
! Testing for agile teams! Testing for agile teams
! Testing for agile teamsDennis Popov
 

Similar to Testing microservices, contract testing (20)

Quality at the speed of digital
Quality   at the speed of digitalQuality   at the speed of digital
Quality at the speed of digital
 
Testing Microservices
Testing MicroservicesTesting Microservices
Testing Microservices
 
An Ultimate Guide to Continuous Testing in Agile Projects.pdf
An Ultimate Guide to Continuous Testing in Agile Projects.pdfAn Ultimate Guide to Continuous Testing in Agile Projects.pdf
An Ultimate Guide to Continuous Testing in Agile Projects.pdf
 
Test Policy and Practices
Test Policy and PracticesTest Policy and Practices
Test Policy and Practices
 
Top Software panies to Outsource.pdfTesting Com
Top Software panies to Outsource.pdfTesting ComTop Software panies to Outsource.pdfTesting Com
Top Software panies to Outsource.pdfTesting Com
 
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Future of QA
Future of QAFuture of QA
Future of QA
 
Futureofqa
FutureofqaFutureofqa
Futureofqa
 
Testing Strategy To Test A Ticketing Platform
Testing Strategy To Test A Ticketing PlatformTesting Strategy To Test A Ticketing Platform
Testing Strategy To Test A Ticketing Platform
 
testing.pptx
testing.pptxtesting.pptx
testing.pptx
 
Software_Testing_ppt.pptx
Software_Testing_ppt.pptxSoftware_Testing_ppt.pptx
Software_Testing_ppt.pptx
 
Madhav_Resume
Madhav_ResumeMadhav_Resume
Madhav_Resume
 
How to scale your Test Automation
How to scale your Test AutomationHow to scale your Test Automation
How to scale your Test Automation
 
PMI-ACP Lesson 06 Quality
PMI-ACP Lesson 06 QualityPMI-ACP Lesson 06 Quality
PMI-ACP Lesson 06 Quality
 
Software Testing PPT | Software All Testing
Software Testing PPT | Software All TestingSoftware Testing PPT | Software All Testing
Software Testing PPT | Software All Testing
 
Webapp Automation Testing of performance marketing and media platform
Webapp Automation Testing of performance marketing and media platformWebapp Automation Testing of performance marketing and media platform
Webapp Automation Testing of performance marketing and media platform
 
Top 5 automation testing tools to gear up website development
Top 5 automation testing tools to gear up website developmentTop 5 automation testing tools to gear up website development
Top 5 automation testing tools to gear up website development
 
! Testing for agile teams
! Testing for agile teams! Testing for agile teams
! Testing for agile teams
 
Software-Testing-ppt.pptx
Software-Testing-ppt.pptxSoftware-Testing-ppt.pptx
Software-Testing-ppt.pptx
 

Recently uploaded

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Recently uploaded (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Testing microservices, contract testing

  • 1. Daria Golub, August 2020 Testing microservices. Contract testing
  • 2. Is it our job? Part of being professional is crafting a high-quality product
  • 3. Motivation Developer testing turns human checking into machine checking, thus, by definition, resulting in testable software and freeing up time for more interesting and intellectually demanding testing activities
  • 4. Cost vs Quality Martin Fowler. Is High Quality Software Worth the Cost? https://martinfowler.com/articles/is-quality-worth-cost.html
  • 5. cruft - the difference between the current code and how it would ideally be. • Neglecting internal quality leads to rapid build up of cruft • This cruft slows down feature development • Even a great team produces cruft, but by keeping internal quality high, is able to keep it under control • High internal quality keeps cruft to a minimum, allowing a team to add features with less effort, time, and cost. High quality software is cheaper to produce
  • 6. Testing objectives Approach “Testing to Critique” • Will the user be delighted by the software? • Is the scope reasonable? • Has any function been forgotten?
  • 8. Testing objectives Approach “Testing to Support” • Support sustainable pace • Support the team’s ability to work fast and without fear • Provide confidence and fast feedback loop • Provides quality feedback loop
  • 9. Agile testing Reactive to proactive • Make sure that testing activities are taken into account during planning • Testing should be included in estimations • Help PO to specify desired functionality through defining test cases • Pair programming/testing to avoid bias
  • 10. Agile testing Pair programming / testing. TDD Writing tests Writing feature
  • 11. Testing pyramid Single function/method Single service. All collaborators subbed/mocked Several services Full coverage from UI
  • 12. Unit tests Best practices • Calculate code coverage. Baseline to be defined by the team / for each component • PR should not bring down code coverage • Every new/changed code should be covered with tests • Cover not only happy flow, but also corner cases and alternative/exception flows
  • 14. Service tests Pros and Cons run independently give fast feedback are stable are easy to maintain do not give us confidence to release.
  • 17. Contract testing is a technique for testing an integration point by checking each application in isolation to ensure the messages it sends or receives conform to a shared understanding that is documented in a "contract".
  • 18. • Captures the interactions that are exchanged between 2 service • Stores them in a contract • Each party verifies adherence to the contract Contract testing
  • 19. Consumer driven contract testing. PACT Pact is a code-first tool for testing HTTP and message integrations using contract tests
  • 20. Consumer side During the consumer tests, each request made to a Pact mock provider is recorded into the contract file, along with its expected response. How PACT works
  • 21. Provider side A Pact simulated consumer then replays each request against the real provider, and compares the actual and expected responses. How PACT works
  • 22. Contract tests run independently give fast feedback are stable are easy to maintain give confidence to release
  • 23. What is PACT not good for? • Testing APIs where the team maintaining the other side of the integration will not also being using Pact • Testing APIs where the consumers cannot be individually identified (eg. public APIs). • Testing providers where the consumer and provider teams do not have good communication channels. • Performance and load testing. • Functional testing of the provider • Testing "pass through" APIs, where the provider merely passes on the request contents to a downstream service without validating them.
  • 24. Matching. Best practices Request matching • Exact matching for the expectations for a request (as you are in control) • Don’t use random or generated data (it can look like contract has changed)
  • 25. Matching. Best practices Response matching • Response matching should be as loose as possible. • Don’t test exact values! • Use matching features like: • Type matching • Regular expressions
  • 26. Implementation steps Consumer • Implement consumer test which will generate pact • Publish pact to pact broker with consumer’s version and tag Documentation: https://docs.pact.io/
  • 27. Implementation steps Provider • Implement provider test which will will get latest pact from pact broker • Publish verification results with provider’s version and tag
  • 28. Can I deploy? • Add step to the CI/CD build which will check if latest version of Consumer / Provider was verified https://docs.pact.io/pact_broker/client_cli/readme Docker image: pactfoundation/pact-cli:latest
  • 29. Recommended literature • Building Microservices by Sam Newman. Chapter 7 “Testing” • Developer Testing by Alexander Tarlinder • The Art of Unit Testing • https://docs.pact.io/ • https://martinfowler.com/articles/is-quality-worth-cost.html