I'm using the ExpandoMetaClass to make a service always return success in an integration test but I would like to have one test that actually fails.
Example use of ExpandoMetaClass:
static {
ExpandoMetaClass someService = new ExpandoMetaClass(Object, false)
someService.accessAnotherSystem = { return 'success' }
someService.initialize()
SomeService.metaClass = someService
}
Note: currently the service isn't defined for the controller but since it's a spring bean referencing the class named SomeService
like someService.accessAnotherSystem()
works just fine i.e. there is no def someService
in the controller.
Therefore I can't do controller.someService.metaClass.accessAnotherSystem = { return 'failure'}
from the integration test.
Also note: this is an integration test for a webflow.
Is it possible to reset the metaClass for one test, or in someway test what I want?