Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xIa066 opened this issue Sep 18, 2024 · 0 comments

Comments

@xIa066
Copy link

xIa066 commented Sep 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant