Doing an integration test in grails 1.3.7, I was mocking a method called 'scp', and the following exception occured: junit.framework.AssertionFailedError: No more calls to 'scp' expected at this point. End of demands.
'scp' was being called twice. The first time it worked, the second one it throwed the exception.
When you mock a method, you can specify a range which indicates how many times you can call the method. Taken from the documentation:
You then specify the name of the method that you want to mock with an optional range as its argument. This range determines how many times you expect the method to be called, so if the number of invocations falls outside of that range (either too few or too many) then an assertion error will be thrown. If no range is specified, a default of "1..1" is assumed, i.e. that the method must be called exactly once.
control.demand.scp(2..2){ file, todir, verb, pass -> return "" }
I couldn't find the reason for this error, so I hope this helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With