Files
firebase-ios-sdk/FirebaseTestingSupport
Nick Cooke 9d986c8c83 [Firestore] Change Firestore's release distro from source to binary for SPM (#11066)
* Point package dependency on Abseil to new binary repo

* Point package dependency on gRPC to new binary repo

* Define Firestore as a binary target

* Add 'Unreleased' changelog entry

* Checkpoint: everything wired up

* Point to G hosted URL

* Touch all CI

* Style

* Revert "Touch all CI"

This reverts commit 44eed9299aa5fcf1856f0a7bc884a6665a7d051a.

* [will revert] touch Firestore CI

* Fix swift-test target

* Fix FirestoreTestingSupportTests

* Favor FirebaseFirestoreTarget over FirebaseFirestore

* Favor FirebaseFirestoreTarget over FirebaseFirestore (2)

* Revert "[will revert] touch Firestore CI"

This reverts commit e0449ff49085b46975930bc7c282df5c1f282625.

* Update gRPC version

* Update changelog entry version

* Point to latest Firestore RC
2023-04-05 13:00:02 -04:00
..

Firebase Testing Support (for automated test developers)

Firebase Testing Support is a collection of libraries that provide type definitions and tools required for writing tests for code that uses Firebase, e.g.:

  • Instances of types like Query cannot be created with a simple constructor which makes unit testing of the code that depends on them difficult/impossible. Firestore Testing Support lib provides a type QueryFake that can be instantiated and used instead of actual Query instances in the tests.

Usage

Add dependency to your test target

Cocoapods

tests.dependency 'FirebaseFirestoreTestingSupport', '~> 1.0'

Swift Package Manager

dependencies: [
    ...
    "FirebaseFirestoreTestingSupport"
],

Use the fake types in the tests instead of real types

See test for example, e.g. QueryFakeTests.swift.

Development

Generate project

Cocoapods

E.g. for FirebaseFirestoreTestingSupport run the following command for the root repo directory:

pod gen --auto-open --local-sources=./ FirebaseFirestoreTestingSupport.podspec --platforms=ios

Swift Package Manager

  • Open the main package definition:
xed Package.swift
  • Select (or add if not exists yet) a scheme for the test target, e.g. FirestoreTestingSupportTests

  • make required modifications and run tests as needed.