concept old ( ) method in category java

appears as: old() method, The old() method
Java Testing with Spock

This is an excerpt from Manning's book Java Testing with Spock.

4.3.4. Use of the old() method

The old() method of Spock is a cool trick, but I’ve yet to find a real example that makes it worthwhile. I mention it here for completeness, and because if you don’t know how it works, you might think it breaks the Spock lifecycle principles. You use it when you want your test to capture the difference from the previous state instead of the absolute value, as shown in the following listing.

Listing 4.23. Asserting with the old() method