Professional Documents
Culture Documents
Microservices Testing
Microservices Testing
com
Testing Microservices
Techniques for Automation
European Testing Conference 2018
Emily Bache
@emilybache
www.praqma.com
Emily Bache
Consultant
Author of
@emilybache
emily.bache@praqma.com
www.praqma.com
Pagero Online
Cloud Service
Invoice Invoice
Issuer Recipient
Some numbers…
www.praqma.com
Pagero Online’s architecture
www.praqma.com
A Microservice
• Independently Deployable
• Lightweight API
• Not too big: fits in my head Docker is used to containerise the service
www.praqma.com
Testing a Microservices
Architecture
In my experience
www.praqma.com
Test Pyramid: Mike Cohn
End-To-End tests
End-to-End exercise the whole
system
“Service Tests”
Unit
Unit tests are for
individual functions
https://www.mountaingoatsoftware.com/blog/the-forgotten-layer-of-the-test-automation-pyramid
www.praqma.com
Testing Strategy for the Monolith
www.praqma.com
Testing Strategy
www.praqma.com
Microservice Tests
µSUT
• Deploy your service on localhost (and
the database if it has one) Test Case
µSDB
collaborator µS
www.praqma.com
Faster execution
Deploy in Same Process
µSUT
• In-process testing: Deploy your
service with an in-memory database Test Case Internal api
µSDB
collaborator µS
www.praqma.com
More production-like
Deploy in Different
Processes
µSUT
• Out-of-process testing: Deploy your
service in one process, and the test Test Case
case in another
• Security needed for ‘internal api’ so
only test/non-production code can
access
• Easier to performance test
µSDB
collaborator µS
www.praqma.com
Business-Facing Feature
Tests
www.praqma.com
Testing a whole Feature
Test Case
• Techniques:
Keep testing costs
as low as possible
• Selective Deployment
• Approval Testing
• Event Monitoring
www.praqma.com
Service-layer tests in a monolith
Monolith
• Test cases are for
different business-
Test Case A
facing workflows
Test Case B
• Will exercise different
components within the
monolith
Database
www.praqma.com
Feature tests in microservices
www.praqma.com
Selective Deployment
www.praqma.com
Pagero Online
Cloud Service
Invoice Invoice
Issuer Recipient
Parts of a test case
www.praqma.com
Approval Testing
www.praqma.com
The “Approved” Result as Text
Recipient
Recipient Presentation
Presentation in plain text
pdf-to-text utility
www.praqma.com
Elements of a Test Case
common to to determine
for reference
Input data varies by test case many tests pass/fail
www.praqma.com
Debugging a failing test?
Test Case
www.praqma.com
Event log recorded in a test case
www.praqma.com
Test Case Elements
www.praqma.com
Independent Microservices
& Teams
www.praqma.com
Testing in the pipeline
version
unit
microservice
system
manual
production
control test test test test
Pair
Programming,
TDD
more production-like environment
monitoring
Test costs increase
www.praqma.com
Multi-team development
Component B
Components C&D
Components E&F
Testing in the pipeline
version
unit
component
system
manual
production
control test test test test
Pair
Programming,
TDD
monitoring
www.praqma.com
Multi-Team CD
Team A
micro- system
manual
version
unit
production
service
test test
control test
test
monitoring
Team B
Team pipelines
Team A
micro- team-
manual
version
unit
system
service
system
test
production
control test test
test test
One environment
shared by all teams
monitoring
Team B
Teams Deploy Independently
Team A incremental
micro- team-
team-
roll-out to
version
unit
service
system
manual
production
control test
test test test
monitoring &
manual testing
Team B
Summary
@emilybache
monitoring
Testing in a
Microservices Architecture team-
system
test
System Tests
Summary
@emilybache
monitoring
Testing in a
Microservices Architecture team-
system
test
System Tests
The Continuous Delivery and DevOps Company
www.praqma.com