SubprocessResultsReporter
public
class
SubprocessResultsReporter
extends Object
implements
ILogSaverListener,
ISupportGranularResults,
ITestInvocationListener
| 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)
在某些情况下,日志必须与测试用例强相关联,但无法在直接 |
void
|
printEvent(String key, Object event)
用于输出事件键和 JSON 对象的辅助程序。 |
void
|
setOutputTestLog(boolean outputTestLog)
设置是否应输出已记录的测试。 |
boolean
|
supportGranularResults()
如果报告程序支持精细结果,则返回 True;否则返回 False。 |
void
|
testAssumptionFailure(TestDescription testId, String trace)
当原子测试标记为假的假设条件时调用 |
void
|
testAssumptionFailure(TestDescription testId, FailureDescription failure)
当原子测试标记为假的假设条件时调用 |
void
|
testEnded(TestDescription testId, long endTime,
|
void
|
testEnded(TestDescription testId,
报告单个测试用例的执行结束。 |
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,
报告测试运行结束。 |
void
|
testRunFailed(FailureDescription failure)
由于 |
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
|
testSkipped(TestDescription testId, SkipReason reason)
当测试因通常不预期的某种原因而被跳过且未执行时调用。 |
void
|
testStarted(TestDescription testId, long startTime)
|
void
|
testStarted(TestDescription testId)
报告单个测试用例的开始。 |
公共构造函数
SubprocessResultsReporter
public SubprocessResultsReporter ()
公共方法
关闭
public void close ()
getSummary
public TestSummary getSummary ()
允许 InvocationListener 返回摘要。
| 返回 | |
|---|---|
TestSummary |
用于总结运行情况的 TestSummary,或 null |
invocationEnded
public 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 原因 |
invocationStarted
public void invocationStarted (IInvocationContext context)
报告测试调用的开始。
将由 TradeFederation 框架自动调用。报告程序需要替换此方法才能支持多设备报告。
| 参数 | |
|---|---|
context |
IInvocationContext:调用相关信息 |
logAssociation
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,应与测试用例相关联。 |
printEvent
public void printEvent (String key,
Object event)用于输出事件键和 JSON 对象的辅助程序。
| 参数 | |
|---|---|
key |
String |
event |
Object |
setOutputTestLog
public void setOutputTestLog (boolean outputTestLog)
设置是否应输出已记录的测试。
| 参数 | |
|---|---|
outputTestLog |
boolean |
supportGranularResults
public boolean supportGranularResults ()
如果报告程序支持精细结果,则返回 True;否则返回 False。
| 返回 | |
|---|---|
boolean |
|
testAssumptionFailure
public void testAssumptionFailure (TestDescription testId, String trace)
当原子测试标记为假的假设条件时调用
| 参数 | |
|---|---|
testId |
TestDescription:用于标识测试 |
trace |
String:失败的堆栈轨迹 |
testAssumptionFailure
public void testAssumptionFailure (TestDescription testId, FailureDescription failure)
当原子测试标记为假的假设条件时调用
| 参数 | |
|---|---|
testId |
TestDescription:用于标识测试 |
failure |
FailureDescription:描述失败及其上下文的 FailureDescription。 |
testEnded
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:测试结束的时间,通过 System.currentTimeMillis() 测量 |
metrics |
:发出的指标的 ERROR(/Map) |
testEnded
public void testEnded (TestDescription testId,metrics)
报告单个测试用例的执行结束。
如果未调用 testFailed(TestDescription, FailureDescription),则表示此测试已通过。此外,还会返回测试用例执行期间可能发出的任何键值指标。
| 参数 | |
|---|---|
testId |
TestDescription:用于标识测试 |
metrics |
:发出的指标的 ERROR(/Map) |
testFailed
public void testFailed (TestDescription testId, FailureDescription failure)
报告单个测试用例的失败。
将在 testStarted 和 testEnded 之间调用。
| 参数 | |
|---|---|
testId |
TestDescription:用于标识测试 |
failure |
FailureDescription:描述失败及其上下文的 FailureDescription。 |
testFailed
public void testFailed (TestDescription testId, String reason)
报告单个测试用例的失败。
将在 testStarted 和 testEnded 之间调用。
| 参数 | |
|---|---|
testId |
TestDescription:用于标识测试 |
reason |
String:失败的堆栈轨迹 |
testIgnored
public void testIgnored (TestDescription testId)
在系统不会运行测试时调用,通常是因为测试方法带有 org.junit.Ignore 注解。
| 参数 | |
|---|---|
testId |
TestDescription:用于标识测试 |
testLog
public void testLog (String dataName,
LogDataType dataType,
InputStreamSource dataStream)提供测试调用中的关联日志或调试数据。
必须在 ERROR(/ITestInvocationListener#invocationFailed(Throwable)) 或 ERROR(/ITestInvocationListener#invocationEnded(long)) 之前调用
TradeFederation 框架会自动调用此方法,提供主机日志和(如果适用)设备 logcat。
| 参数 | |
|---|---|
dataName |
String:数据的 String 描述性名称,例如“device_logcat”。注意:每次调用时,dataName 可能不唯一。即,实现者必须能够处理具有相同 dataName 的多次调用 |
dataType |
LogDataType:数据的 LogDataType |
dataStream |
InputStreamSource:数据的 InputStreamSource。实现人员应调用 createInputStream 以开始读取数据,并确保在完成后关闭生成的 InputStream。调用方应确保数据源在 testLog 方法完成之前保持存在且可访问。 |
testModuleEnded
public void testModuleEnded ()
报告模块运行结束。
testModuleStarted
public void testModuleStarted (IInvocationContext moduleContext)
报告模块运行的开始时间。此回调与 testModuleEnded() 相关联,在序列中是可选的。它仅在使用模块(基于套件的运行程序)的运行期间使用。
| 参数 | |
|---|---|
moduleContext |
IInvocationContext:模块的 IInvocationContext。 |
testRunEnded
public void testRunEnded (long time,
runMetrics) 报告测试运行结束。
| 参数 | |
|---|---|
time |
long:设备报告的经过时间(以毫秒为单位) |
runMetrics |
:测试运行结束时报告的键值对 |
testRunFailed
public void testRunFailed (FailureDescription failure)
由于 FailureDescription 所述的失败,报告测试运行未能完成。
| 参数 | |
|---|---|
failure |
FailureDescription:描述失败及其上下文的 FailureDescription。 |
testRunFailed
public void testRunFailed (String reason)
由于出现严重错误,报告测试运行未能完成。
| 参数 | |
|---|---|
reason |
String:String,用于说明运行失败的原因。 |
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 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() 测量 |
testRunStopped
public void testRunStopped (long arg0)
报告测试运行在完成之前因用户请求而停止。
TODO:目前未使用,考虑移除
| 参数 | |
|---|---|
arg0 |
long:设备报告的经过时间(以毫秒为单位) |
testSkipped
public void testSkipped (TestDescription testId, SkipReason reason)
当测试因非预期原因而被跳过且未执行时调用。 系统会尝试重试这些测试,以便正确执行。
| 参数 | |
|---|---|
testId |
TestDescription:用于标识测试 |
reason |
SkipReason:SkipReason |
testStarted
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:测试开始的时间,通过 System.currentTimeMillis() 测量 |
testStarted
public void testStarted (TestDescription testId)
报告单个测试用例的开始。旧版接口,应尽可能使用 testStarted(com.android.tradefed.result.TestDescription)。
| 参数 | |
|---|---|
testId |
TestDescription:用于标识测试 |