mockito determine whether method was called

mockito determine whether method was called
@Test
public void testDoFoo() {
  Bar bar = mock(Bar.class);
  BarFactory myFactory = new BarFactory() {
    public Bar createBar() { return bar;}
  };

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

  verify(bar, times(1)).someMethod();
}
Source:‮ww‬w.lautturi.com
Created Time:2017-10-04 23:59:44  Author:lautturi