Results 1 to 3 of 3

Thread: STS 2.3 grails not injecting GORM?

  1. #1
    Join Date
    Dec 2009
    Posts
    6

    Default 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?

  2. #2
    Join Date
    May 2009
    Location
    Vancouver
    Posts
    274

    Default

    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

  3. #3
    Join Date
    Dec 2009
    Posts
    6

    Default

    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
  •