How to access, stub and mock inner class methods defined within a groovy script

258 views Asked by At

I have a groovy script in which i have defined and use a small dsl (as an inner class). To test my script i want to mock the dsls behavior (static methods of the inner class). How is it possible to get access to the inner class representing the dsl if i have access to the class representing the script.

def class SomeDSL{
                   //instance variables
                   //instance methods
                   //static methods
}
//other script methods
//script code

Lets say the above is the body of the script call foo_bar.groovy. I use GroovyClassLoader to parse and compile the script. The class object that i get is call foo_bar.class. Now am trying to get the a class representing this SomeDSL so that i can mock its methods. Please let me know if there is a way to get it.

0

There are 0 answers