-
Dec 21st, 2009, 06:53 PM
#1
STS 2.3 grails not injecting GORM?
Attempts to test my domain objects fails with:
groovy.lang.MissingMethodException: No signature of method: MyDomainObject.save() is applicable for argument types: () values: []
The test runs (and passes
using "grails test-app" from the CLI
This was on STS 2.2 updated to 2.3, and on a clean install of the 2.3 package, with groovy and grails extension added. (I've tried this with grails production, and grails latest/beta - same result ... I'm keeping the Grails preference setting at Grails 1.1.2). I'm using Linux Fedora 11 x86_64, tried with both groovy 1.6 and 1.7, and with Sun JDK 1.6.0_17 and OpenJDK.
I have this with imported projects I built from the command line, and with a project created using STS' new grails project wizard.
Any idea what silly thing I've done that could cause this?
-
Dec 24th, 2009, 12:03 PM
#2
Hi,
Are you using mockDomain() call in your test to ensure the existence of the save() method - or is it not that kind of test? What source folder is the test in?
Are you able to let me see the actual body of the test that is failing - it may help me recreate the issue.
cheers
Andy
---
Andy Clement
Groovy/Grails
-
Dec 24th, 2009, 01:26 PM
#3
I wasn't sure if I needed to mockDomain (as I do when testing a Service) to unit-test a standalone domain object from the test/unit tree, so I set up a really simple test ...
import grails.test.*
class DummyTests extends GrailsUnitTestCase {
protected void setUp() {
super.setUp()
}
protected void tearDown() {
super.tearDown()
}
void testId() {
def mpe = new Dummy()
assertNotNull mpe
assertNull mpe.id
assertNotNull mpe.save()
assertNotNull mpe.id
}
}
Then when I add mockDomain, it then passes ... thanks for the head-slpa!
protected void setUp() {
mockDomain(Dummy)
}
(The book I was referring to, "Grails Persistence with GORM and GSQL", doesn't show use of mockDomain() so it didn't come to mind...)
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