ProtoResultReporter

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

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


结果报告程序会构建一个包含所有结果的 TestRecord protobuf。应为 扩展为处理对 processFinalProto(com.android.tradefed.result.proto.TestRecordProto.TestRecord) 中的最终 proto 执行的操作。

摘要

公共构造函数

ProtoResultReporter()

公共方法

final void invocationEnded(long elapsedTime)

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

void invocationFailed(FailureDescription failure)

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

void invocationFailed(Throwable cause)

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

void invocationSkipped(SkipReason reason)

将调用报告为跳过

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)

处理包含所有结果的最终 proto。

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)) 发生后处理最终的测试用例记录 proto。

void processTestCaseStarted(TestRecordProto.TestRecord testCaseStartedRecord)

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

void processTestModuleEnd(TestRecordProto.TestRecord moduleRecord)

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

void processTestModuleStarted(TestRecordProto.TestRecord moduleStartRecord)

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

void processTestRunEnded(TestRecordProto.TestRecord runRecord, boolean moduleInProgress)

ERROR(/#testRunEnded(long,HashMap)) 之后处理最终的运行记录 proto 错误。

void processTestRunStarted(TestRecordProto.TestRecord runStartedRecord)

testRunStarted(String, int) 之后处理部分测试运行记录 proto 错误。

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

如果报告程序支持精细的结果,则返回 True,否则返回 false。

final void testAssumptionFailure(TestDescription test, String trace)

在原子测试标记它假设条件为 false 时调用

final void testAssumptionFailure(TestDescription test, FailureDescription failure)

在原子测试标记它假设条件为 false 时调用

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

ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map)) 的替代方法,可用于指定结束时间 。

void 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)

报告测试运行结束。

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 testSkipped(TestDescription test, SkipReason reason)

在因通常不符合预期的原因跳过测试且未执行测试时调用。

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

公共方法

invocationEnded

public final void invocationEnded (long elapsedTime)

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

将由 TradeFederation 框架自动调用。

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

invocationFailed

public void invocationFailed (FailureDescription failure)

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

将由 TradeFederation 框架自动调用。

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

invocationFailed

public void invocationFailed (Throwable cause)

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

将由 TradeFederation 框架自动调用。

参数
cause Throwable:失败的 Throwable 原因

已跳过调用

public void invocationSkipped (SkipReason reason)

将调用报告为跳过

参数
reason SkipReason

invocationStarted

public final void invocationStarted (IInvocationContext context)

报告测试调用的开始。

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

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

logAssociation

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 LogFileLogFile 之前记录,应与 测试用例。

processFinalInvocationLogs

public void processFinalInvocationLogs (TestRecordProto.TestRecord invocationLogs)

使用调用记录逐个发送调用的所有最终日志。

参数
invocationLogs TestRecordProto.TestRecord:表示调用的最终 proto。

processFinalProto

public void processFinalProto (TestRecordProto.TestRecord finalRecord)

处理包含所有结果的最终 proto。

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

processStartInvocation

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

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

参数
invocationStartRecord TestRecordProto.TestRecord:在 invocationStart 后填充的部分 proto。

invocationContext IInvocationContext:调用 IInvocationContext

processTestCaseEnded

public void processTestCaseEnded (TestRecordProto.TestRecord testCaseRecord)

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

参数
testCaseRecord TestRecordProto.TestRecord:表示测试用例的最终 proto。

processTestCaseStarted

public void processTestCaseStarted (TestRecordProto.TestRecord testCaseStartedRecord)

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

参数
testCaseStartedRecord TestRecordProto.TestRecord:表示测试用例的部分 proto。

processTestModuleEnd

public void processTestModuleEnd (TestRecordProto.TestRecord moduleRecord)

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

参数
moduleRecord TestRecordProto.TestRecord:表示模块的最终 proto。

processTestModuleStarted

public void processTestModuleStarted (TestRecordProto.TestRecord moduleStartRecord)

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

参数
moduleStartRecord TestRecordProto.TestRecord:表示模块的部分 proto。

processTestRunEnded

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

ERROR(/#testRunEnded(long,HashMap)) 之后处理最终的运行记录 proto 错误。

参数
runRecord TestRecordProto.TestRecord:表示运行作业的最终 proto。

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

processTestRunStarted

public void processTestRunStarted (TestRecordProto.TestRecord runStartedRecord)

testRunStarted(String, int) 之后处理部分测试运行记录 proto 错误。

参数
runStartedRecord TestRecordProto.TestRecord:表示运行作业的部分 proto。

setGranularResults

public void setGranularResults (boolean granularResults)

参数
granularResults boolean

setInlineRecordOfChildren

public void setInlineRecordOfChildren (boolean inline)

参数
inline boolean

supportGranularResults

public boolean supportGranularResults ()

如果报告程序支持精细的结果,则返回 True,否则返回 false。

返回
boolean

testAssumptionFailure

public final void testAssumptionFailure (TestDescription test, 
                String trace)

在原子测试标记它假设条件为 false 时调用

参数
test TestDescription:标识测试

trace String:失败的堆栈轨迹

testAssumptionFailure

public final void testAssumptionFailure (TestDescription test, 
                FailureDescription failure)

在原子测试标记它假设条件为 false 时调用

参数
test TestDescription:标识测试

failure FailureDescription:描述失败情况及其上下文的 FailureDescription

testEnded

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)

testEnded

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 FailureDescription:描述失败情况及其上下文的 FailureDescription

测试失败

public final void testFailed (TestDescription test, 
                String trace)

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

将在 testStarted 和 testEnded 之间调用。

参数
test TestDescription:标识测试

trace String:失败的堆栈轨迹

testIgnored

public final void testIgnored (TestDescription test)

在不会运行测试时调用,通常是因为测试方法带有 org.junit.Ignore。

参数
test TestDescription:标识测试

testModuleEnded

public final void testModuleEnded ()

报告模块运行结束。

testModuleStarted

public final void testModuleStarted (IInvocationContext moduleContext)

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

参数
moduleContext IInvocationContext:模块的 IInvocationContext

testRunEnded

public final void testRunEnded (long elapsedTimeMillis, 
                 runMetrics)

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

参数
elapsedTimeMillis long:设备报告的所用时间(以毫秒为单位)

runMetrics :通过 Metric 运行测试运行结束时报告的键值对。

testRunFailed

public final void testRunFailed (FailureDescription failure)

由于“FailureDescription”所述的失败情况,未能完成报告测试运行。

参数
failure FailureDescription:描述失败情况及其上下文的 FailureDescription

testRunFailed

public final void testRunFailed (String errorMessage)

由于发生严重错误,未能完成报告测试运行。

参数
errorMessage StringString,用于说明运行失败的原因。

testRunStarted

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

报告测试运行开始。

参数
runName String:测试运行名称

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

attemptNumber int:订单号,用于标识同一 runName 的不同尝试 运行多次的命令tryNumber 从 0 开始编号,并且应该每次递增。 都会发生新的运行例如测试会精细地重试 3 次,总共应该有 4 次 以相同的 runName 运行,而 tryNumber 范围为 0 到 3。

testRunStarted

public final void testRunStarted (String runName, 
                int testCount)

报告测试运行开始。

参数
runName String:测试运行名称

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

testRunStarted

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

报告测试运行开始。

参数
runName String:测试运行名称

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

attemptNumber int:订单号,用于标识同一 runName 的不同尝试 运行多次的命令tryNumber 从 0 开始编号,并且应在每次 都会发生新的运行例如测试会精细地重试 3 次,总共应运行 4 次 位于同一个 runName 下,并且 tryNumber 范围是 0 到 3。

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

testSkipped(已跳过测试)

public final void testSkipped (TestDescription test, 
                SkipReason reason)

在因通常不符合预期的原因跳过测试且未执行测试时调用。 系统将尝试重新尝试这些测试,以确保正确执行。

参数
test TestDescription:标识测试

reason SkipReasonSkipReason

testStarted

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() 测量

testStarted

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