As a newer developer, one of the issues I anticipate with the way things are setup is the chaining of method calls. The timesExactly() call will likely be forgotten at some point, and without compiler support for Apex, the mock won't be setup correctly and test could accidentally pass.
This signature style forces the developer to explicitly state how many times the method should be called and there will be a compilation error if no Times argument is given.
@Thieveryshoe Thanks for the feedback. I've made a change to address this. Will think about it some more before merging with master. Let me know your thoughts
As a newer developer, one of the issues I anticipate with the way things are setup is the chaining of method calls. The
timesExactly()
call will likely be forgotten at some point, and without compiler support for Apex, the mock won't be setup correctly and test could accidentally pass.mock.assertThat().method(mockedMethodName).wasCalled(2).timesExactly();
I propose that some sort of
Times
object be used, and be a required argument in thewasCalled()
method.mock.assertThat().method(mockedMethodName).wasCalled(Times.Exactly, 1);
mock.assertThat().method(mockedMethodName).wasCalled(Times.LessThan, 2);
mock.assertThat().method(mockedMethodName).wasCalled(Times.MoreThan, 1);
This signature style forces the developer to explicitly state how many times the method should be called and there will be a compilation error if no Times argument is given.