Cool Spock Ignore/IgnoreRest annotations

31 / Aug / 2012 by Amit Jain 0 comments

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 :

  1. @IgnoreRest : Ignores all feature methods not carrying this annotation. Useful for quickly running just a single method.
  2. @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.

~~Amit Jain~~

amit@intelligrape.com

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *