One of my stated goals with Lazytest was to enforce a clean separation between test assertions and code that runs before/around the assertions.
The Spock framework for Java/Groovy calls these the stimulus and response, identified by the keywords
then, respectively. I find this approach attractive, but one look at Spock’s documentation shows it’s thoroughly embedded in the imperative mode:
when: stack.push(elem) then: !stack.empty stack.size() == 1 stack.peek() == elem
In my last Lazytest update, I added the
expect macro, which signals failure by throwing an exception. That was useful for adding typed “reason for failure” objects to the test results, but not good in that it led me back in the direction of allowing arbitrary code in test examples.
After todays’ commits, the
expect macro is still there, but you don’t use it explicitly. I’ve reverted to allowing only a single test expression inside the
it macro. That expression will automatically be wrapped in
If you really need to execute arbitrary code in an example, use the new
do-it macro, and call
Hopefully this is explained clearly enough in the new README.