如何跳过条件是否失败的测试Junit(Instrumentation)测试Android

时间:2019-11-29 06:20:34

标签: android junit4 test-runner android-junit androidjunitrunner

我正在编写用于设备测试的测试用例,在其中,我必须检查一些Wifi,消息,摄像头和音频Apis,但前提是该设备能够使用该功能

示例:

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

但是仅当我的设备具有消息传递功能时,才应执行此Test方法

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

仅当isCapable返回true时,才应执行测试,否则应将其忽略或跳过

如何编写这样的测试类

请有人帮助

1 个答案:

答案 0 :(得分:0)

如果将2 + 2更改为1 + 1,会失败吗? (上面没有评论,信誉不够;)