5
我沿着这些线路测试:如何验证与Specs2特定字符串的匹配invokations用的Mockito
httpClient.post(anyString, anyString) returns (first, second)
//do my thing
there were two(httpClient).post(anyString, anyString)
这工作得很好,但我想验证第一个呼叫通过不同的身体比第二个电话。身体比较大,我不想在一个严格的例子上做精确的匹配。我已经试过这样:
there was one(httpClientMock).postMessage(anyString, argThat(contain("FOO"))
there was one(httpClientMock).postMessage(anyString, argThat(contain("FOO"))
这使得抱怨的Mockito:
InvalidUseOfMatchersException:
[error] Invalid use of argument matchers!
[error] 2 matchers expected, 3 recorded:
我也试过:
there was one(httpClientMock).postMessage(argThat(contain("foo")), argThat(contain("FOO")))
there was one(httpClientMock).postMessage(argThat(contain("foo")), argThat(contain("FOO")))
导致:
Wanted 1 time:
[error] -> ...
[error] But was 2 times. Undesired invocation: ...
它在我看来,像这样的东西应该是possi可是,我似乎无法弄清楚。见解?
我从来没有怀疑,这是可能的。与往常一样,我很高兴我问:) – iwein 2013-03-02 19:40:06
它引发了一个问题,应该有一个替代Mockito for Scala? – iwein 2013-03-02 19:41:25
还有一个选择:http://scalamock.org。但是也许你可以在Mockito邮件列表上询问这是否是一个错误。在这种情况下,他们可能会修复它。 – Eric 2013-03-02 23:08:35