DeviceJUnit4ClassRunner.TestMetrics
public static class DeviceJUnit4ClassRunner.TestMetrics
extends ExternalResource
java.lang.Object | ||
↳ | org.junit.rules.外部资源 | |
↳ | com.android.tradefed.testtype.DeviceJUnit4ClassRunner.TestMetrics |
ExternalResource
和TestRule
的实现。此规则允许在测试用例期间(在@Test 内)记录指标。它保证在测试之间清理指标映射,因此可以重复使用相同的规则对象。
Example: @Rule public TestMetrics metrics = new TestMetrics(); @Test public void testFoo() { metrics.addTestMetric("key", "value"); metrics.addTestMetric("key2", "value2"); } @Test public void testFoo2() { metrics.addTestMetric("key3", "value3"); }
概括
公共构造函数 | |
---|---|
TestMetrics () |
公共方法 | |
---|---|
void | addTestMetric (String key, MetricMeasurement.Metric metric) 以原型格式为测试用例记录一个指标条目。 |
void | addTestMetric (String key, String value) 记录测试用例的指标条目。 |
Statement | apply (Statement base, Description description) |
受保护的方法 | |
---|---|
void | after () |
void | before () |
公共构造函数
测试指标
public TestMetrics ()
公共方法
添加测试指标
public void addTestMetric (String key, MetricMeasurement.Metric metric)
以原型格式为测试用例记录一个指标条目。测试用例中的每个键都必须是唯一的,否则它将覆盖以前的值。
参数 | |
---|---|
key | String :指标的键。 |
metric | MetricMeasurement.Metric :与键关联的值。 |
添加测试指标
public void addTestMetric (String key, String value)
记录测试用例的指标条目。测试用例中的每个键都必须是唯一的,否则它将覆盖以前的值。
参数 | |
---|---|
key | String :指标的键。 |
value | String :与键关联的值。 |
申请
public Statement apply (Statement base, Description description)
参数 | |
---|---|
base | Statement |
description | Description |
退货 | |
---|---|
Statement |
受保护的方法
后
protected void after ()
前
protected void before ()