dart-lang / mockito

Mockito-inspired mock library for Dart
https://pub.dev/packages/mockito
Apache License 2.0
623 stars 160 forks source link

Mockito unable to generate code for records in dart 3.0.0 #664

Closed hwebservices closed 1 year ago

hwebservices commented 1 year ago

I am currently using records in a method and apparently mockito does not generate the code for it in the test case. Below is my method...

Future<(FileModel, Uint8List)> updateHomeImage(
      {File? image, Uint8List? bytes, Uint8List? imageBytes}) async {
    try {
      return kIsWeb
          ? await createImage(imageBytes: imageBytes, category: 'home-picture')
          : await createImage(image: image, category: 'home-picture');
    } on Exception {
      rethrow;
    }
  }

Does mockito supports records? error:

est/cases/providers/home_provider_test.mocks.dart:1541:16: Error: Type 'FileModel' not found.
  _i13.Future<(FileModel, Uint8List)> createImage({
               ^^^^^^^^^
test/cases/providers/home_provider_test.mocks.dart:1541:27: Error: Type 'Uint8List' not found.
  _i13.Future<(FileModel, Uint8List)> createImage({
yanok commented 1 year ago

Mockito does support records starting with version 5.4.2: https://pub.dev/packages/mockito/changelog#542

It looks like you are using an earlier version. BTW, it's always a good idea to add the version info to the bug.

@hwebservices Could you please check it with the latest version and close the bug if it works? Thanks!

hwebservices commented 1 year ago

@yanok Thank you for your response and suggestion, I can confirm it works with version 5.4.2. Closing the issue.