[英]Not able to find solution for detecting camera button for different devices in Espresso script to be run on Firebase Test Lab
I have to create a script using Espresso to test my app in Firebase test lab. 我必须使用Espresso创建一个脚本,以在Firebase测试实验室中测试我的应用程序。 My app uses Camera to capture images and I have opened the default camera app.
我的应用程序使用相机捕获图像,我已打开默认的相机应用程序。
For testing on my device I give package name for the testing device that I am using. 为了在我的设备上进行测试,我给出了我正在使用的测试设备的包名。 The issue is that the camera app package names for different Android devices is different, and we do not know each of it.
问题是不同Android设备的相机应用程序包名称是不同的,我们不知道它们中的每一个。 Also it is not good to hard code package names.
硬编码包名称也不好。
I have searched out and not able to find a way to find a solution. 我已经搜索过,无法找到找到解决方案的方法。
Thanking in advance. 提前感谢。
I don't think there's a good way to do this with the actual camera app, since the camera app often differs between device models and Android versions. 我不认为使用实际的相机应用程序有一个很好的方法,因为相机应用程序通常在设备型号和Android版本之间有所不同。
How about you fake this dependency in your tests? 你在测试中伪造这种依赖性怎么样? Either by abstracting the code that calls the camera app, or by adding your own fake camera activity that will get called and returns you a picture the way it's supposed to happen.
要么通过抽象调用相机应用程序的代码,要么通过添加自己的假相机活动来调用它,并按照应该发生的方式返回一个图片。
You can use android.support.test.espresso.intent
to mock camera launch intent 您可以使用
android.support.test.espresso.intent
来模拟相机启动意图
https://guides.codepath.com/android/UI-Testing-with-Espresso#stubbing-out-the-camera https://guides.codepath.com/android/UI-Testing-with-Espresso#stubbing-out-the-camera
also ref: http://www.qaautomated.com/2016/02/testing-camera-activity-using-intent.html 还有参考: http : //www.qaautomated.com/2016/02/testing-camera-activity-using-intent.html
check google sample https://github.com/googlesamples/android-testing/tree/master/ui/espresso/IntentsAdvancedSample 检查谷歌样本https://github.com/googlesamples/android-testing/tree/master/ui/espresso/IntentsAdvancedSample
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.