I just want to know whether it is possible to unit test android audio recorder app using the Robolectric framework.
As far as I know, Robolectric does not use the emulator or real device for testing. But in audio recording app, I need to test whether audio is getting recorded? Does it get stored at the specified location on SD card? Does it get played using the media player? and many other scenarios.
I have looked into many Robolectric tutorials but they do not answer my question. I had also asked this question( https://groups.google.com/forum/#!topic/robolectric/JLKrRGsvIkU ) in Robolectric google group which went unanswered. Is the concept of shadows helpful here?
I guess you use the MediaRecorder for recording audio.
Robolectric has already a Shadow for the MediaRecorder. This shadow only stores properties and the current stopped/started state. There is no audio recording implemented. For details, see https://github.com/robolectric/robolectric/blob/master/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaRecorder.java
Yes, you can unit test your app with Robolectric but real audio recording will not work. One thing you can do is to put a dummy record file to the target path when other code parts work with this file.
Also, with other tools like Espresso it could be hard to test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With