Search code examples
groovyjvm-languages

Use of When and Then in Groovy?


I have been seeing the use of "when" and "then" keyword in Groovy in several Groovy articles. One of them is here. I searched for the Groovy Doc's but I couldn't find it. So whats the actual purposes of these keyword's? Similar to if/then?


Solution

  • They aren't groovy keywords; they're actually constructs provided by some popular test frameworks. It looks like easyb and spock both use when and then.

    In both cases, the test frameworks create a test specification DSL that looks human readable.