Closed havenqi closed 5 years ago
How are you configuring the server
itself? Are you sure it is being cleaned up between tests? Something like:
@AutoCleanup
private final ErsatzServer ersatzServer = new ErsatzServer()
If not, this could cause the extra expectations, since they are not being cleaned out in a reused server.
Also, just FYI, calling expectations
calls start()
unless autoStart false
is specified, so your explicit start()
call is not needed.
Well, seeing the code in your other issue, it appears you are cleaning things up as you should, perhaps I broke something in the recent update. I will take a look.
As a temporary fix, try adding the following to your test class:
def cleanup(){
server.clearExpectations()
}
This will clear out the expectations between tests, as it should.
Thanks for reporting.
It appears that this is directly related to your other issue #107 - when the Groovy closure variable resolution gets confused it does some odd things. The response body DSL method calls the request body object in this case which creates another request expectation. I am going to close this issue and address both in the other ticket.
It's good to see the details of the expectation logs. But I'm confused with expectation 0, and 1, because the test only has expecation 2 configured. Could you explain more? Thanks.