문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

when and then, among others, seem to be documented here.

Technically the then, when and a few other constructs in Spock are good old labels (aka goto), which developers rarely use these days. Spock uses them to allow developers to logically and visually separate different aspects of their tests - assumptions, constraints, statements or data. The Spock compile-time AST transformations than use the labels to understand the structure of the test and do its magic.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top