MissingMethodException when running integration tests

11 views
Skip to first unread message

Dale Lotts

unread,
Sep 20, 2013, 11:46:35 AM9/20/13
to grails-jax...@googlegroups.com
I'm writing some integration tests for by JSON API - the test run fine when run individually, however, the second or subsequent test fails when run together/

The failures are always MissingMethodException's referring to one of the dynamaic methods on a domain class - i.e. .save(), .addTo...(), etc.

I don't know when these methods are added or what about the test could possibly cause this behavior - any suggestions of where to look would be much appreciated.

Sample test that runs fine along but fails with MissingMethodException when run with other integration tests.

class ContactAPITests extends IntegrationTestCase {

    @Test
    void "Create customer with name only"() {
        def headers = ['Content-Type': 'application/json', 'Accept': 'application/json']
        def content = '{"name":"Customer Test"}'
        def expected = '{"id":2,"version":0,"addresses":[],"attributes":[],"companyName":null,"creditCards":[],"emailAddresses":[],"name":"Customer Test","occasions":[],"officeNotes":null,"phoneNumbers":[],"stripeCustomerID":null,"systemType":false}'

        // create new person
        sendRequest('/api/contact', 'POST', headers, content.bytes)


        assertEquals(201, response.status)
        assertEquals(expected, response.contentAsString)
        assertTrue(response.getHeader('Content-Type').startsWith('application/json'))

        // get list of persons
        sendRequest('/api/contact', 'GET', headers)

        assertEquals(200, response.status)
        assertEquals("[${expected}]".toString(), response.contentAsString)
        assertTrue(response.getHeader('Content-Type').startsWith('application/json'))
    }

Dale Lotts

unread,
Sep 20, 2013, 11:59:41 AM9/20/13
to grails-jax...@googlegroups.com
Geez - hard to figure out but easy to fix.

Do not use @TestFor(...) in integration tests. =) Removing this annotation fixed the problem. =)
Reply all
Reply to author
Forward
0 new messages