MetricTestCase
public
class
MetricTestCase
extends TestCase
| java.lang.Object | |||
| ↳ | junit.framework.Assert | ||
| ↳ | junit.framework.TestCase | ||
| ↳ | com.android.tradefed.testtype.MetricTestCase | ||
TestCase 的扩展版本,允许在作为 TradeFed 的一部分运行时记录指标。直接作为 DeviceTestCase 或作为 HostTest 的一部分。TODO:评估是否需要为 JUnit3 测试提供运行指标(而不仅仅是测试指标)。
摘要
嵌套类 | |
|---|---|
class |
MetricTestCase.LogHolder
用于保存要报告的日志文件的结构。 |
字段 | |
|---|---|
public
List<MetricTestCase.LogHolder> |
mLogs
|
public
HashMap<String, MetricMeasurement.Metric> |
mMetrics
|
公共构造函数 | |
|---|---|
MetricTestCase()
|
|
MetricTestCase(String name)
使用给定的名称构造测试用例。 |
|
公共方法 | |
|---|---|
final
void
|
addTestLog(String dataName, LogDataType dataType, InputStreamSource dataStream)
来自 JUnit3 转发器的回调,用于从测试中获取日志。 |
final
void
|
addTestMetric(String key, MetricMeasurement.Metric metric)
|
final
void
|
addTestMetric(String key, String value)
为测试用例记录指标。 |
字段
mMetrics
public HashMap<String, MetricMeasurement.Metric> mMetrics
公共构造函数
MetricTestCase
public MetricTestCase ()
公共方法
addTestLog
public final void addTestLog (String dataName,
LogDataType dataType,
InputStreamSource dataStream)来自 JUnit3 转发器的回调,用于从测试中获取日志。
| 参数 | |
|---|---|
dataName |
String:数据的描述性名称(字符串)。例如“device_logcat”。请注意,dataName 在每次调用时可能不是唯一的。也就是说,实现者必须能够处理具有相同 dataName 的多次调用 |
dataType |
LogDataType:数据的 LogDataType |
dataStream |
InputStreamSource:数据的 InputStreamSource。实现者应调用 createInputStream 开始读取数据,并确保在完成后关闭生成的 InputStream。调用方应确保数据源在 testLog 方法完成之前保持存在且可访问。 |
addTestMetric
public final void addTestMetric (String key,
MetricMeasurement.Metric metric)| 参数 | |
|---|---|
key |
String |
metric |
MetricMeasurement.Metric |
addTestMetric
public final void addTestMetric (String key,
String value)记录测试用例的指标。
| 参数 | |
|---|---|
key |
String:用于查找相应指标的键。 |
value |
String:与密钥关联。 |