James Earl Douglas
June 11, 2013
A simple test
test("1 + 1 = 2") {
val input1 = 1
val input2 = 1
val expectedOutput = 2
val output = Arithmetic.add(input1, input2)
assert(output === expectedOutput)
}
A simple specification
The Arithmetic#add
function produces the sum of two
integers.
Test code is a side-effect of test specification
Let's produce our tests before (or without) coding them.
test | function | input | expected output |
---|---|---|---|
1 + 1 = 2 | add | 1, 1 | 2 |
Wait, isn't this just a CSV parser?
Yeah, pretty much.
What's benefit of following this pattern?
Test specifications are tangible, and transcend implementation details.