Mockito reset call count?

Viewed 1382

I am effectively calling a method of a mocked class 3 times in a test but when I assert that the call was method 3 times, the test fail. The actual call count is down to 1 according to the result from 2. How does mockito counts calls ?

import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
class RealService {
  doSomething(){

  }
}
class MockService extends Mock implements RealService{}
void main() {
  test('Mockito callcount 3 times',(){
    final mock = MockService();
    mock.doSomething();
    mock.doSomething();
    verify(mock.doSomething()).called(2);
    // now calling a third time again
    mock.doSomething();
    verify(mock.doSomething()).called(3);
  });
}

My background is from sinon in Node

Expected: <3>
  Actual: <1>
Unexpected number of calls
2 Answers

Mockito has a reset function that does exactly this.

Related