I'm using groovy 1.7.8.
I have the following code:
public class StaticClass {
public static String getStaticString(String string) {
return "NOT WORKING"
}
}
My test:
void testStaticMethod() {
StaticClass.metaClass.'static'.getStaticString = { i ->
"WORKING"
}
assert "WORKING" == StaticClass.getStaticString('test')
}
I can not get my test to pass. Any ideas on what I'm doing wrong?
Try typing the closure:
StaticClass.metaClass.'static'.getStaticString = { String i ->
"WORKING"
}
You need to match the method signature exactly if you're trying to override something.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With