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.
模拟方法时有没有办法接受任意数量的参数?
例如,如果我想模拟这两种方法:
foo(String s); foo(String s, int i);
现在,在我的测试中,我做了:
myMockedClass.foo(_) >> x myMockedClass.foo(_, _) >> x
有没有办法同时模拟两者?就像是:
myMockedClass.foo(*) >> x
(这不起作用)
此功能已计划,但尚不存在。建议的语法是foo.bar(*_).
foo.bar(*_)