Skip to content

Need Assistance with Referencing Dummy Values Provided to provideDummy() in Mockito Tests #770

Open
@zexi-liu7

Description

@zexi-liu7

I want to test method1 to verify that its retry functionality works correctly. In my system, the only way to trigger the retry is by invoking failure.onRetry(). Could you help me reference this failure in my test code so that I can call failure.onRetry() properly?

Here’s the code snippet for context:

test(
   'test method1',
   () async {
     MissingFieldFailure failure = MissingFieldFailure(
       fields: [],
       onRetry: service.method1(), // This is where the retry is triggered
       origin: 'test',
       package: 'test',
     );

   // Ignore the dummy rule for now
   provideDummy<Result<ApiResponseEntity>>(failure);

   await service.method1();

   await expectLater(
     service.method1(),
     emits(isA<MissingFieldFailure>()),
   );
 },
);

In the test, I’m setting up a MissingFieldFailure instance with an onRetry callback that is supposed to call service.method1(). However, I need a way to ensure that the retry is properly tested by referencing this failure and invoking failure.onRetry() in my test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions