TestRunResult

public class TestRunResult
extends Object

java.lang.Object
   ↳ com.android.tradefed.result.TestRunResult


用于保存单次测试运行的结果。

准确统计测试次数,并跟踪未完成的测试。

不具有线程安全性!必须按顺序调用 test* 回调

摘要

常量

String ERROR_DIVIDER

公共构造函数

TestRunResult()

创建一个空的TestRunResult

公共方法

void addTestResult(TestDescription test, TestResult testResult)
getCompletedTests()

获取已完成的测试集。

long getElapsedTime()

返回当前运行已过去的时间。

int getExpectedTestCount()

获取相应 TestRunResult 预期包含的测试用例数量。

getFailedTests()

获取失败的测试集。

String getName()
int getNumAllFailedTests()

返回处于失败状态(失败、假设失败)的测试总数

int getNumCompleteTests()

获取相应运行中已完成的测试数量,即状态不为“不完整”的测试数量。

int getNumTests()

获取相应运行中的测试数量。

int getNumTestsInState(TestStatus status)

获取相应运行中处于指定状态的测试数量。

int getNumTestsInState(TestResult.TestStatus ddmlibStatus)

为了与旧状态兼容。

getPassedTests()

获取通过的测试集。

FailureDescription getRunFailureDescription()

如果运行未失败,则返回运行失败描述符 null

String getRunFailureMessage()

如果运行未失败,则返回运行失败错误消息 null

MultiMap<String, LogFile> getRunLoggedFiles()

返回一个包含与相应测试用例关联的所有已记录文件的映射的副本。

getRunMetrics()
getRunProtoMetrics()
long getStartTime()

返回第一次 testRunStart 调用的开始时间。

getTestEntriesInState( statuses)

获取处于指定状态的一组测试。

getTestResults()

返回测试结果的映射。

getTestsInState( statuses)

获取处于指定状态的一组测试。

getTestsResultsInState(TestStatus status)

返回处于特定状态的所有 TestResult

String getTextSummary()

返回一个描述结果的易懂字符串。

boolean hasFailedTests()
boolean isRunComplete()
boolean isRunFailure()
static TestRunResult merge( testRunResults)
static TestRunResult merge( 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, testMetrics)
void testEnded(TestDescription test, 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, 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==== "

公共构造函数

TestRunResult

public TestRunResult ()

创建空的 TestRunResult

公共方法

addTestResult

public void addTestResult (TestDescription test, 
                TestResult testResult)

参数
test TestDescription

testResult TestResult

getCompletedTests

public  getCompletedTests ()

获取已完成的测试集。

返回

getElapsedTime

public long getElapsedTime ()

返回当前运行的已用时间。

返回
long

getExpectedTestCount

public int getExpectedTestCount ()

获取相应 TestRunResult 预期包含的测试用例数量。由于测试崩溃,实际数量可能少于预期数量。通常,此类不匹配表示测试运行失败。

返回
int

getFailedTests

public  getFailedTests ()

获取失败的测试集。

返回

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(com.android.tradefed.result.TestStatus)

参数
ddmlibStatus TestResult.TestStatus

返回
int

getPassedTests

public  getPassedTests ()

获取通过的测试集。

返回

getRunFailureDescription

public FailureDescription getRunFailureDescription ()

如果运行未失败,则返回运行失败描述符 null

返回
FailureDescription

getRunFailureMessage

public String getRunFailureMessage ()

如果运行未失败,则返回运行失败错误消息 null

返回
String

getRunLoggedFiles

public MultiMap<String, LogFile> getRunLoggedFiles ()

返回一个映射的副本,其中包含与相应测试用例关联的所有已记录文件。

返回
MultiMap<String, LogFile>

getRunMetrics

public  getRunMetrics ()

返回
测试运行指标的 ERROR(/Map)

getRunProtoMetrics

public  getRunProtoMetrics ()

返回
采用新 proto 格式的测试运行指标的 ERROR(/Map)

getStartTime

public long getStartTime ()

返回第一次 testRunStart 调用的开始时间。

返回
long

getTestEntriesInState

public  getTestEntriesInState ( statuses)

获取处于指定状态的一组测试。

参数
statuses

返回

getTestResults

public  getTestResults ()

返回测试结果的映射。

返回

getTestsInState

public  getTestsInState ( statuses)

获取处于指定状态的一组测试。

参数
statuses

返回

getTestsResultsInState

public  getTestsResultsInState (TestStatus status)

返回处于特定状态的所有 TestResult

参数
status TestStatus

返回

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 ( testRunResults)

参数
testRunResults

返回
TestRunResult

合并

public static TestRunResult merge ( testRunResults, 
                MergeStrategy strategy)

合并了多个具有相同 testRunName 的 TestRunResults。如果某个测试用例出现在多个 TestRunResults 中,但结果不同(例如,“boottest-device”运行了三次,结果为“失败-失败-通过”),我们会将失败运行中的所有堆栈轨迹串联起来,并信任最后一次运行的结果,以获取状态、指标、日志文件、开始/结束时间。

参数
testRunResults :要合并的 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, 
                 testMetrics)

参数
test TestDescription

endTime long

testMetrics

testEnded

public void testEnded (TestDescription test, 
                 testMetrics)

参数
test TestDescription

testMetrics

testFailed

public void testFailed (TestDescription test, 
                FailureDescription failure)

参数
test TestDescription

failure FailureDescription

testFailed

public void testFailed (TestDescription test, 
                String trace)

参数
test TestDescription

trace String

testIgnored

public void testIgnored (TestDescription test)

参数
test TestDescription

testLogSaved

public void testLogSaved (String dataName, 
                LogFile logFile)

有关正在记录的文件的信息会存储起来,并与正在进行的测试用例或测试运行相关联。

参数
dataName String:引用数据的名称。

logFile LogFileLogFile 对象,表示对象保存的位置以及有关该对象的信息。

testRunEnded

public void testRunEnded (long elapsedTime, 
                 runMetrics)

参数
elapsedTime long

runMetrics

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

testStarted

public void testStarted (TestDescription test)

参数
test TestDescription