Is it necessary to remove the metaClass after use mockDomain in Grails unit tests?
Posted
by
Arturo Herrero
on Stack Overflow
See other posts from Stack Overflow
or by Arturo Herrero
Published on 2012-03-30T10:50:55Z
Indexed on
2012/03/30
17:30 UTC
Read the original article
Hit count: 287
mockDomain provide a dynamic methods like save()
, validate()
, ... for a domain class.
Is it necessary to remove the meta classes for each class I mock using mockDomain
?
class UserTests extends GrailsUnitTestCase {
protected void setUp()
{
super.setUp()
mockDomain User
mockDomain Address
}
protected void tearDown()
{
super.tearDown()
def remove = GroovySystem.metaClassRegistry.&removeMetaClass
remove User
remove Address
}
}
© Stack Overflow or respective owner