2 Sep 22:03
[groovy-user] Mocking
From: Alexandre Poitras <apoitras@...>
Subject: [groovy-user] Mocking
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-09-02 20:05:21 GMT
Subject: [groovy-user] Mocking
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-09-02 20:05:21 GMT
Hi
We are using Grails on a project and I was wondering how do you guys mock Grails static methods in Groovy? We used to use the object metaClass property to inject the desired behaviour in a collaborator but unfortunately we quickly found out it wasn't a great idea since all changes made throught the metaClass are global and not local to the test. This can cause a lot of side effects on subsequent tests as we have experienced.
Right now, I'm thinking of hiding all these methods behind a repository interface as we are used to do in Java. It may requires some boilerplate code but at least it is testable.
Am I missing something? Any suggestions?
Alexandre Poitras
We are using Grails on a project and I was wondering how do you guys mock Grails static methods in Groovy? We used to use the object metaClass property to inject the desired behaviour in a collaborator but unfortunately we quickly found out it wasn't a great idea since all changes made throught the metaClass are global and not local to the test. This can cause a lot of side effects on subsequent tests as we have experienced.
Right now, I'm thinking of hiding all these methods behind a repository interface as we are used to do in Java. It may requires some boilerplate code but at least it is testable.
Am I missing something? Any suggestions?
Alexandre Poitras
RSS Feed