How to skip test if a condition is failed Junit (Instrumentation) Testing Android

488 Views Asked by At

I am writing test cases for a device testing in which I will have to check some Wifi, Messaging, Camera and Audio Apis but only if the device is capable of that Feature

Example :

@Test
public void testMessagingApi() throws Exception {
    ....some test method....
}

But this Test method should execute only if my device is capable of Messaging feature

public boolean isCapable(String feature) {
     Check some property to test if the feature is supported
     return supported;
}

The test should execute only if isCapable returns true else it should be ignored or skipped

How to write such a test class

Please someone help

1

There are 1 best solutions below

0
On

And if you change 2 + 2 to 1 + 1, does it fail? (Cound not comment above, not enough reputation ;)