"Expect tests" seems like a bad name, since that covers all tests.
"Expect tests" seems like a bad name, since that covers all tests.
I much prefer property based testing over expectation based testing. You have to explicitly think about what properties hold true about the thing you're writing.
For example, fib(N+1) = fib(N) + fib(N), so this property can be tested for all N; primitive generators can easily generate the data, and good composition framework can easily generate complex data from primitive data.
Of course, you have to have a property you can specify easily. Otherwise, it'd be exactly the same as expectation based testing.
I've found a bug in a Haskell program about fib generation - your test would work (if fixed for the subtractions) but incorrectly as there was an overflow in the addition. A basic property of "fib(n+1) > fib(n)" for n>1 finds this.
I like this type of testing as it asks you to more generally consider what guarantees your code is making about its operation.
Edit - your example is a good one and necessary, I just wanted to add a bit extra as I really like property based testing
Yes this is right level of automation, not whatever this article is going on about with the editor integration. Yuck.