Skip to content

🐛 [cloud_firestore] 'Object.==' and Mockito #5288

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

Closed
radvansky-tomas opened this issue Mar 10, 2021 · 6 comments · Fixed by #5443
Closed

🐛 [cloud_firestore] 'Object.==' and Mockito #5288

radvansky-tomas opened this issue Mar 10, 2021 · 6 comments · Fixed by #5443
Labels
plugin: cloud_firestore type: question A question where further information is requested

Comments

@radvansky-tomas
Copy link

I am trying to mock flutter fire plugin using Mockito, however generation fails because of using 'Object.==' inside many flutter fire classes. I reported it to Mockito plugin, however they doubt you should be using it.

Any input from your end ?

dart-lang/mockito#354

@radvansky-tomas radvansky-tomas added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Mar 10, 2021
@markusaksli-nc markusaksli-nc added plugin: cloud_firestore type: question A question where further information is requested and removed type: bug Something isn't working Needs Attention This issue needs maintainer attention. labels Mar 10, 2021
@mockturtl
Copy link
Contributor

This is also relevant to firebase_auth.

With @GenerateMocks([FirebaseAuth]), the code generation succeeds, but the analyzer finds an invalid_implementation_override error in the generated class for FirebaseApp.

# pubspec.yaml
dependencies:
  flutter:
    sdk: flutter  # 2.0.2
  firebase_auth: ^1.0.1

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^1.12.2
  mockito: ^5.0.2
$ dart run build_runner build
// my_test_mocks.dart
// Mocks generated by Mockito 5.0.2 from annotations
// in my_test.dart.
// Do not manually edit this file.
...
class _FakeFirebaseApp extends _i1.Fake implements _i2.FirebaseApp {}
error • 'Object.==' ('bool Function(Object)') isn't a valid concrete implementation of 'FirebaseApp.==' ('bool Function(dynamic)') at ... • (invalid_implementation_override)

dart-lang/mockito#354 (comment)

I suggest opening bugs against those packages, perhaps asking why they expanded the parameter type on the == operator. It may be accidental.

@gmcdowell
Copy link

this is an encouraging nudge to get this addressed ASAP please, given the use of Mockito and Firebase is fundamental and this issue is currently not viewed as a bug

@radvansky-tomas
Copy link
Author

@markusaksli-nc Can you please explain what next ? do you have any remedy/workaround/plan to resolve it ?

@markusaksli-nc
Copy link
Contributor

I'm not really the person to ask for that. It would help if you permalink some code lines where this is an issue (following the recent null-safety updates)

mockturtl added a commit to mockturtl/flutterfire that referenced this issue Mar 23, 2021
@mockturtl
Copy link
Contributor

mockturtl commented Mar 23, 2021

It would help if you permalink some code lines where this is an issue

See link, above. Object's operator == takes an Object parameter. Mockito's question is why flutterfire changes the type to dynamic in its @overrides.

PR incoming.

@gmcdowell
Copy link

gmcdowell commented Mar 24, 2021

@markusaksli-nc given @mockturtl has done as you ask can you provide us with an eta at all?
This is a blocker from out POV and would really appreciate some escalation

Ah I can see movement in the issue, so will park this for time being ;)

rrousselGit pushed a commit that referenced this issue Mar 25, 2021
@firebase firebase locked and limited conversation to collaborators Apr 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
plugin: cloud_firestore type: question A question where further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants