Reputation: 423
I have multiple devices connected and I run the gradle command 'connectedCheck' which runs tests on multiple devices.
ConnectedCheck executes tests on all the devices in an order. I want to get the serial number of the device the tests are currently being run on.
Does android provide a way to do that?
Upvotes: 3
Views: 680
Reputation: 423
I found the solution! In fact there wasn't a problem in the first place.
Issue: Gradle android plugin's task to run tests is 'connectedCheck'. It executes tests on how many ever android devices connected to a host. Now when I @Ignore a test it will be ignored on all those devices where as I wanted to do that only for the failing device/devices
Solution: Add a custom jUnit annotation that takes an array of String values for Device serial IDs. Write a custom test runner by extending BlockJUnit4ClassRunner override runChild to check if Build.Device is same as the one provided in the annotation if a method is annotated.
If it is fireTestIgnored to ignore so that it will be skipped only for the device you specified in the annotation.
Upvotes: 1