SlideShare a Scribd company logo
Common Path for
Approval Testing
patterns for more powerful asserts
@LlewellynFalco
English
CodeResult
Whiteboard
// Create side (0,0) – (3,4)
// Verify length
Side s = new Side(0,0,3,4);
Approvals.Verify(s + “ length = “ +s.Length);
Side (0,0) – (3,4) length = 5
Testing Circle
1) Numbers
// verify 2 names
assert(2, names.length)
Easy
Simple
1) Numbers
// verify names
assert(5, names.length)
assert(“Llew”, names[0])
assert(“Woody”, names[1])
assert(“Jim”, names[2])
assert(“Jason”, names[3])
assert(“Dan”, names[4])
Can get
complicated
I have to
change my
Scenarios
to make it work
1. Specification
2. Feedback
3. Regression
4. Granularity
2) Strings
// verify names
Assert(
“[Llew, Woody, Jim, Jason, Dan]”,
names.toString())
More expressive
Objects, Tests & Logs
Can use
your
normal
Scenarios
2) Strings You’ll start to want
more…
// verify names
Assert(
“[Llew, Woody, Jim, Jason, Dan]”,
names.toString())
3)
// verify json
Assert(
“{age:12,
name:Tom,
address: 123 fake st}”,
tom.toString())
Easy to test bigger
concepts
Long
strings
3)
// verify xml
Assert(
“<xml><person>nt<name>tom<name>n
t<age>”13”<age>nt</person>”,
tom.toString())
Can get very bigLong
strings
Line endings
Scoping
Matters
can != should
4) Files
// verify companies as xml
assertFileContains(
“expected.companylist.xml”,
report.toString())
Less Clutter
Can use
your
normal
Scenarios
4) Files
// verify companies as xml
assertFileContains(
“expected.companylist.xml”,
report.toString())
Lots of filenames
Creating
The files
5)
// verify companies as xml
Verify(report)
Convention over
configuration
Code
starts to
become
trivial
Automatic
names
5)
// verify companies as xml
Verify(report)
What went wrong?
Automatic
names
Slow
Do
Verify Pass
Increase
Feedback
Fail
See the forest
& the trees
Files not
limited to
text
6) Diff Tools
Can render
html, svg, etc…
(on failure)
Duplication
in the tests6) Diff Tools
On failure
event is
pretty basic
(on failure)
Testing gets
easier & easier7)
Custom Test
Methods
MapReduce.verify(…)
Wpf.verify(…)
Xml.verify(…)
Routing.verify(…)
Tests give
high Return on
Investment
1. Numb3rs
2. “Strings”
3. “VeryrnLongrnStrings”
4. Files.txt
5. AutomaticNames()
6. DIFF TOOLS DIFF T00LS
7. Test.CustomVerify()

More Related Content

Approval testing from basic to advanced