我想使用 Mockito 验证字符串参数是否满足两个条件:
verify(mockClass).doSomething(Matchers.startsWith("prefix"));
verify(mockClass).doSomething(Matchers.endsWith("suffix"));
如何将这两者合并为一个语句?
这可以使用org.mockito.AdditionalMatchers
:
import static org.mockito.AdditionalMatchers.and;
verify(mockClass).doSomething(
and(Matchers.startsWith("prefix"),
Matchers.endsWith("suffix"));
还有org.mockito.AdditionalMatchers.or
and org.mockito.AdditionalMatchers.not
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)