Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

junit.framework.AssertionFailedError: No more calls to 'scp' expected at this point. End of demands.

Tags:

grails

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.

like image 966
alscu Avatar asked Dec 17 '13 17:12

alscu


1 Answers

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.

like image 89
alscu Avatar answered Oct 13 '22 20:10

alscu