March 2016
Intermediate to advanced
304 pages
8h 9m
English
When you create a unit test to examine the behavior of a specific class, you’ll find yourself writing the same code over and over again in the given: block. This makes sense because several test methods have the same initial state and only a different trigger (the when: block). Instead of copying and pasting this behavior (and thus violating the DRY[6] principle), Spock offers you several facilities to extract common preconditions and post-conditions of tests in their own methods.
This acronym stands for don’t repeat yourself. See https://en.wikipedia.org/wiki/Don’t_repeat_yourself for more information.
In the Spock test that examines your imaginary electronic ...
Read now
Unlock full access