Re: mockDomain method missing 1.4.0M1 ??

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: mockDomain method missing 1.4.0M1 ??

Roshan Dawrani
Please add @Mock(TextQuestion) annotation to your test class.

Grails compiler then sees that you want to mock a domain class and weaves in mockDomain() methods to that particular test class.

Cheers.

On Tue, Dec 20, 2011 at 1:00 PM, Bobby Mantoni <[hidden email]> wrote:

No signature of method: idxdemosites.feedback.QuestionnaireControllerTests.mockDomain() is applicable for argument types: (java.lang.Class) values: [class idxdemosites.feedback.User] Possible solutions: mockCodec(java.lang.Class), mockFor(java.lang.Class)

groovy.lang.MissingMethodException: No signature of method: idxdemosites.feedback.QuestionnaireControllerTests.mockDomain() is applicable for argument types: (java.lang.Class) values: [class idxdemosites.feedback.User]
Possible solutions: mockCodec(java.lang.Class), mockFor(java.lang.Class)
	at idxdemosites.feedback.QuestionnaireControllerTests.testSubmitFeedback(QuestionnaireControllerTests.groovy:15)
TEST:
@TestFor(QuestionnaireController)
class QuestionnaireControllerTests {

    void testSubmitFeedback() {
mockDomain(TextQuestion, [new TextQuestion(id:2, questionText:'Question?')])...
TextQuestion is a simple domain object.  Has mockDomain been removed or something?
If I fully-qualify with grails.test.MockUtils.mockDomain(User), I don't get the error, but the mocking then doesn't seem to work (or maybe that's just something else).. Am I using this properly?  I'm trying to add the mock instance, the controller queries for it by id, then I want to verify it got saved by doing a count() or findAll() back in the test.
Thanks



--
Roshan