ProtoResultReporter

public abstract class ProtoResultReporter
extends Object implements ITestInvocationListener , ILogSaverListener , ISupportGranularResults

java.lang.Object
com.android.tradefed.result.proto.ProtoResultReporter


结果报告器构建了一个包含所有结果的TestRecord protobuf。应该扩展以处理如何处理processFinalProto(com.android.tradefed.result.proto.TestRecordProto.TestRecord)中的最终原型。

概括

公共构造函数

ProtoResultReporter ()

公共方法

final void invocationEnded (long elapsedTime)

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

void invocationFailed ( FailureDescription failure)

由于某些错误情况,报告不完整的调用。

void invocationFailed (Throwable cause)

由于某些错误情况,报告不完整的调用。

final void invocationStarted ( IInvocationContext context)

报告测试调用的开始。

final void logAssociation (String dataName, LogFile logFile)

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

void processFinalInvocationLogs (TestRecordProto.TestRecord invocationLogs)

使用调用记录将调用的所有最终日志一一发送。

void processFinalProto (TestRecordProto.TestRecord finalRecord)

处理带有所有结果的最终原型。

void processStartInvocation (TestRecordProto.TestRecord invocationStartRecord, IInvocationContext invocationContext)

发生invocationStarted(com.android.tradefed.invoker.IInvocationContext)后部分调用测试记录 proto 的处理。

void processTestCaseEnded (TestRecordProto.TestRecord testCaseRecord)

ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,HashMap))发生后对最终测试用例记录原型的处理。

void processTestCaseStarted (TestRecordProto.TestRecord testCaseStartedRecord)

testStarted(com.android.tradefed.result.TestDescription, long)发生后部分测试用例记录原型的处理。

void processTestModuleEnd (TestRecordProto.TestRecord moduleRecord)

testModuleEnded()发生后处理最终的模块记录原型。

void processTestModuleStarted (TestRecordProto.TestRecord moduleStartRecord)

testModuleStarted(com.android.tradefed.invoker.IInvocationContext)发生后处理部分模块记录原型。

void processTestRunEnded (TestRecordProto.TestRecord runRecord, boolean moduleInProgress)

ERROR(/#testRunEnded(long,HashMap))发生后对最终运行记录原型的处理。

void processTestRunStarted (TestRecordProto.TestRecord runStartedRecord)

testRunStarted(String, int)发生后部分测试运行记录原型的处理。

void setGranularResults (boolean granularResults)
void setInlineRecordOfChildren (boolean inline)
boolean supportGranularResults ()

如果报告器支持粒度结果,则返回 True,否则返回 false。

final void testAssumptionFailure ( TestDescription test, String trace)

当原子测试标记它假定条件为假时调用

final void testAssumptionFailure ( TestDescription test, FailureDescription failure)

当原子测试标记它假定条件为假时调用

final void testEnded ( TestDescription test, long endTime, testMetrics) testEnded ( TestDescription test, long endTime, testMetrics)

替代ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map)) ,我们可以直接指定结束时间。

void testEnded ( TestDescription test, testMetrics) testEnded ( TestDescription test, testMetrics)

报告单个测试用例的执行结束。

final void testFailed ( TestDescription test, FailureDescription failure)

报告单个测试用例的失败。

final void testFailed ( TestDescription test, String trace)

报告单个测试用例的失败。

final void testIgnored ( TestDescription test)

当测试不会运行时调用,通常是因为测试方法使用 org.junit.Ignore 注释。

final void testModuleEnded ()

报告模块运行的结束。

final void testModuleStarted ( IInvocationContext moduleContext)

报告正在运行的模块的开始。

final void testRunEnded (long elapsedTimeMillis, runMetrics) testRunEnded (long elapsedTimeMillis, runMetrics)

报告测试运行结束。

final void testRunFailed ( FailureDescription failure)

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

final void testRunFailed (String errorMessage)

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

void testRunStarted (String runName, int testCount, int attemptNumber)

报告测试运行的开始。

final void testRunStarted (String runName, int testCount)

报告测试运行的开始。

void testRunStarted (String runName, int testCount, int attemptNumber, long startTime)

报告测试运行的开始。

final void testStarted ( TestDescription test, long startTime)

替代testStarted(com.android.tradefed.result.TestDescription)我们还指定测试开始的时间,结合ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,Map))进行准确测量.

final void testStarted ( TestDescription test)

报告单个测试用例的开始。

受保护的方法

TestRecordProto.ChildReference createModuleChildReference (TestRecordProto.TestRecord record)

为模块创建子引用。

公共构造函数

ProtoResultReporter

public ProtoResultReporter ()

公共方法

调用结束

public final void invocationEnded (long elapsedTime)

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

将由 TradeFederation 框架自动调用。

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

调用失败

public void invocationFailed (FailureDescription failure)

由于某些错误情况,报告不完整的调用。

将由 TradeFederation 框架自动调用。

参数
failure FailureDescription : 描述失败原因的FailureDescription

调用失败

public void invocationFailed (Throwable cause)

由于某些错误情况,报告不完整的调用。

将由 TradeFederation 框架自动调用。

参数
cause Throwable : Throwable失败的原因

调用开始

public final void invocationStarted (IInvocationContext context)

报告测试调用的开始。

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

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

日志关联

public final 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 ,应该与测试用例相关联。

processFinalInvocationLogs

public void processFinalInvocationLogs (TestRecordProto.TestRecord invocationLogs)

使用调用记录将调用的所有最终日志一一发送。

参数
invocationLogs TestRecordProto.TestRecord :代表调用的最终原型。

processFinalProto

public void processFinalProto (TestRecordProto.TestRecord finalRecord)

处理带有所有结果的最终原型。

参数
finalRecord TestRecordProto.TestRecord :包含所有调用结果的最终原型。

进程启动调用

public void processStartInvocation (TestRecordProto.TestRecord invocationStartRecord, 
                IInvocationContext invocationContext)

发生invocationStarted(com.android.tradefed.invoker.IInvocationContext)后部分调用测试记录 proto 的处理。

参数
invocationStartRecord TestRecordProto.TestRecord :invocationStart 后填充的部分原型。

invocationContext IInvocationContext :调用IInvocationContext

进程TestCaseEnded

public void processTestCaseEnded (TestRecordProto.TestRecord testCaseRecord)

ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,HashMap))发生后对最终测试用例记录原型的处理。

参数
testCaseRecord TestRecordProto.TestRecord :代表测试用例的最终原型。

processTestCaseStarted

public void processTestCaseStarted (TestRecordProto.TestRecord testCaseStartedRecord)

testStarted(com.android.tradefed.result.TestDescription, long)发生后部分测试用例记录原型的处理。

参数
testCaseStartedRecord TestRecordProto.TestRecord :代表测试用例的部分原型。

processTestModuleEnd

public void processTestModuleEnd (TestRecordProto.TestRecord moduleRecord)

testModuleEnded()发生后处理最终的模块记录原型。

参数
moduleRecord TestRecordProto.TestRecord :代表模块的最终原型。

processTestModuleStarted

public void processTestModuleStarted (TestRecordProto.TestRecord moduleStartRecord)

testModuleStarted(com.android.tradefed.invoker.IInvocationContext)发生后处理部分模块记录原型。

参数
moduleStartRecord TestRecordProto.TestRecord :代表模块的部分原型。

进程测试运行结束

public void processTestRunEnded (TestRecordProto.TestRecord runRecord, 
                boolean moduleInProgress)

ERROR(/#testRunEnded(long,HashMap))发生后对最终运行记录原型的处理。

参数
runRecord TestRecordProto.TestRecord :代表运行的最终原型。

moduleInProgress boolean :模块是否正在进行中。

processTestRunStarted

public void processTestRunStarted (TestRecordProto.TestRecord runStartedRecord)

testRunStarted(String, int)发生后部分测试运行记录原型的处理。

参数
runStartedRecord TestRecordProto.TestRecord :代表运行的部分原型。

setGranularResults

public void setGranularResults (boolean granularResults)

参数
granularResults boolean

setInlineRecordOfChildren

public void setInlineRecordOfChildren (boolean inline)

参数
inline boolean

支持粒度结果

public boolean supportGranularResults ()

如果报告器支持粒度结果,则返回 True,否则返回 false。

退货
boolean

测试假设失败

public final void testAssumptionFailure (TestDescription test, 
                String trace)

当原子测试标记它假定条件为假时调用

参数
test TestDescription : 标识测试

trace String :失败的堆栈跟踪

测试假设失败

public final void testAssumptionFailure (TestDescription test, 
                FailureDescription failure)

当原子测试标记它假定条件为假时调用

参数
test TestDescription : 标识测试

failure FailureDescriptionFailureDescription描述失败及其上下文。

测试结束

public final void testEnded (TestDescription test, 
                long endTime, 
                 testMetrics)

替代ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map)) ,我们可以直接指定结束时间。结合testStarted(com.android.tradefed.result.TestDescription, long)进行准确测量。

参数
test TestDescription : 标识测试

endTime long :测试结束的时间,通过System.currentTimeMillis()测量

testMetrics :发出的指标的ERROR(/Map)

测试结束

public void testEnded (TestDescription test, 
                 testMetrics)

报告单个测试用例的执行结束。

如果未调用testFailed(TestDescription, FailureDescription) ,则此测试通过。还返回在测试用例执行期间可能已发出的任何键/值指标。

参数
test TestDescription : 标识测试

testMetrics :发出的指标的ERROR(/Map)

测试失败

public final void testFailed (TestDescription test, 
                FailureDescription failure)

报告单个测试用例的失败。

将在 testStarted 和 testEnded 之间调用。

参数
test TestDescription : 标识测试

failure FailureDescriptionFailureDescription描述失败及其上下文。

测试失败

public final void testFailed (TestDescription test, 
                String trace)

报告单个测试用例的失败。

将在 testStarted 和 testEnded 之间调用。

参数
test TestDescription : 标识测试

trace String :失败的堆栈跟踪

测试忽略

public final void testIgnored (TestDescription test)

当测试不会运行时调用,通常是因为测试方法使用 org.junit.Ignore 注释。

参数
test TestDescription : 标识测试

测试模块结束

public final void testModuleEnded ()

报告模块运行的结束。

testModuleStarted

public final void testModuleStarted (IInvocationContext moduleContext)

报告正在运行的模块的开始。此回调与testModuleEnded()相关联,并且在序列中是可选的。它仅在使用模块的运行期间使用:基于套件的运行器。

参数
moduleContext IInvocationContext :模块的IInvocationContext

测试运行结束

public final void testRunEnded (long elapsedTimeMillis, 
                 runMetrics)

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

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

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

测试运行失败

public final void testRunFailed (FailureDescription failure)

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

参数
failure FailureDescriptionFailureDescription描述失败及其上下文。

测试运行失败

public final void testRunFailed (String errorMessage)

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

参数
errorMessage String :描述运行失败原因的String

测试运行开始

public void testRunStarted (String runName, 
                int testCount, 
                int attemptNumber)

报告测试运行的开始。

参数
runName String : 测试运行名称

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

attemptNumber int :订单号,标识同一 runName 多次运行的不同尝试。 attemptNumber 是 0-indexed 并且应该在每次新的运行发生时递增。例如,一个测试是粒度重试 3 次,它应该在相同的 runName 下总共运行 4 次,并且尝试编号是从 0 到 3。

测试运行开始

public final void testRunStarted (String runName, 
                int testCount)

报告测试运行的开始。

参数
runName String : 测试运行名称

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

测试运行开始

public void testRunStarted (String runName, 
                int testCount, 
                int attemptNumber, 
                long startTime)

报告测试运行的开始。

参数
runName String : 测试运行名称

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

attemptNumber int :订单号,标识同一 runName 多次运行的不同尝试。 attemptNumber 是 0-indexed 并且应该在每次新的运行发生时递增。例如,一个测试是粒度重试 3 次,它应该在相同的 runName 下总共运行 4 次,并且尝试编号是从 0 到 3。

startTime long :运行开始的时间,通过System.currentTimeMillis()测量

测试开始

public final void testStarted (TestDescription test, 
                long startTime)

替代testStarted(com.android.tradefed.result.TestDescription)我们还指定测试开始的时间,结合ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,Map))进行准确测量.

参数
test TestDescription : 标识测试

startTime long :测试开始的时间,通过System.currentTimeMillis()测量

测试开始

public final void testStarted (TestDescription test)

报告单个测试用例的开始。旧界面,应尽可能使用testStarted(com.android.tradefed.result.TestDescription)

参数
test TestDescription : 标识测试

受保护的方法

createModuleChildReference

protected TestRecordProto.ChildReference createModuleChildReference (TestRecordProto.TestRecord record)

为模块创建子引用。

参数
record TestRecordProto.TestRecord

退货
TestRecordProto.ChildReference