Testing the
Bigger Picture -
Architectural
Testability
@northern_tester
Ash Winter –
tester, speaker,
author, testability
advocate
• Distracted by local
optima…
• Where is the
biggest gain to be
made in the system?
• Your architecture
silly!
Testers. Always chasing the feature
squirrel…
@northern_tester
@northern_tester
If the architectural testability of your system is
poor, it means…
…it won’t get tested
…the tester will test it
…it won’t work
…it will be hard to operate
…it will be frustrating to use
…it will make your team sad
…it will create bottlenecks
…it will make less money
What we will cover…
@northern_tester
• Team Testability
Test
• Your testing
smells
• CODS model
• Improving your
world
Testability is
just a vague
concept
@northern_tester
Testability is
only a
system
property
It’s a social
problem to
solve
@northern_tester
It’s a
technical
problem to
solve
It’s someone
else's
problem
@northern_tester
Retrofitting is
incredibly
hard
Can’t we just
get on with
it?
@northern_tester
Confused with
automatability
Software testability is how easy a
product or system is to test.
@northern_tester
Software testability is the degree to which a
software artefact supports testing in a given test
context. If the testability of the software artefact is
high, then finding faults in the system by means of
testing is easier.
@northern_tester
Practical Testability
by James Bach
@northern_tester
Useful but
hard to
discuss with
stakeholders
@northern_tester
Testability
as pyramid
base by
Richard
Bradshaw
@northern_tester
Better! A familiar
model to get people
on board
@northern_tester
@northern_tester
People, teams,
organisations,
relationships,
information flow
Technologies,
languages, libraries,
tools, architecture, ops
@northern_tester
Barely a mention in
many testing
models
@northern_tester
Ability to test
• Impactful
• Performing testing
increases
testability
• Diverse techniques
• Bottleneck
Testing your team for
testability…
@northern_tester
Without them suspecting a thing…
@northern_tester
Who is this…
• It’s Joel Spolsky
• Writer of blogs at
joelonsoftware.com
• FogBugz
• Trello
• Co-founder of Stack
Overflow
• Most importantly though,
The Joel Test!
@northern_tester
WTF…
• The Joel Test
• 12 Steps to Better Code
• Not all patterns but teams,
working conditions etc.
• Insight without the maturity
model…
@northern_tester
Test and Testability
• Your testing tells you
about your testability
• You can cover a lot of
ground
• While not really talking
about testability
• Just talking about the
testing you do already
Exercise: The Team Test
for Testability
@northern_tester
@northern_tester
The Team Test
• Yes or No
• Fast
• Social aspects
• Technical aspects
• Retrospective
• Team similarities &
differences
Learning
@northern_tester
• Testability challenges manifest in our
testing but testing may not be the root
• Talking about testability too early can
cause engagement problems
• Use existing ceremonies to gather
testability information
• Might expose ‘easy wins’ such as access
problems
Architectural testability allows your team to make
changes with very low cost and risk.
@northern_tester
Architectural testability allows your team to create tests that
provide valuable feedback within minutes, if not seconds.
Each team member can run a set of tests every time they
make a change. This feedback provides a safety net that
encourages your team members to make changes frequently
without fear. Confidence in testing encourages refactoring
and continuous improvement of the code.
@northern_tester
Draw your architecture
@northern_tester
• My architecture
• Take 5 minutes to
draw yours out,
don’t worry about
too much detail
What does good look like?
@northern_tester
• Embraces change
• Decoupled but
cohesive
• Minimizes waste
• Sustainable
• Relationships
Good memories…
@northern_tester
• Right size microservices, responsible for just enough
• Each service has a mock for early testing by
consumers
• Code instrumented with structured, contextual events
• Consistent API docs expressed in Swagger
What does bad look like?
@northern_tester
• Slows as complexity
grows
• Technical debt pooling
• Untested areas
• Side effects
• Persistent team siloing
Painful memories…
@northern_tester
• Three types of consumer, SOAP, batch, web
• Mixed technologies - LAMP but with Microsoft SQL Server
• Two minutes for new application test environment, two
weeks for the database
• Different logging and monitoring tooling by layer
administered by different teams.
@northern_tester
Retrofitting
• Is really, really hard
• Architectures act as
anchors
• Have you ever tried to
change an architecture
for testing?
• Tiny changes to move
the needle
Introducing the CODS model for
architectural testability
@northern_tester
Controllability…
@northern_tester
• You can set the system
into its important states
• Identify and control
important variables
 Configuration
• Control the environment
the system resides in
 Test data
Observability…
@northern_tester
• Infer internal state from
external outputs
• Logs - a message
• Metrics – a measure
• Events – a collection for
a unit of work
• Instrument for the
information we want
Decomposability…
@northern_tester
• Independent testable
components
• Test alone
• Test unique combinations
• Learn and debug
Simplicity…
@northern_tester
• How easy the system is to
understand
• Consumers, inputs,
outputs, interactions,
technologies, protocols,
configurations
• Transparency
• Cognitive load again
@northern_tester
Operability
Operability
Operability
Operability
When can we use this…
@northern_tester
• Story kick off
• Post-mortem
• Architecture
design and review
We need to
be able to
detect
problems
@northern_tester
Use the
CODS model
to help us
make the right
changes
@northern_tester
Smells of Poor Architectural
Testability
@northern_tester
Not always obvious
• Symptoms show in daily
work
• Queues
• Bottlenecks
• Cadence
• Frustrated team
• Frustrated stakeholders
@northern_tester
My mobile testing story…
Pull a feature branch, build a development environment, configure
relevant external feeds, find device, join a specific Wi-Fi network,
change DNS, configure a local proxy to intercept and change certain
headers and URI's.
@northern_tester
Problems
• Desensitized
• Hours from build to test
• Shallow testing
• Automation?
• Ready to test work
• Frustrated everyone
What smells do you
recognize?
@northern_tester
Release
Management
Theatre
Mono
strategies
Fear of
change
Teams
looking for
more testers
Too many
user
interface
tests
Valuable
scenarios
not tested
Lack of
resilience
testing
“Sunny”
days only
Cluttered
logging
with no
insights
Excessive
test
repetition
Issues hard to
isolate and
debug
Tests that
don’t die
Lengthy
build
times
Too many
persistent
environments
Environments no
one cares about
Inanimate
documentation
Customer
hand
holding
Poor relations with
Ops
Long lists of
deferred bugs
Hard to test
dependencies
Wrangling
over scale
95th
Percentile?
Tester
turnover
Exercise: Detecting Testing Smells
@northern_tester
Experiencing
@northern_tester
• High maintenance automation due to dependencies
• Hard to debug and isolate problems
• Mock two key external services
• Unique tracing id throughout their logging
Doing
@northern_tester
• Rate each smell for
your current context
based on the handout
• If you have friends here
from your company, get
together.
Learning
@northern_tester
• Causes are not obvious
• The whole architecture is the target
area, not just the app.
• Looking for smells can yield testability
improvements
• Common smells and unique smells…
@northern_tester
Improving architectural testability
using CODS
@northern_tester
Tactics for testability
• Controllability
• Feature flags
• Canary release
• Automated deployment
• Blue/green
• Ephemeral environments
@northern_tester
Tactics for testability
• Observability
• Events over logs
• Tracing
• Visualization
• Traffic replay
• Diagnostic &
application
information
@northern_tester
Tactics for testability
• Decomposability
• Microservices
• Circuit breakers
• Message brokers
• Mocks and spies
@northern_tester
Tactics for testability
• Simplicity
• Automated documentation
• Team on call
• Technical debt
• Pairing & mobbing
• Architecture Decision
Records
@northern_tester
When testing isn’t enough
• Scared testers
• Updating core library
• Major versions
• Small increments
• Load testing
• Deployed to limited
live services
Exercise: Applying the
CODS Model
@northern_tester
20 000
transactions
per second
@northern_tester
@northern_tester
@northern_tester
Operability
Operability
Operability
Operability
Logs to
events
Retired
unused
API’s
New services
for high
throughput
API’s
Circuit
breakers
Throttling
Tracing
ID’s
Actionable
alerts
Architectural
Decision
Records
Feature
Toggle
Dashboard
Doing
@northern_tester
• Look where your testing stinks
• Determine where to focus CODS
• Add to your architecture
• Annotate with recommendations
Thinking
@northern_tester
Think about:
• Size of change?
• Where to start?
Learning
@northern_tester
• Smells give us clues on where to focus
• CODS provides a framework for
change
• Visualizing is great for advocacy
• Choose changes carefully…
Handouts
TeamDrivenTestability–TeamTestforTestability
Foryourteam,completetheTeamTestforTestability.PutaYesorNoanswerforeach.Ifit’snotconsistent
putNo.Thereisadescriptionandexamplestoguideyou.Addyourtotalatthebottom.
QuestionDescriptionExamplesAnswer
Doeseachmemberofthe
teamhaveamethodof
consumingtheapplication
logsfromProduction?
Werecognisetheimportancethatall
teammemberscanseebelowthe
applicationwithorganisedlogging
whichshowsimportantsystemevents,so
wearen'tfooledbywhatweseeonthe
surfaceoftheapplicationswetest.
No:Limitedteammembershaveaccessto
disparatehoststoinspectlogfiles
Yes:Wehavetoolingwhichcentralises,
aggregatesanddisplaysourloggingwhichis
availabletoallteammembers
Doestheteamknowwhat
valuethe95thpercentileof
responsetimesisfortheir
system?
Werecognisetheneedtoperformance
andcapacitytest,gatherdatafor
analysis,andanalysedatawithout
outlierstoexposethesystemlimits.
No:Weregularlydeferperformanceandcapacity
testing
Yes:Weactivelytrackourperformanceand
capacitywithregulartestingandreviewona
consistentbasis
Doestheteamcollaborate
regularlywithteamsthat
maintaintheir
dependencies?
Werecognisetheimportanceofour
internalandexternaldependencies.The
testabilityofdependencieseffectsyour
testability.
No:Wecontactourdependencieswhenthereisa
problem
Yes:Wecollaboratewithourdependenciesby
attendingtheirceremonieswhereappropriateand
monitoringtheiruptime
Cantheteamtestboththe
scheduledandondemand
partsoftheirsystem?
Weneedtheabilitytotestboth
scheduledtaskswhichliftsandshiftsor
replicatesdataandotheroperations
whichoccurondemand.
No:Wewaittotestscheduledtasksinlater
environments
Yes:Wecantestbothscheduledandondemand
taskswhenneeded,whiletheyarebeing
developed
Canyousetyoursystem
intoagivenstatetorepeata
test?
Weneedtheabilitytosetbothdataand
configurationtorecreatetheconditions
foraspecifictest,toassistwith
consistencyandreproducibility.
No:Testdataandconfigurationarenotinsource
control,requiresaseparateteamtoschedulea
change
Yes:Testdataandconfigurationisinsource
controlandcanbesetbytheteam
TeamDrivenTestability–TeamTestforTestability
Iseachmemberoftheteam
abletocreateadisposable
testenvironment?
Weneedallmembersoftheteamtobe
abletobuildatestenvironmentwitha
specificversionoftheapplicationand
tearitdownafterwardstoenableearly
showcasingandtesting.
No:Allourenvironmentsarepersistentwithalong
buildperformedoutsidetheteam
Yes:Anenvironmentcanbecreatedanddestroyed
byeachteammemberinaself-servicemanner
Ifyouasktheteamto
changetheircodebase,do
theyreactpositively?
Weneedconfidencewhenchangesthat
addvaluearerequired,wecanchange
thecodeorconfigurationwith
knowledgeofpotentialimpacts.
No:Wearereluctanttochangesomeorpartofthe
codebasewithoutlengthyanalysis
Yes:Weareconfidentthatwecanmakeisolatable
changeswhichcanrealisebusinessvaluewhile
minimisingrisk
Iseachmemberoftheteam
abletorunautomatedunit
tests?
Weneedaclearunderstandingwhata
unitisinthecontextofoursystemand
eachteammembercanexecuteour
lowestleveltestsuiteondemand.
No:Wehavenounittests
Yes:Unittestsarepartofourdefinitionofdone,run
aspartofcontinuousintegrationandexecutableby
anyteammember
Doestheteamcuratea
livingknowledgebase
aboutthesystemit
maintains?
Weneedastoreofoperationaland
applicationknowledgethatiskeptupto
dateinorderforourstakeholdersto
integratewiththeteamwhichisupto
datewithoursystem.
No:Wehaveateamwikipagewhichisupdated
Yes:Wehavealivingexecutablespecification
describingoursystemanddocumentationsuchas
Swaggerforthosewhowishtointegratewithus
Doestheteamknowwhich
partsofthecodebaseare
subjecttothemostchange?
Weneedanunderstandingofwhich
areasofourcodebasearesubjecttothe
mostchangesowecantargettesting
appropriately.
No:Werelyonintuitionalonetodescribechanges
Yes:Wevisualiseoursourcecoderepositories
usingtoolingsuchasGource.
Doeseachmemberofthe
teamhaveaccesstothe
systemsourcecontrol?
Weneedallmembersoftheteamto
accessoneofthemaincollaboration
artefactsforadevelopmentteam,for
codeandconfiguration.
No:Onlythedevelopershaveaccesstothecode
Yes:Developers,test,operationsandproduct
stakeholderscanatleastviewthecodeortakepart
incodereviews
Doestheteamhaveregular
contactwiththeusersofthe
system?
Weneedregularcontactwithourusers,
internalorexternal,withapreference
forfacetofaceifpossible.
No:Wefixanyoperatorproblemsaftergo-live
Yes:Wecollaboratewithourusersoften,inviting
internaluserstoourceremoniesandwith
monitoringofjourneystocomplementdirect
feedbackbyexternalusers
TeamDrivenTestability–TestingSmells
#SmellExampleImpact
(1-5)
CODS
Model
1Toomanyproduction
issues
Doesyourteamfeelthattoomanyissuesareescapinginto
production?Isyourteam'splannedworkfrequentlyinterruptedand
delayedasaresultofdealingwithproductionissues?
CS
2Pre-releaseregression
cycles
Doesyourteamhavetoexecutealengthyregressiontestcycle
beforereleasing?Doesyourteamoftenfindimportantissuesduring
thisregressioncycle?
COS
3Lackofautomation&
exploratorytesting
Doesyourteamfrequentlycheckandconfirmthingsthatshouldbe
doneusingautomation?Doesyourteamoverlookexploratory
testing?
CODS
4HesitancetochangecodeIsyourteamhesitanttomakesmall,regularcodeimprovementsfor
fearitwillintroduceundetectedissues?Doesyourteamfeel
uncomfortablerefactoringthecodeevenwhentheybelieveit's
necessary?
CODS
5Testingnotconsidered
duringarchitecturaldesign
Doesyourteamneglecttoinvolvetestersinthearchitecturaldesign
discussions?Doesyourteamneglecttheimpactontestingwhen
makingdesigndecisions?
S
6TeamseekingmoretestersDoesyourteamfeelliketheyneedtoaddmoretestersasaresultof
mountingworkloadandcomplexity?
CDS
7ToomanyslowUItestsDoesyourteamwastealotoftimepreparing,executingandwaiting
forfeedbackfromslowUItests,eithermanualorautomated?
C
8Importantscenariosnot
tested
Doesyourteamreleasethesystemwithouttestingimportant
scenariosbecausetheyareeitherimpossibleorimpracticaltotest?
Arethereareasofsignificantriskthatarenotbeingtested?
CD
9Ineffectiveunitand
integrationtests
Doesyourteamwriteunittestsandintegrationteststhatoftenmiss
importantproblems?Doesyourteamendeavourtocontinuously
improveyourunitandintegrationtests?
DS
TeamDrivenTestability–TestingSmells
10Clutteredineffective
logging
Doyourlogscontainlotsoferrorsandwarningsevenwhenthe
systemisconsideredtobebehavingasnormal?Canteammembers
quicklyandeasilyisolateanddebugissuesusingthelogs?
OD
11Flakynondeterministic
automation
Doesyourteamspendalargeproportionoftheirtimeinvestigating
failures,debuggingandmaintainingautomation?Doesyourteam
re-runautomationwhenitfailsexpectingittopassthesecondtime?
ODS
12Teststhatcontain
duplication&irrelevant
detail
Doesyourteamhaveteststhatcontainalotofduplicatesteps
(usuallysetup)inordertogetitinastatetoperformtheessential
partofthetest?Doesyourteamhaveteststhatcontainlotsofdetails
thathavenothingspecificallytodowithwhatyou'reactuallytrying
totest?
CS
13Issuesaredifficultto
reproduce
Doesyourteamoftenencounterissuesthataredifficult,time
consumingorimpracticaltoreproduceeitherinyourtest
environmentsorproduction?
COD
14Issuesaredifficulttoisolate
&debug
Doesyourteamstruggletoisolateanddebugissueswhenthey
occureitherinyourtestenvironmentsorproduction?Doesittake
daysofinvestigationtofindtherootcauseofaproblem?
D
15Toomucheffortspent
writing,maintainingand
debuggingautomation
DoesyourteamrelytooheavilyonautomationwrittenattheUI
level?DoesyourteamtestbusinesslogicthroughtheUI?
CODS
ImpactonDeliveryofValueandTeamSatisfactionScale
1Noimpactonteameffectiveness
2Smellcontributestoteamperiodicallybuildingfeatureswhichdonotmeetdefinitionofdone
3Smellcontributestoteamoftenbuildingfeatureswhichdonotmeetdefinitionofdone
4Smellcontributestofeatureswhichresultinproductionincidentsthatdamagevalueandconfidence
5Smellcontributestomultipledeliveryproblemswhichprohibitreleaseandincidentresolution
PotentialRemediesandImprovements–TestableArchitecture
Observability
•Loggingineachlayerof
thearchitectureand
betweencomponents
•Controllablelevelsof
loggingbyrequestto
gatherfurtherinformation
onconsumerrequests
•Aggregatedloggingto
bringtogetherlogsfrom
variouslayersand
interfacestoshowholistic
picturesofsystemsevents
•Createtheabilitytoreplay
traffictoobserveeventsin
thearchitecture
•Monitoringwhich
combinesdiagnostics(CPU
usagesforexample)and
applicationinformation
Controllability
•Featureflagging
techniquestocontrol
exposureofnew
technologyorfunctionality
•Trialmanagementto
releasenewtechnologyor
functionalitytoalimited
numberofconsumers
•Automateddeploymentof
theapplicationtobeable
todeploynewversionson
demand
•BlueGreendeploymentsto
switchbetweennewand
oldversionstoprotect
currentandnew
functionality
•Createenvironmentsto
mirrorproductiontoahigh
degree
Decomposability
•Employingamicroservice
architecturetodecouple
criticalcomponents
•Createcircuitbreakers
betweenlayerstohandle
persistenterrorconditions
betweeninternaland
externalservices.
•Addqueueingtechnology
suchasKafkatomanage
highloadscenariosorto
queueinfrequent
operationstobeprocessed
atadifferenttime.
•Createmocksforexternal
servicestoisolatepartsof
thearchitecturefortesting
andissuediagnosis
Simplicity
•AutomatedAPI
documentationtooling
suchasSwagger
•Developersandtesters
supportthesystemin
Production
•Policiestopayback
technicaldebtsuchastest-
drivendevelopment
•Pairandmob
programmingtopromote
knowledgesharing
betweendevelopersand
operationspeople.
•AdoptLightweight
ArchitectureRecordsin
sourcecontroltotrack
changestothearchitecture

Architectural Testability Workshop for Test Academy Barcelona

Editor's Notes

  • #19 Controllability determines the dept and breath of our testing efforts - how deep you can go while still knowing what breadth you have covered. Without this you can go down the rabbit hole and miss the bigger picture. Without control testing is pushed later and later, Controllability determines what scenarios we can exercise - whether it be setting test data to the right state or ensuring a dependency returns a specific response.
  • #39 Controllability determines the dept and breath of our testing efforts - how deep you can go while still knowing what breadth you have covered. Without this you can go down the rabbit hole and miss the bigger picture. Without control testing is pushed later and later, Controllability determines what scenarios we can exercise - whether it be setting test data to the right state or ensuring a dependency returns a specific response.
  • #46 2000 bugs in 2 years Communicated through tickets Longs test cycles against builds on long lived environments Mastered weirdly named tooling “Quality Centre” Left with a weird feeling - we did tons of testing, but we never got any faster, no one got what they wanted…
  • #58 Controllability determines the dept and breath of our testing efforts - how deep you can go while still knowing what breadth you have covered. Without this you can go down the rabbit hole and miss the bigger picture. Without control testing is pushed later and later, Controllability determines what scenarios we can exercise - whether it be setting test data to the right state or ensuring a dependency returns a specific response.
  • #59 Controllability determines the dept and breath of our testing efforts - how deep you can go while still knowing what breadth you have covered. Without this you can go down the rabbit hole and miss the bigger picture. Without control testing is pushed later and later, Controllability determines what scenarios we can exercise - whether it be setting test data to the right state or ensuring a dependency returns a specific response.
  • #60 Controllability determines the dept and breath of our testing efforts - how deep you can go while still knowing what breadth you have covered. Without this you can go down the rabbit hole and miss the bigger picture. Without control testing is pushed later and later, Controllability determines what scenarios we can exercise - whether it be setting test data to the right state or ensuring a dependency returns a specific response.