While writing a test case, we are generally interested in executing only the one we are working on. With JUnit test case in grails we could say “grails test-app <ClassName>.<currentTestCase>”. However it doesn’t work with spock specification’s.
Spock framework provides multiple cool annotations, following two annotations can be used to speed up writing/executing test case in question :
- @IgnoreRest : Ignores all feature methods not carrying this annotation. Useful for quickly running just a single method.
- @Ignore : Ignores a feature method.
So while writing specification I prefer @IgnoreRest instead of giving even the class name to be tested and remove it later once I am done with the specification. Similarly If there is a specification that takes good time to execute and doesn’t need to be tested right now, we can annotate it with @Ignore, to save some time.