简体   繁体   English

排除基于设备的测试

[英]Excluding a test based on device

I have noticed that there just isn't a way to make my tests viable on all possible devices, mainly because of Facebook login I mentioned here. 我注意到没有办法让我的测试在所有可能的设备上都可行,主要是因为我在这里提到的Facebook登录

That being said, is there a way to automatically skip a test based on device its running on? 话虽如此,有没有办法根据运行的设备自动跳过测试? I know I can use @Suppress to skip it on every device, but is there a way to define when to skip? 我知道我可以使用@Suppress在每台设备上跳过它,但有没有办法定义何时跳过?

The documentation for the AndroidJUnitRunner ( https://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner.html ) lists a few features that seem helpful to achieve what you have in mind. AndroidJUnitRunnerhttps://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner.html )的文档列出了一些看似有助于实现您的想法的功能。 Namely, there are switches to only run tests with ( -e annotation ) or without ( -e notAnnotation ) a given annotation. 也就是说,有些开关只能使用( -e annotation )或不使用( -e notAnnotation )给定注释运行测试。

You could annotate some of your tests with @OnlySamsung and then -- depending on the device you run the test on -- include or exclude those using the described filter mechanism: -e notAnnotation com.example.annotations.OnlySamsung 您可以使用@OnlySamsung注释一些测试,然后 - 根据您运行测试的设备 - 使用所描述的过滤机制包含或排除那些: -e notAnnotation com.example.annotations.OnlySamsung

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM