Embedded Cloud Firestore client, to be used in unit testing Firestore.
This library simulates the features from Firestore
, allowing you to write Unit Tests without mocking every single function from Firestore
.
This might not be as precise as the real Firestore, but will come close enough for most usages.
Add this line to your build.gradle
dependencies, and you should be good to go!
testImplementation("top.colman.embeddedfirestore:embedded-firestore:${version}")
Embedded Firestore usage is pretty simple.
val client: Firestore = EmbeddedFirestore().createClient {
// Optional: Start a collection
createCollection("MyCollectionId") {
// Optional: Start some documents
createDocument("MyDocumentId", myPojo)
createDocument("MyOtherDocumentId", myDocumentMap)
}
}
val myTarget = MyClassThatUsesFirestore(client)
This library is in a very early state. I just hacked around until my use case was met, and tried to make it at least usable for simpler cases.
If you believe that you can help me improve the features of this library, please feel free to make a pull request or open an issue!