TestRunResult
public
class
TestRunResult
extends Object
| java.lang.Object | |
| ↳ | com.android.tradefed.result.TestRunResult |
用于保存单次测试运行的结果。
准确统计测试次数,并跟踪未完成的测试。
不具有线程安全性!必须按顺序调用 test* 回调
摘要
常量 | |
|---|---|
String |
ERROR_DIVIDER
|
公共构造函数 | |
|---|---|
TestRunResult()
创建空的 |
|
公共方法 | |
|---|---|
void
|
addTestResult(TestDescription test, TestResult testResult)
|
Set<TestDescription>
|
getCompletedTests()
获取已完成的测试的集合。 |
long
|
getElapsedTime()
返回当前运行的已用时间。 |
int
|
getExpectedTestCount()
获取相应 TestRunResult 预期包含的测试用例数量。 |
Set<TestDescription>
|
getFailedTests()
获取失败的测试集。 |
String
|
getName()
|
int
|
getNumAllFailedTests()
返回处于失败状态(失败、假设失败)的测试总数 |
int
|
getNumCompleteTests()
获取相应运行中已完成的测试数量,即状态不为“不完整”的测试数量。 |
int
|
getNumTests()
获取相应运行中的测试数量。 |
int
|
getNumTestsInState(TestStatus status)
获取相应运行中处于指定状态的测试数量。 |
int
|
getNumTestsInState(TestResult.TestStatus ddmlibStatus)
为了与旧状态兼容。 |
Set<TestDescription>
|
getPassedTests()
获取已通过的测试的集合。 |
FailureDescription
|
getRunFailureDescription()
如果运行未失败,则返回运行失败描述符 |
String
|
getRunFailureMessage()
如果运行未失败,则返回运行失败错误消息 |
MultiMap<String, LogFile>
|
getRunLoggedFiles()
返回一个包含与相应测试用例关联的所有已记录文件的映射的副本。 |
Map<String, String>
|
getRunMetrics()
|
HashMap<String, MetricMeasurement.Metric>
|
getRunProtoMetrics()
|
long
|
getStartTime()
返回第一次 testRunStart 调用的开始时间。 |
Map<TestDescription, TestResult>
|
getTestEntriesInState(Collection<TestStatus> statuses)
获取处于指定状态的一组测试。 |
Map<TestDescription, TestResult>
|
getTestResults()
返回测试结果的映射。 |
Set<TestDescription>
|
getTestsInState(List<TestStatus> statuses)
获取处于指定状态的一组测试。 |
List<TestResult>
|
getTestsResultsInState(TestStatus status)
返回处于特定状态的所有 |
String
|
getTextSummary()
返回一个描述结果的易懂字符串。 |
boolean
|
hasFailedTests()
|
boolean
|
isRunComplete()
|
boolean
|
isRunFailure()
|
static
TestRunResult
|
merge(List<TestRunResult> testRunResults)
|
static
TestRunResult
|
merge(List<TestRunResult> testRunResults, MergeStrategy strategy)
合并同一 testRunName 的多个 TestRunResults。 |
void
|
resetRunFailure()
重置运行失败状态。 |
void
|
setAggregateMetrics(boolean metricAggregation)
|
void
|
setRunComplete(boolean runComplete)
|
void
|
testAssumptionFailure(TestDescription test, String trace)
|
void
|
testAssumptionFailure(TestDescription test, FailureDescription failure)
|
void
|
testEnded(TestDescription test, long endTime, HashMap<String, MetricMeasurement.Metric> testMetrics)
|
void
|
testEnded(TestDescription test, HashMap<String, MetricMeasurement.Metric> testMetrics)
|
void
|
testFailed(TestDescription test, FailureDescription failure)
|
void
|
testFailed(TestDescription test, String trace)
|
void
|
testIgnored(TestDescription test)
|
void
|
testLogSaved(String dataName, LogFile logFile)
有关正在记录的文件的信息会存储起来,并与正在进行的测试用例或测试运行相关联。 |
void
|
testRunEnded(long elapsedTime, HashMap<String, MetricMeasurement.Metric> runMetrics)
使用新 proto 指标的新界面。 |
void
|
testRunEnded(long elapsedTime, Map<String, String> runMetrics)
|
void
|
testRunFailed(FailureDescription failureDescription)
|
void
|
testRunFailed(String errorMessage)
|
void
|
testRunStarted(String runName, int testCount, long startTime)
通知测试运行已开始。 |
void
|
testRunStarted(String runName, int testCount)
通知测试运行已开始。 |
void
|
testRunStopped(long elapsedTime)
|
void
|
testSkipped(TestDescription test, SkipReason reason)
|
void
|
testStarted(TestDescription test, long startTime)
|
void
|
testStarted(TestDescription test)
|
常量
ERROR_DIVIDER
public static final String ERROR_DIVIDER
常量值: " ====Next Error==== "
公共构造函数
公共方法
addTestResult
public void addTestResult (TestDescription test, TestResult testResult)
| 参数 | |
|---|---|
test |
TestDescription |
testResult |
TestResult |
getCompletedTests
public Set<TestDescription> getCompletedTests ()
获取已完成的测试集。
| 返回 | |
|---|---|
Set<TestDescription> |
|
getElapsedTime
public long getElapsedTime ()
返回当前运行的已用时间。
| 返回 | |
|---|---|
long |
|
getExpectedTestCount
public int getExpectedTestCount ()
获取相应 TestRunResult 预期包含的测试用例数量。由于测试崩溃,实际数量可能少于预期数量。通常,这种不匹配表示测试运行失败。
| 返回 | |
|---|---|
int |
|
getName
public String getName ()
| 返回 | |
|---|---|
String |
测试运行名称 |
getNumAllFailedTests
public int getNumAllFailedTests ()
返回处于失败状态(失败、假设失败)的测试总数
| 返回 | |
|---|---|
int |
|
getNumCompleteTests
public int getNumCompleteTests ()
获取相应运行中已完成的测试数量,即状态不为“不完整”的测试数量。
| 返回 | |
|---|---|
int |
|
getNumTests
public int getNumTests ()
获取相应运行中的测试数量。
| 返回 | |
|---|---|
int |
|
getNumTestsInState
public int getNumTestsInState (TestStatus status)
获取相应运行中处于指定状态的测试数量。
| 参数 | |
|---|---|
status |
TestStatus |
| 返回 | |
|---|---|
int |
|
getNumTestsInState
public int getNumTestsInState (TestResult.TestStatus ddmlibStatus)
为了与旧状态兼容。请改用 getNumTestsInState(TestStatus)。
| 参数 | |
|---|---|
ddmlibStatus |
TestResult.TestStatus |
| 返回 | |
|---|---|
int |
|
getRunFailureDescription
public FailureDescription getRunFailureDescription ()
如果运行未失败,则返回运行失败描述符 null。
| 返回 | |
|---|---|
FailureDescription |
|
getRunFailureMessage
public String getRunFailureMessage ()
如果运行未失败,则返回运行失败错误消息 null。
| 返回 | |
|---|---|
String |
|
getRunLoggedFiles
public MultiMap<String, LogFile> getRunLoggedFiles ()
返回一个包含与相应测试用例关联的所有已记录文件的映射的副本。
| 返回 | |
|---|---|
MultiMap<String, LogFile> |
|
getRunProtoMetrics
public HashMap<String, MetricMeasurement.Metric> getRunProtoMetrics ()
| 返回 | |
|---|---|
HashMap<String, MetricMeasurement.Metric> |
采用新 proto 格式的测试运行指标的 Map。 |
getStartTime
public long getStartTime ()
返回第一次 testRunStart 调用的开始时间。
| 返回 | |
|---|---|
long |
|
getTestEntriesInState
public Map<TestDescription, TestResult> getTestEntriesInState (Collection<TestStatus> statuses)
获取处于指定状态的一组测试。
| 参数 | |
|---|---|
statuses |
Collection |
| 返回 | |
|---|---|
Map<TestDescription, TestResult> |
|
getTestResults
public Map<TestDescription, TestResult> getTestResults ()
返回测试结果的映射。
| 返回 | |
|---|---|
Map<TestDescription, TestResult> |
|
getTestsInState
public Set<TestDescription> getTestsInState (List<TestStatus> statuses)
获取处于指定状态的一组测试。
| 参数 | |
|---|---|
statuses |
List |
| 返回 | |
|---|---|
Set<TestDescription> |
|
getTestsResultsInState
public List<TestResult> getTestsResultsInState (TestStatus status)
返回处于特定状态的所有 TestResult。
| 参数 | |
|---|---|
status |
TestStatus |
| 返回 | |
|---|---|
List<TestResult> |
|
getTextSummary
public String getTextSummary ()
返回描述结果的易懂字符串。
| 返回 | |
|---|---|
String |
|
hasFailedTests
public boolean hasFailedTests ()
| 返回 | |
|---|---|
boolean |
如果测试运行有任何失败或出错的测试,则为 true。 |
isRunComplete
public boolean isRunComplete ()
| 返回 | |
|---|---|
boolean |
如果测试运行已完成,则为 true。 |
isRunFailure
public boolean isRunFailure ()
| 返回 | |
|---|---|
boolean |
如果测试运行失败,则为 true。 |
合并
public static TestRunResult merge (List<TestRunResult> testRunResults)
| 参数 | |
|---|---|
testRunResults |
List |
| 返回 | |
|---|---|
TestRunResult |
|
合并
public static TestRunResult merge (List<TestRunResult> testRunResults, MergeStrategy strategy)
合并了多个具有相同 testRunName 的 TestRunResults。如果某个测试用例出现在多个 TestRunResults 中,但结果不同(例如,“boottest-device”运行了三次,结果为“失败-失败-通过”),我们会将失败运行中的所有堆栈轨迹串联起来,并信任最终运行结果的状态、指标、日志文件、开始/结束时间。
| 参数 | |
|---|---|
testRunResults |
List:要合并的 TestRunResult 列表。 |
strategy |
MergeStrategy:用于合并结果的合并策略。 |
| 返回 | |
|---|---|
TestRunResult |
包含来自 testRunResults 的合并数据的最终 TestRunResult。 |
resetRunFailure
public void resetRunFailure ()
重置运行失败状态。
重试时有时需要重置运行失败状态。在执行此操作时应谨慎,以免清除实际故障。
setAggregateMetrics
public void setAggregateMetrics (boolean metricAggregation)
| 参数 | |
|---|---|
metricAggregation |
boolean |
setRunComplete
public void setRunComplete (boolean runComplete)
| 参数 | |
|---|---|
runComplete |
boolean |
testAssumptionFailure
public void testAssumptionFailure (TestDescription test, String trace)
| 参数 | |
|---|---|
test |
TestDescription |
trace |
String |
testAssumptionFailure
public void testAssumptionFailure (TestDescription test, FailureDescription failure)
| 参数 | |
|---|---|
test |
TestDescription |
failure |
FailureDescription |
testEnded
public void testEnded (TestDescription test, long endTime, HashMap<String, MetricMeasurement.Metric> testMetrics)
| 参数 | |
|---|---|
test |
TestDescription |
endTime |
long |
testMetrics |
HashMap |
testEnded
public void testEnded (TestDescription test, HashMap<String, MetricMeasurement.Metric> testMetrics)
| 参数 | |
|---|---|
test |
TestDescription |
testMetrics |
HashMap |
testFailed
public void testFailed (TestDescription test, FailureDescription failure)
| 参数 | |
|---|---|
test |
TestDescription |
failure |
FailureDescription |
testFailed
public void testFailed (TestDescription test, String trace)
| 参数 | |
|---|---|
test |
TestDescription |
trace |
String |
testLogSaved
public void testLogSaved (String dataName,
LogFile logFile)有关正在记录的文件的信息会存储起来,并与正在进行的测试用例或测试运行相关联。
| 参数 | |
|---|---|
dataName |
String:引用数据的名称。 |
logFile |
LogFile:表示对象保存位置及其相关信息的 LogFile 对象。 |
testRunEnded
public void testRunEnded (long elapsedTime,
HashMap<String, MetricMeasurement.Metric> runMetrics)使用新的 proto 指标的新界面。
| 参数 | |
|---|---|
elapsedTime |
long |
runMetrics |
HashMap |
testRunEnded
public void testRunEnded (long elapsedTime,
Map<String, String> runMetrics)| 参数 | |
|---|---|
elapsedTime |
long |
runMetrics |
Map |
testRunFailed
public void testRunFailed (FailureDescription failureDescription)
| 参数 | |
|---|---|
failureDescription |
FailureDescription |
testRunFailed
public void testRunFailed (String errorMessage)
| 参数 | |
|---|---|
errorMessage |
String |
testRunStarted
public void testRunStarted (String runName,
int testCount,
long startTime)通知测试运行已开始。
| 参数 | |
|---|---|
runName |
String:与测试运行关联的名称,用于跟踪。 |
testCount |
int:与测试运行关联的预期测试用例数量。 |
startTime |
long |
testRunStarted
public void testRunStarted (String runName,
int testCount)通知测试运行已开始。
| 参数 | |
|---|---|
runName |
String:与测试运行关联的名称,用于跟踪。 |
testCount |
int:与测试运行关联的预期测试用例数量。 |
testRunStopped
public void testRunStopped (long elapsedTime)
| 参数 | |
|---|---|
elapsedTime |
long |
testSkipped
public void testSkipped (TestDescription test, SkipReason reason)
| 参数 | |
|---|---|
test |
TestDescription |
reason |
SkipReason |
testStarted
public void testStarted (TestDescription test, long startTime)
| 参数 | |
|---|---|
test |
TestDescription |
startTime |
long |