Skip to content

Unit test firestore: Mocking DocumentReference and CollectionReference #3263

Description

@einevea

We are trying to test classes with dependencies on firestore and we found we cannot mock these classes because their constructors are internal. Is it possible if the following methods return interfaces instead of classes:

val collectionReference:CollectionReference = db.collection(collectionName)
val document: DocumentReference = collectionReference.document(docId)

Activity

  1. schmidt-sebastian commented on May 16, 2018

    @schmidt-sebastian
    Contributor

    Thanks for sending this over. I filed an internal issue and will update you as we make progress.

  2. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    status: blockedResolving the issue is dependent on other work.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    api: firestoreIssues related to the Firestore API.
    and removed
    triage meI really want to be triaged.
    🚨 criticalP0 critical issue. Requires immediate fix
    on Jun 11, 2018
  3. mustafaakin commented on Jul 11, 2018

    @mustafaakin

    We need them too for unit testing purposes

  4. abchugh commented on Aug 8, 2019

    @abchugh

    Looks like the constructor of CollectionReference was missed in the fix

  5. schmidt-sebastian commented on Aug 8, 2019

    @schmidt-sebastian
    Contributor

    Follow up PR: #6054

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: firestoreIssues related to the Firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.status: blockedResolving the issue is dependent on other work.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions