The document discusses patterns for more powerful asserts when doing approval testing. It outlines 7 approaches to asserting values in approval tests, moving from simple number and string assertions to more complex objects, files, automatically generated names, custom verification methods, and using diff tools to compare outputs on failure. The goal is to make approval testing more expressive and tests less cluttered while still using normal test scenarios.
2. 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
4. 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
6. 2) Strings
// verify names
Assert(
“[Llew, Woody, Jim, Jason, Dan]”,
names.toString())
More expressive
Objects, Tests & Logs
Can use
your
normal
Scenarios
17. Testing gets
easier & easier7)
Custom Test
Methods
MapReduce.verify(…)
Wpf.verify(…)
Xml.verify(…)
Routing.verify(…)
Tests give
high Return on
Investment