如何验证一个方法是否被对象的依赖项没有调用?
例如:
public interface Dependency {void someMethod();}
public class Foo {public bar(final Dependency d) {...}}
通过Foo测试:
public class FooTest {@Testpublic void dependencyIsNotCalled() {final Foo foo = new Foo(...);final Dependency dependency = mock(Dependency.class);foo.bar(dependency);**// verify here that someMethod was not called??**}}