ProtoResultReporter

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

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


结果报告程序会构建一个包含所有结果的 TestRecord protobuf。应进行扩展,以处理 processFinalProto(TestRecord) 中的最终 proto。

摘要

公共构造函数

ProtoResultReporter()

公共方法

final void invocationEnded(long elapsedTime)

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

void invocationFailed(FailureDescription failure)

报告因某些错误情况而导致的不完整调用。

void invocationFailed(Throwable cause)

报告因某些错误情况而导致的不完整调用。

void invocationSkipped(SkipReason reason)

报告调用已跳过

void invocationStarted(IInvocationContext context)

报告测试调用的开始。

final void logAssociation(String dataName, LogFile logFile)

在某些情况下,日志必须与测试用例紧密关联,但无法在直接 testLogSaved(String,LogDataType,InputStreamSource,LogFile) 回调中实现此目的。

void processFinalInvocationLogs(TestRecordProto.TestRecord invocationLogs)

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

void processFinalProto(TestRecordProto.TestRecord finalRecord)

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

void processStartInvocation(TestRecordProto.TestRecord invocationStartRecord, IInvocationContext invocationContext)

在发生 invocationStarted(IInvocationContext) 后,处理部分调用检测记录 proto。

void processTestCaseEnded(TestRecordProto.TestRecord testCaseRecord)

处理 testEnded(TestDescription,long,HashMap) 发生后的最终测试用例记录 proto。

void processTestCaseStarted(TestRecordProto.TestRecord testCaseStartedRecord)

处理 testStarted(TestDescription,long) 发生后的部分测试用例记录 proto。

void processTestModuleEnd(TestRecordProto.TestRecord moduleRecord)

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

void processTestModuleStarted(TestRecordProto.TestRecord moduleStartRecord)

在发生 testModuleStarted(IInvocationContext) 后处理部分模块记录 proto。

void processTestRunEnded(TestRecordProto.TestRecord runRecord, boolean moduleInProgress)

在发生 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, HashMap<String, MetricMeasurement.Metric> testMetrics)

testEnded(TestDescription,Map) 的替代方案,可直接指定结束时间。

void testEnded(TestDescription test, HashMap<String, MetricMeasurement.Metric> 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, HashMap<String, MetricMeasurement.Metric> 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(TestDescription) 的替代方案,其中还指定了测试开始时间,并与 testEnded(TestDescription,long,Map) 结合使用以实现精确衡量。

final void testStarted(TestDescription test)

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

受保护的方法

void afterModuleEnd()
void beforeModuleStart()
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 原因

invocationSkipped

public void invocationSkipped (SkipReason reason)

报告调用已跳过

参数
reason SkipReason

invocationStarted

public void invocationStarted (IInvocationContext context)

报告测试调用的开始。

将由 TradeFederation 框架自动调用。报告者需要替换此方法才能支持多设备报告。

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

logAssociation

public final void logAssociation (String dataName, 
                LogFile logFile)

在某些情况下,日志必须与测试用例紧密关联,但无法在直接 testLogSaved(String,LogDataType,InputStreamSource,LogFile) 回调中实现这一点。因此,此回调允许明确提供强关联。

参数
dataName String:数据的名称

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

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(IInvocationContext) 发生后的部分调用检测记录 proto。

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

invocationContext IInvocationContext:调用 IInvocationContext

processTestCaseEnded

public void processTestCaseEnded (TestRecordProto.TestRecord testCaseRecord)

在发生 testEnded(TestDescription,long,HashMap) 后,对最终确定的测试用例记录 proto 的处理。

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

processTestCaseStarted

public void processTestCaseStarted (TestRecordProto.TestRecord testCaseStartedRecord)

处理 testStarted(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(IInvocationContext) 后,对部分模块记录 proto 的处理。

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

processTestRunEnded

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

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, 
                HashMap<String, MetricMeasurement.Metric> testMetrics)

testEnded(TestDescription,Map) 的替代方案,可直接指定结束时间。与 testStarted(TestDescription,long) 结合使用,可实现精确衡量。

参数
test TestDescription:标识测试

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

testMetrics HashMap:所发出指标的 Map

testEnded

public void testEnded (TestDescription test, 
                HashMap<String, MetricMeasurement.Metric> testMetrics)

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

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

参数
test TestDescription:标识测试

testMetrics HashMap:所发出指标的 Map

testFailed

public final void testFailed (TestDescription test, 
                FailureDescription failure)

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

将在 testStarted 和 testEnded 之间调用。

参数
test TestDescription:标识测试

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

testFailed

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() 相关联,在序列中是可选的。仅在运行使用模块(基于套件的运行程序)时使用。

参数
moduleContext IInvocationContext:模块的 IInvocationContext

testRunEnded

public final void testRunEnded (long elapsedTimeMillis, 
                HashMap<String, MetricMeasurement.Metric> runMetrics)

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

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

runMetrics HashMap:在测试运行结束时通过 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 的不同尝试的订单号。attemptNumber 的索引从 0 开始,每次新运行时都应递增。例如,如果某测试细粒度重试 3 次,则在同一 runName 下应总共有 4 次运行,且 attemptNumber 从 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 的不同尝试的订单号。attemptNumber 从 0 开始,每次新运行时都会递增。例如,如果某个测试进行了 3 次精细重试,则在同一 runName 下,该测试总共应运行 4 次,且 attemptNumber 为 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(TestDescription) 的替代方案,我们还指定了测试开始时间,并与 testEnded(TestDescription,long,Map) 结合使用以实现精确衡量。

参数
test TestDescription:标识测试

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

testStarted

public final void testStarted (TestDescription test)

报告单个测试用例的开始。旧版接口,应尽可能使用 testStarted(TestDescription)

参数
test TestDescription:标识测试

受保护的方法

afterModuleEnd

protected void afterModuleEnd ()

beforeModuleStart

protected void beforeModuleStart ()

createModuleChildReference

protected TestRecordProto.ChildReference createModuleChildReference (TestRecordProto.TestRecord record)

为模块创建子级引用。

参数
record TestRecordProto.TestRecord

返回值
TestRecordProto.ChildReference