Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我编写了一个自定义 jmock 操作,它只存储了一个复杂的 bean,然后我使用传统的 JUnit 断言来验证它。
JMock 期望中是否有一种直接的方法来断言从传递给模拟接口函数的对象上调用的几个 getter 返回的值?
我不确定这是否符合 JMock 设计的原则。作为记录,您可以将单个对象的多个匹配器与allOf()
allOf()
oneOf(foo).wasCalled(with(allOf(hasProperty("bar", equalTo(1)), hasProperty("fizz", stringContains("buzz"))));
这有点难看,所以我通常将期望的构造打包在一个辅助方法中