ShardListener
public
class
ShardListener
extends CollectingTestListener
implements
ISupportGranularResults
| java.lang.Object | ||
| ↳ | com.android.tradefed.result.CollectingTestListener | |
| ↳ | com.android.tradefed.invoker.ShardListener | |
一种 ITestInvocationListener,用于从调用分片(即拆分后的调用,可在多个资源上并行运行)收集结果,并将结果转发给另一个监听器。
摘要
公共构造函数 | |
|---|---|
ShardListener(ITestInvocationListener main)
创建 |
|
公共方法 | |
|---|---|
List<ITestInvocationListener>
|
getUnderlyingResultReporter()
|
void
|
invocationEnded(long elapsedTime)
报告调用已终止,无论是成功终止还是因某些错误情况而终止。 |
void
|
invocationFailed(FailureDescription failure)
报告因某些错误情况而导致的不完整调用。 |
void
|
invocationFailed(Throwable cause)
报告因某些错误情况而导致的不完整调用。 |
void
|
invocationSkipped(SkipReason reason)
报告调用已跳过 |
void
|
invocationStarted(IInvocationContext context)
报告测试调用的开始。 |
void
|
logAssociation(String dataName, LogFile logFile)
在某些情况下,日志必须与测试用例紧密关联,但无法在直接 |
void
|
setSupportGranularResults(boolean enableGranularResults)
|
boolean
|
supportGranularResults()
如果报告器支持精细结果,则返回 True,否则返回 False。 |
void
|
testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)
提供测试调用中的相关日志或调试数据。 |
void
|
testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)
|
void
|
testModuleEnded()
报告模块运行结束。 |
void
|
testModuleStarted(IInvocationContext moduleContext)
报告模块运行的开始时间。 |
void
|
testRunEnded(long elapsedTime, HashMap<String, MetricMeasurement.Metric> runMetrics)
报告测试运行结束。 |
void
|
testRunFailed(FailureDescription failure)
报告测试运行因 |
void
|
testRunFailed(String failureMessage)
由于出现严重错误,报告测试运行未能完成。 |
void
|
testRunStarted(String name, int numTests, int attemptNumber, long startTime)
报告测试运行的开始。 |
公共构造函数
ShardListener
public ShardListener (ITestInvocationListener main)
创建 ShardListener 网址。
| 参数 | |
|---|---|
main |
ITestInvocationListener:应转发结果的 ITestInvocationListener。为防止与其他 ShardListener 发生冲突,此对象在转发结果时将同步到 main。并且只有在调用分片完成时才会发送结果。 |
公共方法
getUnderlyingResultReporter
public List<ITestInvocationListener> getUnderlyingResultReporter ()
| 返回 | |
|---|---|
List<ITestInvocationListener> |
|
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,LogDataType,InputStreamSource,LogFile) 回调中实现这一点。因此,此回调允许明确提供强关联。
| 参数 | |
|---|---|
dataName |
String:数据的名称 |
logFile |
LogFile:之前记录的 LogFile,应与测试用例相关联。 |
setSupportGranularResults
public void setSupportGranularResults (boolean enableGranularResults)
| 参数 | |
|---|---|
enableGranularResults |
boolean |
supportGranularResults
public boolean supportGranularResults ()
如果报告器支持精细结果,则返回 True,否则返回 False。
| 返回 | |
|---|---|
boolean |
|
testLog
public void testLog (String dataName,
LogDataType dataType,
InputStreamSource dataStream)提供测试调用中的相关日志或调试数据。
必须在 ERROR(ITestInvocationListener.invocationFailed(Throwable)/ITestInvocationListener#invocationFailed(java.lang.Throwable) ITestInvocationListener.invocationFailed(Throwable)) 或 ERROR(/ITestInvocationListener#invocationEnded(long)) 之前调用
TradeFederation 框架会自动调用此方法,并提供主机日志和设备 logcat(如果适用)。
| 参数 | |
|---|---|
dataName |
String:数据的描述性名称。例如“device_logcat”。String注意:dataName 在每次调用时可能不是唯一的。也就是说,实现者必须能够处理具有相同 dataName 的多次调用 |
dataType |
LogDataType:数据的 LogDataType |
dataStream |
InputStreamSource:数据的 InputStreamSource。实现者应调用 createInputStream 开始读取数据,并确保在完成后关闭生成的 InputStream。调用方应确保数据源在 testLog 方法完成之前保持存在且可访问。 |
testLogSaved
public void testLogSaved (String dataName,
LogDataType dataType,
InputStreamSource dataStream,
LogFile logFile)| 参数 | |
|---|---|
dataName |
String |
dataType |
LogDataType |
dataStream |
InputStreamSource |
logFile |
LogFile |
testModuleEnded
public void testModuleEnded ()
报告模块运行结束。
testModuleStarted
public void testModuleStarted (IInvocationContext moduleContext)
报告模块运行的开始时间。此回调与 testModuleEnded() 相关联,在序列中是可选的。仅在运行使用模块(基于套件的运行程序)时使用。
| 参数 | |
|---|---|
moduleContext |
IInvocationContext:模块的 IInvocationContext。 |
testRunEnded
public void testRunEnded (long elapsedTime,
HashMap<String, MetricMeasurement.Metric> runMetrics)报告测试运行结束。FIXME:我们不能有两个具有不同类型的 Map<> 接口,因此我们必须在此处使用 HashMap。
| 参数 | |
|---|---|
elapsedTime |
long:设备报告的已用时间,以毫秒为单位 |
runMetrics |
HashMap:在测试运行结束时通过 Metric 报告的键值对。 |
testRunFailed
public void testRunFailed (FailureDescription failure)
报告测试运行因 FailureDescription 所述的失败而未能完成。
| 参数 | |
|---|---|
failure |
FailureDescription:描述失败及其上下文的 FailureDescription。 |
testRunFailed
public void testRunFailed (String failureMessage)
由于出现严重错误,报告测试运行未能完成。
| 参数 | |
|---|---|
failureMessage |
String:String,用于描述运行失败的原因。 |
testRunStarted
public void testRunStarted (String name,
int numTests,
int attemptNumber,
long startTime)报告测试运行的开始。
| 参数 | |
|---|---|
name |
String:测试运行名称 |
numTests |
int:测试运行中的测试总数 |
attemptNumber |
int:用于标识多次运行的同一 runName 的不同尝试的订单号。attemptNumber 从 0 开始,每次新运行时都会递增。例如,如果某个测试进行了 3 次精细重试,则在同一 runName 下,该测试总共应运行 4 次,且 attemptNumber 为 0 到 3。 |
startTime |
long:运行开始时间,通过 System.currentTimeMillis() 测量 |