简体   繁体   中英

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.

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?

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. Namely, there are switches to only run tests with ( -e annotation ) or without ( -e notAnnotation ) a given annotation.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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