📜  调用 mockito 方法 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:07.354000             🧑  作者: Mango

代码示例3
@Test
public void testDoFoo() {
  Bar bar = mock(Bar.class);
  BarFactory myFactory = new BarFactory() {
    public Bar createBar() { return bar;}
  };

  Foo foo = new Foo(myFactory);
  foo.foo();

  verify(bar, times(1)).someMethod();
}