我得到了上课的方法
interface Class1{
void method1(SomeObject... parameters);
}
我有一个自定义的 Hamcrest 匹配器
public class SomeObjectMatcher extends BaseMatcher<SomeObject>{...}
如何编写与传递给方法1的对象匹配的期望
SomeObject someObject = new SomeObject(...);
...
mockery.checking(new Expectations(){{
oneOf(class1).method1(with(new SomeObjectMatcher(someObject1)));
}}
实际调用是
class1.method1(someObject);
传递的对象和预期的一样,但是SomeObjectMatcher失败了,因为实际传递的参数不是someObject1,而是SomeObject[]{someObject1}(只有一个对象的数组-someObject1)?有没有办法在链中添加一个新的匹配器,比如
oneOf(class1).method1(with(arrayHas(new SomeObjectMatcher(someObject1))));