0

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

techiegul
  • 11
  • 5
  • Have a look over here, @RunIf should meet what you need https://stackoverflow.com/questions/1689242/conditionally-ignoring-tests-in-junit-4 – Franc Schiphorst Nov 29 '19 at 06:39
  • tried this with RuniF Test @RunIf(DatabaseIsConnected.class) public void addition_isCorrect() { assertEquals(4, 2 + 2); } class DatabaseIsConnected implements Checker { Override public boolean satisfy() { return false; } } Here I am purposely returning false but still test run and it shows pass Can anyone help – techiegul Nov 29 '19 at 08:18

1 Answers1

0

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