RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.81k stars 406 forks source link

Testing with Espresso #282

Closed sevar83 closed 5 years ago

sevar83 commented 5 years ago

Hi, we've successfully used Fotoapparat in an interesting OCR-related project. It's absolutely kick-ass. But now our QA team wish to write automated integration tests with Espresso and need to stub the result photo. Any advice how to mock the camera cleanly and properly? I prefer to not mock Fotoapparat but the underlying camera.

Diolor commented 5 years ago

Hi and thanks for your kind words. My two cents on testing:

I think if you mock FA and the returning result will be sufficient for you. Let me explain: If you mock the vanilla camera API then you will also test FA. In practice it's our responsibility to test FA here, so it might be unnecessary work from you. If you mock FA you will approach it as a "stable API black box" and only test your logic, which is what matters there.

If you still want to mock the Android camera API then you have to read the FA source code and mock all the points FA touches the Android camera API

sevar83 commented 5 years ago

Thanks for the advice, totally makes sense! When the times comes we will either mock the photo results stream or create a mock web camera in Jenkins. Whatever is better for the QA guys.