Grails version 2.0 and above made unit testing much simpler with so many new annotations introduced. However if you wanted to mock a specific method of a class whose method is being tested or you wanted to create a stub of the class already annotated by @Mock, things would become difficult. So I always ended up […]
As we all know that groovy is a dynamic programming language, so we can add any method to any class at runtime. First, let’s see a small and simple example of metaProgamming given below, in which we are adding a method (isEvent) into an Integer class. [groovy] Integer.metaClass.isEven = { -> // only (->) sign […]
In Groovy you can use “()” with any object which in turn is same as calling call() method on that object. You can write code which are more human readable using this groovy feature. This is somewhat overriding “()” operator. The blog adds Microsoft VB array access like syntax to Java List.