You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I'm still having issues when using EquatableMixin from the package Equatable.
I have a class like this:
class AuctionLot {
final int fie;
}
class AuctionLotDetail extends Foo with EquatableMixin{
final int fee;
}
EquatableMixin overrides the equality operator, and Mockito doesn't seem to handle that well:
test/mocks_repository.mocks.dart:53:7: Error: The implementation of '==' in the non-abstract class '_FakeAuctionLotDetail' does not conform to its interface.
class _FakeAuctionLotDetail extends _i1.Fake implements _i5.AuctionLotDetail {}
^^^^^^^^^^^^^^^^^^^^^
org-dartlang-sdk:///third_party/dart/sdk/lib/_internal/vm/lib/object_patch.dart:21:27: Context: The parameter 'other' of the method 'Object.==' has type 'Object', which does not match the corresponding type, 'Object?', in the overridden method, 'AuctionLot with EquatableMixin.=='.
- 'Object' is from 'dart:core'.
Change to a supertype of 'Object?', or, for a covariant parameter, a subtype.
bool operator ==(Object other) native "Object_equals";
^
lib/model/auction_lot_detail.dart:8:7: Context: This is the overridden method ('==').
class AuctionLotDetail extends AuctionLot with EquatableMixin {
^
test/mocks_repository.mocks.dart:101:7: Error: The implementation of '==' in the non-abstract class 'MockAuctionLotDetail' does not conform to its interface.
class MockAuctionLotDetail extends _i1.Mock implements _i5.AuctionLotDetail {
^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter_2.0.6/.pub-cache/hosted/pub.dartlang.org/mockito-5.0.10/lib/src/mock.dart:196:20: Context: The parameter 'other' of the method 'Mock.==' has type 'Object', which does not match the corresponding type, 'Object?', in the overridden method, 'AuctionLot with EquatableMixin.=='.
- 'Object' is from 'dart:core'.
Change to a supertype of 'Object?', or, for a covariant parameter, a subtype.
The generated Fakes:
class _FakeAuctionLotDetail extends _i1.Fake implements _i4.AuctionLotDetail {}
The generated Mock:
/// A class which mocks [AuctionLotDetail].
///
/// See the documentation for Mockito's code generation for more information.
class MockAuctionLotDetail extends _i1.Mock implements _i5.AuctionLotDetail {
MockAuctionLotDetail() {
_i1.throwOnMissingStub(this);
}
[.. all the prop overrides omitted for brevity]
@override
String toString() => super.toString();
}
The text was updated successfully, but these errors were encountered:
The workaround is to upgrade to equatable 2.0.3 which uses non-nullable Object as the parameter to ==.
srawlins
added
P3
A lower priority bug or feature request
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
labels
Jul 2, 2021
I am using Mockito 5.0.10, and I do have read about various fixes regarding operators override:
However, I'm still having issues when using
EquatableMixin
from the package Equatable.I have a class like this:
EquatableMixin overrides the equality operator, and Mockito doesn't seem to handle that well:
The generated Fakes:
class _FakeAuctionLotDetail extends _i1.Fake implements _i4.AuctionLotDetail {}
The generated Mock:
The text was updated successfully, but these errors were encountered: