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'))
}
}