模块监听器
public class ModuleListener
extends CollectingTestListener
java.lang.Object | ||
↳ | com.android.tradefed.result.CollectingTestListener | |
↳ | com.android.tradefed.testtype.suite.ModuleListener |
侦听器附加到每个模块的每个IRemoteTest
以收集结果列表。
概括
公共构造函数 | |
---|---|
ModuleListener ( ITestInvocationListener listener, IInvocationContext moduleContext) 构造函数。 |
公共方法 | |
---|---|
boolean | hasLastAttemptFailed () 返回侦听器上次重试会话是否失败。 |
void | logAssociation (String dataName, LogFile logFile) 在某些情况下,日志必须与测试用例强关联,但有机会这样做就直接 |
void | setAttemptIsolation ( CurrentInvocation.IsolationGrade isolation) 设置是否应将尝试报告为孤立的。 |
void | setCollectTestsOnly (boolean collectTestsOnly) 设置我们是否只收集测试。 |
void | setMarkTestsSkipped (boolean skip) 是否将所有测试用例标记为跳过。 |
void | setTestMappingSources ( testMappingSources) setTestMappingSources ( testMappingSources) 设置将插入到指标中的测试映射源。 |
void | testAssumptionFailure ( TestDescription test, String trace) 当原子测试标记其假定条件为 false 时调用 |
void | testAssumptionFailure ( TestDescription test, FailureDescription failure) 当原子测试标记其假定条件为 false 时调用 |
void | testEnded ( TestDescription test, long endTime, testMetrics) testEnded ( TestDescription test, long endTime, testMetrics) |
void | testEnded ( TestDescription test, testMetrics) testEnded ( TestDescription test, testMetrics) 报告单个测试用例的执行结束。 |
void | testFailed ( TestDescription test, FailureDescription failure) 报告单个测试用例的失败。 |
void | testFailed ( TestDescription test, String trace) 报告单个测试用例的失败。 |
void | testIgnored ( TestDescription test) 当测试不会运行时调用,通常是因为测试方法用 org.junit.Ignore 注解。 |
void | testLog (String dataName, LogDataType dataType, InputStreamSource dataStream) |
void | testLogSaved (String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile) |
void | testRunEnded (long elapsedTime, runMetrics) testRunEnded (long elapsedTime, runMetrics) 报告测试运行结束。 |
void | testRunFailed ( FailureDescription failure) 报告测试运行由于 |
void | testRunFailed (String errorMessage) 报告测试运行由于致命错误而未能完成。 |
void | testRunStarted (String name, int numTests, int attemptNumber) 报告测试运行的开始。 |
void | testRunStarted (String name, int numTests, int attemptNumber, long startTime) 报告测试运行的开始。 |
void | testStarted ( TestDescription test, long startTime) |
公共构造函数
模块监听器
public ModuleListener (ITestInvocationListener listener, IInvocationContext moduleContext)
构造函数。
参数 | |
---|---|
listener | ITestInvocationListener |
moduleContext | IInvocationContext |
公共方法
上次尝试失败
public boolean hasLastAttemptFailed ()
返回侦听器上次重试会话是否失败。
退货 | |
---|---|
boolean |
日志关联
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 setAttemptIsolation (CurrentInvocation.IsolationGrade isolation)
设置是否应将尝试报告为孤立的。
参数 | |
---|---|
isolation | CurrentInvocation.IsolationGrade |
仅设置收集测试
public void setCollectTestsOnly (boolean collectTestsOnly)
设置我们是否只收集测试。
参数 | |
---|---|
collectTestsOnly | boolean |
设置跳过的标记测试
public void setMarkTestsSkipped (boolean skip)
是否将所有测试用例标记为跳过。
参数 | |
---|---|
skip | boolean |
设置测试映射源
public void setTestMappingSources (testMappingSources)
设置将插入到指标中的测试映射源。
参数 | |
---|---|
testMappingSources |
测试假设失败
public void testAssumptionFailure (TestDescription test, String trace)
当原子测试标记其假定条件为 false 时调用
参数 | |
---|---|
test | TestDescription :标识测试 |
trace | String : 失败的堆栈跟踪 |
测试假设失败
public void testAssumptionFailure (TestDescription test, FailureDescription failure)
当原子测试标记其假定条件为 false 时调用
参数 | |
---|---|
test | TestDescription :标识测试 |
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
测试结束
public 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) |
测试结束
public void testEnded (TestDescription test,testMetrics)
报告单个测试用例的执行结束。
如果未调用testFailed(TestDescription, FailureDescription)
,则此测试通过。还返回测试用例执行期间可能发出的任何键/值指标。
参数 | |
---|---|
test | TestDescription :标识测试 |
testMetrics | ERROR(/Map) |
测试失败
public void testFailed (TestDescription test, FailureDescription failure)
报告单个测试用例的失败。
将在 testStarted 和 testEnded 之间调用。
参数 | |
---|---|
test | TestDescription :标识测试 |
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
测试失败
public void testFailed (TestDescription test, String trace)
报告单个测试用例的失败。
将在 testStarted 和 testEnded 之间调用。
参数 | |
---|---|
test | TestDescription :标识测试 |
trace | String : 失败的堆栈跟踪 |
测试被忽略
public void testIgnored (TestDescription test)
当测试不会运行时调用,通常是因为测试方法用 org.junit.Ignore 注解。
参数 | |
---|---|
test | TestDescription :标识测试 |
测试日志
public void testLog (String dataName, LogDataType dataType, InputStreamSource dataStream)
参数 | |
---|---|
dataName | String |
dataType | LogDataType |
dataStream | InputStreamSource |
测试日志已保存
public void testLogSaved (String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)
参数 | |
---|---|
dataName | String |
dataType | LogDataType |
dataStream | InputStreamSource |
logFile | LogFile |
测试运行结束
public void testRunEnded (long elapsedTime,runMetrics)
报告测试运行结束。 FIXME:我们不能有两个不同类型的 Map<> 接口,所以我们必须在这里使用 HashMap。
参数 | |
---|---|
elapsedTime | long :设备报告的经过时间,以毫秒为单位 |
runMetrics | Metric 测试运行结束时报告的键值对。 |
测试运行失败
public void testRunFailed (FailureDescription failure)
报告测试运行由于FailureDescription
描述的故障而未能完成。
参数 | |
---|---|
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
测试运行失败
public void testRunFailed (String errorMessage)
报告测试运行由于致命错误而未能完成。
参数 | |
---|---|
errorMessage | String :描述运行失败原因的String 。 |
测试运行开始
public void testRunStarted (String name, int numTests, int attemptNumber)
报告测试运行的开始。
参数 | |
---|---|
name | String : 测试运行名称 |
numTests | int : 测试运行中的测试总数 |
attemptNumber | int :订单号,标识同一 runName 多次运行的不同尝试。 attemptsNumber 是从 0 开始索引的,并且每次新的运行发生时都应该递增。例如,一个测试被粒度重试 3 次,它应该在同一 runName 下总共运行 4 次,并且 attemptsNumber 从 0 到 3。 |
测试运行开始
public void testRunStarted (String name, int numTests, int attemptNumber, long startTime)
报告测试运行的开始。
参数 | |
---|---|
name | String : 测试运行名称 |
numTests | int : 测试运行中的测试总数 |
attemptNumber | int :订单号,标识同一 runName 多次运行的不同尝试。 attemptsNumber 是从 0 开始索引的,并且每次新的运行发生时都应该递增。例如,一个测试被粒度重试 3 次,它应该在同一 runName 下总共运行 4 次,并且 attemptsNumber 从 0 到 3。 |
startTime | long :运行开始的时间,通过System.currentTimeMillis() 测量 |
测试开始
public 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() 测量 |