控制台结果报告器

public class ConsoleResultReporter
extends TestResultListener implements ILogSaverListener , ITestInvocationListener

java.lang.Object
com.android.tradefed.result.TestResultListener
com.android.tradefed.result.ConsoleResultReporter


结果报告器将测试结果打印到控制台。

打印每个测试运行、每个测试用例、测试指标、测试日志和测试文件位置。

概括

公共构造函数

ConsoleResultReporter ()

公共方法

void invocationEnded (long elapsedTime)

报告调用已终止,无论是成功终止还是由于某些错误情况。

void invocationStarted ( IInvocationContext context)

报告测试调用的开始。

void logAssociation (String dataName, LogFile logFile)

在某些情况下,日志必须与测试用例强关联,但有机会这样做就直接testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile)回调是不可能的。

void testLogSaved (String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)

保存测试日志时调用。

void testResult ( TestDescription test, TestResult result)
void testRunEnded (long elapsedTimeMillis, metrics) testRunEnded (long elapsedTimeMillis, metrics)

报告测试运行结束。

void testRunFailed ( FailureDescription failure)

由于FailureDescription描述的故障,报告测试运行未能完成。

void testRunFailed (String errorMessage)

报告测试运行由于致命错误而未能完成。

void testRunStarted (String runName, int testCount)

报告测试运行的开始。

公共构造函数

控制台结果报告器

public ConsoleResultReporter ()

公共方法

调用结束

public void invocationEnded (long elapsedTime)

报告调用已终止,无论是成功终止还是由于某些错误情况。

将由 TradeFederation 框架自动调用。

参数
elapsedTime long :调用经过的时间(以毫秒为单位)

调用开始

public void invocationStarted (IInvocationContext context)

报告测试调用的开始。

将由 TradeFederation 框架自动调用。记者需要覆盖此方法以支持多设备报告。

参数
context IInvocationContext :有关调用的信息

日志关联

public void logAssociation (String dataName, 
                LogFile logFile)

在某些情况下,日志必须与测试用例强关联,但有机会这样做就直接testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile)回调是不可能的。因此,此回调允许显式提供强关联。

参数
dataName String :数据的名称

logFile LogFile :之前记录的LogFile ,应该与测试用例相关联。

测试日志已保存

public void testLogSaved (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream, 
                LogFile logFile)

保存测试日志时调用。

应该用来代替ITestInvocationListener#testLog(String, LogDataType, InputStreamSource)

参数
dataName String :数据的ERROR(/String)描述性名称。例如“device_logcat”。注意 dataName 每次调用可能不是唯一的。即实现者必须能够处理具有相同数据名的多个调用

dataType LogDataType :数据的LogDataType

dataStream InputStreamSource :数据的InputStreamSource 。实施者应调用 createInputStream 开始读取数据,并确保在完成后关闭生成的 InputStream。

logFile LogFile :包含已保存文件的元数据的LogFile

测试结果

public void testResult (TestDescription test, 
                TestResult result)

参数
test TestDescription

result TestResult

测试运行结束

public void testRunEnded (long elapsedTimeMillis, 
                 metrics)

报告测试运行结束。 FIXME: 我们不能有两个不同类型的 Map<> 接口,所以我们必须在这里使用 HashMap。

参数
elapsedTimeMillis long :设备报告经过的时间,以毫秒为单位

metrics :在测试运行结束时使用Metric报告的键值对。

测试运行失败

public void testRunFailed (FailureDescription failure)

由于FailureDescription描述的故障,报告测试运行未能完成。

参数
failure FailureDescription :描述故障及其上下文的FailureDescription

测试运行失败

public void testRunFailed (String errorMessage)

报告测试运行由于致命错误而未能完成。

参数
errorMessage String : ERROR(/String)描述运行失败的原因。

测试运行开始

public void testRunStarted (String runName, 
                int testCount)

报告测试运行的开始。

参数
runName String : 测试运行名称

testCount int : 测试运行中的测试总数