We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Hello,
I integrated the latest version of Mockito into the saint of one of my apps.
I have a case where I am using Mockito with Flutter's FirebaseFirestore.
Here is my test case:
import 'package:app/models/private_tip_model.dart'; import 'package:app/repositories/private_tips_repository.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; main() { test("Doit permettre de retourer une liste de conseils par ordre de création", () async { // ARRANGE FirebaseFirestoreMock firebase = FirebaseFirestoreMock(); CollectionReferenceMock collectionReferenceMock = CollectionReferenceMock(); QueryMock queryMock = QueryMock(); QuerySnapshotMock querySnapshotMock = QuerySnapshotMock(); QueryDocumentSnapshotMock queryDocumentSnapshotMock = QueryDocumentSnapshotMock(); when(queryDocumentSnapshotMock.id).thenReturn('0987654321'); when(queryDocumentSnapshotMock.data()).thenReturn({ 'title': 'Tips 1', 'content': 'Content 1', 'createdAt': 1234567, }); when(querySnapshotMock.docs).thenReturn([queryDocumentSnapshotMock]); when(queryMock.get()) .thenAnswer((realInvocation) => Future.value(querySnapshotMock)); when(collectionReferenceMock.orderBy( 'createdAt', descending: true, )).thenReturn(queryMock); when(firebase.collection(PrivateTipsRepository.COLLECTION)) .thenReturn(collectionReferenceMock); final PrivateTipsRepository privateTipsRepository = PrivateTipsRepository(firebase); // ACT List<PrivateTipModel> privateTips = await privateTipsRepository.tips; // ASSERT expect(privateTips.length, 1); expect(privateTips[0].uid, '0987654321'); expect(privateTips[0].title, 'Tips 1'); expect(privateTips[0].content, 'Content 1'); expect(privateTips[0].createdAt, 1234567); }); } class FirebaseFirestoreMock extends Mock implements FirebaseFirestore {} // ignore: must_be_immutable class CollectionReferenceMock extends Mock implements CollectionReference {} class QuerySnapshotMock extends Mock implements QuerySnapshot {} class QueryDocumentSnapshotMock extends Mock implements QueryDocumentSnapshot {} class QueryMock extends Mock implements Query {}
Visual studio code shows me the following error on the class FirebaseFirestoreMock:
I understood well in your documentation that it was now necessary to create methods in the mocks.
But even if I create the method used in my test (collection), I still get this error.
Thanks.
The text was updated successfully, but these errors were encountered:
Duplicate of #354
Sorry, something went wrong.
No branches or pull requests
Hello,
I integrated the latest version of Mockito into the saint of one of my apps.
I have a case where I am using Mockito with Flutter's FirebaseFirestore.
Here is my test case:
Visual studio code shows me the following error on the class FirebaseFirestoreMock:
I understood well in your documentation that it was now necessary to create methods in the mocks.
But even if I create the method used in my test (collection), I still get this error.
Thanks.
The text was updated successfully, but these errors were encountered: