📜  mockito 模拟静态方法 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:23.933000             🧑  作者: 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();
}