如果条件失败,如何跳过测试Junit(Instrumentation)测试Android

问题描述 投票:0回答:1

我正在编写用于设备测试的测试用例,在其中,我必须检查一些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时,才应执行测试,否则应将其忽略或跳过

如何编写这样的测试类

请有人帮助

android junit4 test-runner android-junit androidjunitrunner
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.