Instrumentation Testing with Firebase

571 views
Skip to first unread message

Kylan Johnson

unread,
Sep 5, 2016, 4:27:43 PM9/5/16
to Firebase Google Group
I'm looking for a mock implementation of the Firebase server so I can write a few Instrumentation tests cases in Android without involving the network?  Does anyone know of any implementation or is Google planning to release a mocked implementation?

I've seen the posts suggesting the usage of dev, qa, staging, prod variants to keep things separate.  However this seems to skirt the issue that a network is involved in instrumentation testing.  (not ideal).

Any pointers in this matter would be awesome.  

Thanks!

Kylan

Jacob Wenger

unread,
Sep 5, 2016, 5:19:38 PM9/5/16
to fireba...@googlegroups.com
Hey Kylan,

There is no official mock version of Firebase, although there are some third-party versions like MockFirebase and firebase-server, although I cannot guarantee those are up-to-date. If you are just using the Realtime Database, one thing you can do is call goOffline() at the beginning of your tests. This will block all network activity, but local events will still fire due to latency compensation. This has limitations (e.g. Security Rules aren't enforced and transactions don't work outline), but may work depending on your use case.

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/cba97999-ecb7-4ead-88b3-9f962b580a73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Doug Stevenson

unread,
Sep 5, 2016, 5:29:20 PM9/5/16
to Firebase Google Group
The Android version of go offline is here.

Kylan, if that doesn't satisfy your needs, can you say a little bit more about what you would expect a mocked Firebase to behave like?  Are you talking about a completely different version of the client library that never connects to a database and allows you to trigger database events programmatically?  You can mostly do those things while in an offline state.  You could also fully mock (in the unit testing sense of the word) and inject all of the objects that come from the client library for complete control.

Doug


On Monday, September 5, 2016 at 2:19:38 PM UTC-7, Jacob Wenger wrote:
Hey Kylan,

There is no official mock version of Firebase, although there are some third-party versions like MockFirebase and firebase-server, although I cannot guarantee those are up-to-date. If you are just using the Realtime Database, one thing you can do is call goOffline() at the beginning of your tests. This will block all network activity, but local events will still fire due to latency compensation. This has limitations (e.g. Security Rules aren't enforced and transactions don't work outline), but may work depending on your use case.

Cheers,
Jacob
On Mon, Sep 5, 2016 at 9:24 AM, Kylan Johnson <k.john...@gmail.com> wrote:
I'm looking for a mock implementation of the Firebase server so I can write a few Instrumentation tests cases in Android without involving the network?  Does anyone know of any implementation or is Google planning to release a mocked implementation?

I've seen the posts suggesting the usage of dev, qa, staging, prod variants to keep things separate.  However this seems to skirt the issue that a network is involved in instrumentation testing.  (not ideal).

Any pointers in this matter would be awesome.  

Thanks!

Kylan

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

Adam Zell

unread,
Sep 5, 2016, 8:21:08 PM9/5/16
to Firebase Google Group
Hello,

I have used https://github.com/urish/firebase-server for local testing with a Java client.  Sample integration at https://github.com/azell/quasar-firebase.  I would recommend looking at the test files in the integration project for how to spin up the local firebase server with pre-set data and rules.
Reply all
Reply to author
Forward
0 new messages