【发布时间】:2019-11-29 06:20:34
【问题描述】:
我正在为设备测试编写测试用例,其中我必须检查一些 Wifi、消息、相机和音频 API,但前提是设备具有该功能
例子:
@Test
public void testMessagingApi() throws Exception {
....some test method....
}
但只有当我的设备具备消息功能时,才应执行此测试方法
public boolean isCapable(String feature) {
Check some property to test if the feature is supported
return supported;
}
只有当 isCapable 返回 true 时才应该执行测试,否则应该忽略或跳过它
这样的测试类怎么写
请人帮忙
【问题讨论】:
-
看看这里,@RunIf 应该满足你的需求stackoverflow.com/questions/1689242/…
-
用 RuniF 测试 @RunIf(DatabaseIsConnected.class) public void addition_isCorrect() { assertEquals(4, 2 + 2); } 类 DatabaseIsConnected 实现 Checker { Override public boolean meet() { return false; } } 这里我故意返回 false 但仍然试运行它显示通过 谁能帮忙
标签: android junit4 test-runner android-junit androidjunitrunner