子进程结果报告器

public class SubprocessResultsReporter
extends Object implements ITestInvocationListener , ILogSaverListener , ISupportGranularResults

java.lang.Object
com.android.tradefed.result.SubprocessResultsReporter


实现ITestInvocationListener以指定为 result_reporter 并从子进程转发测试、测试运行、测试调用的结果。

概括

公共构造函数

SubprocessResultsReporter ()

公共方法

void close ()

TestSummary getSummary ()

允许 InvocationListener 返回摘要。

void invocationEnded (long elapsedTime)

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

void invocationFailed ( FailureDescription failure)

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

void invocationFailed (Throwable cause)

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

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 printEvent (String key, Object event)

帮助程序打印事件键,然后打印 json 对象。

void setOutputTestLog (boolean outputTestLog)

设置我们是否应该输出记录的测试。

boolean supportGranularResults ()

如果 reporter 支持粒度结果,则返回 True,否则返回 false。

void testAssumptionFailure ( TestDescription testId, String trace)

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

void testAssumptionFailure ( TestDescription testId, FailureDescription failure)

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

void testEnded ( TestDescription testId, long endTime, metrics) testEnded ( TestDescription testId, long endTime, metrics)

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

void testEnded ( TestDescription testId, metrics) testEnded ( TestDescription testId, metrics)

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

void testFailed ( TestDescription testId, FailureDescription failure)

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

void testFailed ( TestDescription testId, String reason)

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

void testIgnored ( TestDescription testId)

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

void testLog (String dataName, LogDataType dataType, InputStreamSource dataStream)

提供来自测试调用的关联日志或调试数据。

void testModuleEnded ()

报告模块运行结束。

void testModuleStarted ( IInvocationContext moduleContext)

报告模块运行的开始。

void testRunEnded (long time, runMetrics) testRunEnded (long time, runMetrics)

报告测试运行结束。

void testRunFailed ( FailureDescription failure)

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

void testRunFailed (String reason)

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

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

报告测试运行的开始。

void testRunStarted (String runName, int testCount)

报告测试运行的开始。

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

报告测试运行的开始。

void testRunStopped (long arg0)

由于用户请求,报告测试运行在完成之前停止。

void testStarted ( TestDescription testId, long startTime)

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

void testStarted ( TestDescription testId)

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

公共构造函数

子进程结果报告器

public SubprocessResultsReporter ()

公共方法

关闭

public void close ()

获取摘要

public TestSummary getSummary ()

允许 InvocationListener 返回摘要。

退货
TestSummary总结运行的TestSummary ,或 null

调用结束

public void invocationEnded (long elapsedTime)

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

将由 TradeFederation 框架自动调用。

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

调用失败

public void invocationFailed (FailureDescription failure)

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

将由 TradeFederation 框架自动调用。

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

调用失败

public void invocationFailed (Throwable cause)

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

将由 TradeFederation 框架自动调用。

参数
cause Throwable : 失败的ERROR(/Throwable)原因

调用开始

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 printEvent (String key, 
                Object event)

帮助程序打印事件键,然后打印 json 对象。

参数
key String

event Object

设置输出测试日志

public void setOutputTestLog (boolean outputTestLog)

设置我们是否应该输出记录的测试。

参数
outputTestLog boolean

支持粒度结果

public boolean supportGranularResults ()

如果 reporter 支持粒度结果,则返回 True,否则返回 false。

退货
boolean

测试假设失败

public void testAssumptionFailure (TestDescription testId, 
                String trace)

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

参数
testId TestDescription :标识测试

trace String :失败的堆栈跟踪

测试假设失败

public void testAssumptionFailure (TestDescription testId, 
                FailureDescription failure)

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

参数
testId TestDescription :标识测试

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

测试结束

public void testEnded (TestDescription testId, 
                long endTime, 
                 metrics)

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

参数
testId TestDescription :标识测试

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

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

测试结束

public void testEnded (TestDescription testId, 
                 metrics)

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

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

参数
testId TestDescription :标识测试

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

测试失败

public void testFailed (TestDescription testId, 
                FailureDescription failure)

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

将在 testStarted 和 testEnded 之间调用。

参数
testId TestDescription :标识测试

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

测试失败

public void testFailed (TestDescription testId, 
                String reason)

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

将在 testStarted 和 testEnded 之间调用。

参数
testId TestDescription :标识测试

reason String :失败的堆栈跟踪

测试忽略

public void testIgnored (TestDescription testId)

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

参数
testId TestDescription :标识测试

测试日志

public void testLog (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

提供来自测试调用的关联日志或调试数据。

必须在ERROR(/ITestInvocationListener#invocationFailed(Throwable))ERROR(/ITestInvocationListener#invocationEnded(long))之前调用

TradeFederation 框架将自动调用此方法,提供主机日志和设备 logcat(如果适用)。

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

dataType LogDataType :数据的LogDataType

dataStream InputStreamSource :数据的InputStreamSource 。实施者应调用 createInputStream 开始读取数据,并确保在完成后关闭生成的 InputStream。调用者应确保数据源保持存在且可访问,直到 testLog 方法完成。

测试模块结束

public void testModuleEnded ()

报告模块运行结束。

测试模块启动

public void testModuleStarted (IInvocationContext moduleContext)

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

参数
moduleContext IInvocationContext :模块的IInvocationContext

测试运行结束

public void testRunEnded (long time, 
                 runMetrics)

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

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

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

测试运行失败

public void testRunFailed (FailureDescription failure)

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

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

测试运行失败

public void testRunFailed (String reason)

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

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

测试运行开始

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

报告测试运行的开始。

参数
runName String : 测试运行名称

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

attemptNumber int : order number,标识同一 runName 多次运行的不同尝试。 attemptNumber 是从 0 开始索引的,每次发生新的运行时都应该递增。例如,一个测试被精细地重试了 3 次,它应该在同一个 runName 下总共运行 4 次,并且 attemptNumber 是从 0 到 3。

测试运行开始

public 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 : order number,标识同一 runName 多次运行的不同尝试。 attemptNumber 是从 0 开始索引的,每次发生新的运行时都应该递增。例如,一个测试被精细地重试了 3 次,它应该在同一个 runName 下总共运行 4 次,并且 attemptNumber 是从 0 到 3。

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

测试运行已停止

public void testRunStopped (long arg0)

由于用户请求,报告测试运行在完成之前停止。

TODO:目前未使用,考虑删除

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

测试开始

public void testStarted (TestDescription testId, 
                long startTime)

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

参数
testId TestDescription :标识测试

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

测试开始

public void testStarted (TestDescription testId)

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

参数
testId TestDescription :标识测试