android-instrumentation - AndroidJUnitRunner + Act

设置:

我继承的一个较旧的项目有很多遗留的仪器测试,我想对它们施加超时,因为它们中的很多都可以无限期地挂起,这使得很难获得测试报告。我正在将测试更新为 Junit4 样式,但目前它们都在扩展 ActivityInstrumentationTestCase2。

到目前为止尝试过:

在 AndroidJUnitRunner 的文档中它说要设置这个标志:

Set timeout (in milliseconds) that will be applied to each test: -e timeout_msec 5000 ...

... All arguments can also be specified in the in the AndroidManifest via a meta-data tag

我已经尝试将 AndroidJUnitRunner 配置添加到应用程序 list 和测试 list 中,但 timeout_msec 元数据项到目前为止没有任何效果。

最佳答案

您可以使用规则为类中的每个测试提供超时,如下所示。

@Rule public Timeout timeout = new Timeout(120000, TimeUnit.MILLISECONDS);

您还可以使用以下命令指定每个测试基础超时

@Test(timeout = 100) // Exception: test timed out after 100 milliseconds
public void test1() throws Exception {
    Thread.sleep(200);
}

您可以使用此链接阅读更多关于差异的信息

https://stackoverflow.com/a/32034936/2128442

关于android-instrumentation - AndroidJUnitRunner + ActivityInstrumentationTestCase2 超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40052862/

相关文章:

sql-server - TSQL 触发器而不是插入

java - 当 PoolingHttpClientConnectionManager 中的 Max

erlang - 有什么方法可以浏览 erlang 术语存储 (ETS)

scala - 隐式是私有(private)的吗?

amazon-web-services - AWS : Security Group Auto Sc

python - 检查 Python 中两个字符串中的常用字母是否位于同一位置?

angular - 取消选中所有选中的复选框 Angular2

python - Django 选择和字典

r - 如何在列表列上应用一个函数并在 dplyr 和 purrr 中返回另一个函数?

scala - 如何对spark Dataframe进行合并操作?