unit testing - Understanding metaClass in Grails tests -


i'm learning grails, , working through the guide on testing.

there's example provided covers writing test piece of code in fictional bookcontroller:

def show = {     [ book : book.get( params.id ) ] } 

the guide suggests following approach mocking out result of params.id:

void testa() {     bookcontroller.metaclass.getparams = {-> [id:10] } } 

as change on static definition of bookcontroller, persist between tests, or grails magic somehow automatically clean in teardown method?

ie, if write subsequent test skipped setup of metaclass.getparams , ran after testa, params.id still return 10?

if so, what's standard grails practice cleaning in test tear-down? doesn't seem covered in guide i'm reading.

you're using ancient version of docs covering 1.0.x. testing support lot more solid now, see updated chapter 9 in http://grails.org/doc/latest/


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -