0

In a grails integration test, I have code that resembles this:

def ctrlA = new MyController()
... make some request that returns 'ok' ...
assert ctrlA.response.json.status == 'ok'

def ctrlB = new MyController()
... make some request that returns 'error' ...
assert ctrlB.response.json.status == 'error' // fails; status still equals 'ok'

Problem: Even when ctrlB actually does return a json response that looks like { status: 'error' }, I'm actually seeing { status: 'ok' }, the value that was in ctrlA.response.json!! My logs in the controller indicate that 'error' is most definitely being returned.

Why is this?

tim_yates
  • 167,322
  • 27
  • 342
  • 338
Travis Webb
  • 14,688
  • 7
  • 55
  • 109
  • Hi, Could you post your complete test class? We cannot get any integration tests to work, we always get null responses. – John Little Jan 22 '15 at 10:33
  • Unfortunately I haven't programmed in grails for quite a while now, and I no longer have access to that code. Sorry. – Travis Webb Jan 25 '15 at 05:13

1 Answers1

2

Ah. Don't need the separate ctrlA and ctrlB at all. Just call ctrl.response.reset() in between.

Travis Webb
  • 14,688
  • 7
  • 55
  • 109