假设我有一个方法正在进行单元测试
class MyClass {
private Foo foo;
public void myMethod(String arg1, String arg2) {
foo.bar(arg1);
foo.bar(arg2);
}
}
并且该测试
def "Playlist with stale channel should get updated upon refresh"() {
when: "myMethod is called with 'a','b'"
MyClass myClass = new MyClass();
myClass.myMethod('a', 'b');
then: "expect that foo('a') is called before foo('b') is called"
/*
How can I do this? I only know how to check that it was called twice.
*/
2 * foo.bar(_) >> null
/*
How could I make an assertion like "foo.bar was called twice, first with 'a' as
the argument, then again with 'b' as the argument?
*/
}
1条答案
按热度按时间xdnvmnnf1#
你应该能做到