views:

40

answers:

3

Is this possible? I tried with EasyMock.expectLastCall().times(0); but EasyMock complains that times must be >=1

A: 

Looks like a bug to me. The internal class Range does not allow to set a maximum less than 1.

Couldn't you mock that method, and just call Assert.fail() ?

Christian Strempfer
yes, I did it that way eventually, see my answer
nkr1pt
A: 

I managed to come up with a solution:

expectLastCall().andAnswer(new IAnswer() {
    public Object answer() {
        Assert.assertFail();
        return null;
    }
});
nkr1pt
A: 

If you expect your method not to be called then just don't record it. But I agree it won't work with a nice mock.

Henri Tremblay