class MyTests extends ControllerUnitTestCase {
def securityMock
def controller
protected void setUp() {
super.setUp()
securityMock = mockFor(SecurityUtils)
securityMock.demand.static.getSubject{-> [isAuthenticated:{false}] as Subject}
controller = MyController()
}
void testOne() {
controller.myAction()
}
void testTwo() {
controller.myAction()
}
}
This is related to callsite caching. Graeme reported this bug http://jira.codehaus.org/browse/GROOVY-3433
and using the Groovy 1.6.1 jar fixes this problem too. Note that because of hard-coded jar names, you need to rename groovy-all-1.6.1.jar to groovy-all-1.6.0.jar in $GRAILS_HOME/lib