felangel / mocktail

A mock library for Dart inspired by mockito
https://pub.dev/packages/mocktail
MIT License
588 stars 80 forks source link

Repository.updateItem() Function Throws Null Subtype Exception in Bloc Test Event #225

Closed dipu0 closed 5 months ago

dipu0 commented 5 months ago

Describe the bug When utilizing the bloc test to act an event that triggers the execution of the following code snippet:

bool? isDone = await repository!.updateItem(newList);

where the updateItem function is defined as:

Future<bool?> updateItem(List<entity?> entityList) async {
  // Implementation details...
}

An exception is thrown during execution, specifically: "type 'Null' is not a subtype of type 'Future<bool?>'".

To Reproduce

  1. Invoke the bloc test with the relevant event triggering the code mentioned above.
  2. Observe the execution and the thrown exception.

Expected behavior The updateItem function should handle the provided list (newList), perform its operations, and return a Future<bool?> based on the operation's success or failure.

Actual Behavior The code execution results in an exception: "type 'Null' is not a subtype of type 'Future<bool?>'", which is unexpected and indicates an issue within the function or its invocation.

felangel commented 5 months ago

Hi @dipu0 👋 Can you share a link to a minimal reproduction sample? I’m guessing you’re using a mock bloc and not stubbing updateItem but if your goal is to test the bloc you shouldn’t be mocking it in the first place. Hope that helps!