Files
firebase-ios-sdk/FirebaseTestingSupport/README.md
T
Maksym Malyhin c9c03467ff Prototype of a module with Firestore fakes for testing dependent code in Swift (#7668)
* Firestore testing support prototype

* SwiftPM target

* Comments and formatting

* Move FirebaseFirestoreTestingSupport.podspec to subfolder

* Swift PM updated

* Headers location and imports

* Podspec version update

* Brief readme

* Swift PM FirestoreTestingSupportTests target added

* Formatting

* Move FirebaseFirestoreTestingSupport.podspec back to root

* README updates

* Cleanup podspec

* README
2021-03-09 14:32:33 -05:00

53 lines
1.4 KiB
Markdown

# 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](../FirebaseTestingSupport/Firestore/Tests/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.