TestResultListener

public abstract class TestResultListener
extends Object implements ITestLifeCycleReceiver

java.lang.Object
   ↳ com.android.tradefed.result.TestResultListener


针对仅关注单个测试结果的实现者,对 ITestLifecycleListener 进行简化。

它将各种生命周期事件过滤到 testResult 方法。

它不是线程安全的,尤其假设 ITestLifecycleListener 事件是按顺序接收的。

摘要

公共构造函数

TestResultListener()

公共方法

final void testAssumptionFailure(TestDescription test, String trace)

当原子测试标记其假设的条件为 false 时调用

final void testEnded(TestDescription test, long endTime, Map<String, String> testMetrics)

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

final void testEnded(TestDescription test, long endTime, HashMap<String, MetricMeasurement.Metric> testMetrics)

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

final void testEnded(TestDescription test, Map<String, String> testMetrics)

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

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

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

final void testFailed(TestDescription test, String trace)

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

final void testIgnored(TestDescription test)

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

abstract void testResult(TestDescription test, TestResult result)
void testRunEnded(long elapsedTimeMillis, HashMap<String, MetricMeasurement.Metric> runMetrics)

报告测试运行结束。

void testSkipped(TestDescription test, SkipReason reason)

当测试因通常不预期的原因而被跳过且未执行时调用。

final void testStarted(TestDescription test, long startTime)

testStarted(TestDescription) 的替代方案,其中还指定了测试开始时间,并与 testEnded(TestDescription,long,Map) 结合使用以实现精确衡量。

final void testStarted(TestDescription test)

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

公共构造函数

TestResultListener

public TestResultListener ()

公共方法

testAssumptionFailure

public final void testAssumptionFailure (TestDescription test, 
                String trace)

当原子测试标记其假设的条件为 false 时调用

参数
test TestDescription:标识测试

trace String:失败的堆栈轨迹

testEnded

public final void testEnded (TestDescription test, 
                long endTime, 
                Map<String, String> testMetrics)

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

参数
test TestDescription:标识测试

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

testMetrics Map:所发出指标的 Map

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 final void testEnded (TestDescription test, 
                Map<String, String> testMetrics)

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

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

参数
test TestDescription:标识测试

testMetrics Map:所发出指标的 Map

testEnded

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

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

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

参数
test TestDescription:标识测试

testMetrics HashMap:所发出指标的 Map

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:标识测试

testResult

public abstract void testResult (TestDescription test, 
                TestResult result)

参数
test TestDescription

result TestResult

testRunEnded

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

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

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

runMetrics HashMap:在测试运行结束时通过 Metric 报告的键值对。

testSkipped

public 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:标识测试