-
Apr 7th, 2010, 12:37 PM
#1
MissingMethodException exception when running Grails tests in STS
Hello,
I am new to both Grails and STS/Eclipse. I am getting the following MissingMethodException with the following message when I attempt to run a very simple integration test by right clicking on the test class and selecting Run As > Junit Test from the menu:
groovy.lang.MissingMethodException: No signature of method: test.User.save() is applicable for argument types: () values: []
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter. unwrap(ScriptBytecodeAdapter.java:54)
at org.codehaus.groovy.runtime.callsite.PogoMetaClass Site.call(PogoMetaClassSite.java:51)
at org.codehaus.groovy.runtime.callsite.CallSiteArray .defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallS ite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallS ite.call(AbstractCallSite.java:121)
...
The domain class that I am trying to test looks like this:
<code>
package test
class User {
String userId;
String password;
String homepage;
Date dateCreated;
static constraints = {
}
}
</code>
My integration test looks like this:
<code>package test
import grails.test.*
class UserIntegrationTests extends GrailsUnitTestCase {
void testSaveInitialUser() {
def user = new User(userId: 'hello', password: 'secret', homepage: 'http://www.world.com');
assertNotNull user.save();
assertNotNull user.id;
User foundUser = User.get(user.id);
assertEquals(foundUser.userId, foundUser.userId);
}
}
</code>
The project containing the code listed above was created using the Grails project wizard provided by STS. I'm using STS version 2.3.2 with Grails v.1.2.2.
The test passes when i run it using the test-app command on the grails command prompt.
Any help would be greatly appreciated!
Thanks in advance
Alex
-
Apr 9th, 2010, 10:27 AM
#2
Hi Alex,
Don't you need to use mockDomain() before the save method comes into existence for those kinds of test? (of course, that doesn't quite explain why it is different when run through test-app...).
Andy
---
Andy Clement
SpringSource
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules