Make verifyInOrder fail given non-mock-calls.
Also adds a test for verify failing when given a non-mock call.
diff --git a/lib/src/mock.dart b/lib/src/mock.dart
index 4142f1f..44bec84 100644
--- a/lib/src/mock.dart
+++ b/lib/src/mock.dart
@@ -997,7 +997,10 @@
throw StateError(_verifyCalls.join());
}
_verificationInProgress = true;
- return <T>(List<T> _) {
+ return <T>(List<T> responses) {
+ if (responses.length != _verifyCalls.length) {
+ fail('Used on a non-mockito object');
+ }
_verificationInProgress = false;
var verificationResults = <VerificationResult>[];
var time = DateTime.fromMillisecondsSinceEpoch(0);
diff --git a/test/verify_test.dart b/test/verify_test.dart
index 59c2575..659fe07 100644
--- a/test/verify_test.dart
+++ b/test/verify_test.dart
@@ -206,6 +206,12 @@
'2 verify calls have been stored.')));
}
});
+
+ test('should fail when called with non-mock-call parameter', () {
+ expectFail('Used on a non-mockito object', () {
+ verifyInOrder(['a string is not a mock call']);
+ });
+ });
});
group('verify should fail when no matching call is found', () {
@@ -457,6 +463,12 @@
});
});
+ test('should fail when given non-mock-call parameters', () {
+ expectFail('Used on a non-mockito object', () {
+ verifyInOrder(['a string is not a mock call']);
+ });
+ });
+
test('verify been used as an argument fails', () {
mock.methodWithoutArgs();
mock.getter;