Describe the bug
When you have multiple positional parameters of the same (nullable) Type in your mocked Method, you cannot verify that one positional parameter is null and others are any().
To Reproduce
Steps to reproduce the behavior:
This Test will fail, but from my point of view it should not:
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
class MockListener extends Mock {
void call(int? previous, int next);
}
void main() {
late MockListener listener;
setUp(() {
listener = MockListener();
registerFallbackValue(1);
});
test('verify listener is called with any()', () {
// Arrange
final previousInt = null;
final nextInt = 3;
// Act
listener(previousInt, nextInt);
// Assert
verify(() => listener(null, any())).called(1);
});
}
Expected behavior
Tests like this should not fail
Additional context
In _is_invocation.dart, there is this line of code in _reconstitutePositionalArgs:
if (positionalArgument == null || positionalArgument == arg._fallbackValue)
shouldn't the first check be removed? i did this and all tests are still successful.
easy workaround of course is to also use a matcher for the first positional argument, so
verify(() => listener(any(that: isNull), any())).called(1);
will work
Describe the bug
When you have multiple positional parameters of the same (nullable) Type in your mocked Method, you cannot verify that one positional parameter is null and others are any().
To Reproduce
Steps to reproduce the behavior:
This Test will fail, but from my point of view it should not:
Expected behavior
Tests like this should not fail
Additional context
In _is_invocation.dart, there is this line of code in _reconstitutePositionalArgs:
if (positionalArgument == null || positionalArgument == arg._fallbackValue)shouldn't the first check be removed? i did this and all tests are still successful.
easy workaround of course is to also use a matcher for the first positional argument, so
verify(() => listener(any(that: isNull), any())).called(1);will work