View
1.726
Download
0
Category
Preview:
Citation preview
#DevoxxUS @spoole167 @stuartmarks
Steve Poole : IBM
JVM Developer
DevOps practitioner
Developer Advocate
Stuart Marks : Oracle
Principal MTS
Java / OpenJDK Core Libraries
#DevoxxUS @spoole167 @stuartmarks
“I get paid for code that works, not for tests”
How to maximize your effort and protect your investment in tests and testing now with
addedCloud
#DevoxxUS @spoole167 @stuartmarks
1. Think before you act2. Make your tests understandable3. Keep your tests “small and simple”4. Test one thing only5. Fast tests only6. Absolute repeatability7. Independent tests only8. Provide diagnostic data on failure 9. No hard-coding of your environment10.No extraneous output
#DevoxxUS @spoole167 @stuartmarks
1. Think before you act
What are you testing?
Why are you testing?
Planht
tps:
//ww
w.fl
ickr
.com
/pho
tos/
ayur
vedi
cmed
icin
es/
#DevoxxUS @spoole167 @stuartmarks
2. Make your tests understandable
Comments
Expected behaviour
Aid debug
Diagnostics
http
s://w
ww
.flic
kr.c
om/p
hoto
s/83
6334
10@
N07
/
#DevoxxUS @spoole167 @stuartmarks
3. Keep your tests “small and simple”
Separate test logic / setup
Much easier to debug
Use setup / teardown
https://www.flickr.com/photos/9266144@N02/
#DevoxxUS @spoole167 @stuartmarks
4. Test one thing only
One scenario per test
Enables fast debug
Obvious why test failed
https://www.flickr.com/photos/ryantron/
#DevoxxUS @spoole167 @stuartmarks
5. Fast tests only
Run unit tests often as possible
Maintain quality bar
Quick results
https://www.flickr.com/photos/mcleod/
#DevoxxUS @spoole167 @stuartmarks
6. Absolute repeatability
Non-deterministictests are a headache
Fix intermittent tests immediately
No value, waste of resource
Must trust all tests
https://www.flickr.com/photos/fdecomite/
#DevoxxUS @spoole167 @stuartmarks
7. Independent tests only
Must run in any order
Run subset, faster results
No dependencies
http
s://w
ww
.flic
kr.c
om/p
hoto
s/sh
eila
_sun
d/
#DevoxxUS @spoole167 @stuartmarks
8. Provide diagnostic data on failure
Use message in asserts
Make it simple to debug
Reference input dataRecord test environment info ht
tps:
//ww
w.fl
ickr
.com
/pho
tos/
davi
dbak
er/
#DevoxxUS @spoole167 @stuartmarks
9. No hard-coding of your environment
No ports, IP addresses,data files, databases
Use config files, systemproperties or mock objects
Portable tests
http
s://w
ww
.flic
kr.c
om/p
hoto
s/pu
g50/
#DevoxxUS @spoole167 @stuartmarks
10. No extraneous output
A passing test is a silent test
Too much output = confusion
Use option, config file toturn on debug, save output
http
s://w
ww
.flic
kr.c
om/p
hoto
s/3-
bs/
#DevoxxUS @spoole167 @stuartmarks
Pirate rules
Guidelines only
Some may seen obvious.
Some may seem pedantic
Until you inherit a testsuite…
Thank you.https://www.flickr.com/photos/gapic/
© 2017 IBM Corporation
Mission Badge #6:SMS Text
Your mission should you choose to accept it….
Join us at the IBM Booth for hands-on labs, demos, games and talk to our developers.
Text Mission2017 to 41411to get the booth giveaway and learn more about all the IBM sessions & speakers.
Enter the raffle by completing missions for a chance to win• a Drone• TJBot Kit • VR glasses
Recommended