In tests i need to override function of some domain class, like this
SomeDomain.countBySomeField(Paramater)
To solve this i tried
@Mock([SomeDomain])
class SomeDomainTests ...
...
void test() {
SomeDomain.metaClass.static.countBySomeField = { -> 1}
}
But when this method invoke in controller(that was invoked by test), what i expet not happen. Probably, you say go read documentation, but i didnt find someting that will tell me how to do this. I will be grateful for any article or example that can say me where im wrong.
I solve my problem by doing this