BugreportCollector

public class BugreportCollector
extends Object implements ITestInvocationListener

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


一种透传 ITestInvocationListener,用于在发生可配置事件时收集 bugreport,然后在收集每个 bugreport 后对其子项调用 ITestInvocationListener#testLog

行为:(FIXME:完成此操作)

  • 如果有任何测试用例失败,则在每次运行后捕获
  • 在每个测试用例后捕获
  • 在每次失败的测试用例后捕获
  • 捕获

摘要

嵌套类

enum BugreportCollector.Filter

 

enum BugreportCollector.Freq

 

enum BugreportCollector.Noun

 

class BugreportCollector.Predicate

用于描述何时捕获 bug 报告的完整谓词。 

enum BugreportCollector.Relation

 

interface BugreportCollector.SubPredicate

 

字段

public static final BugreportCollector.Predicate AFTER_FAILED_TESTCASES

在每次失败的测试用例后触发的预定义谓词

public static final BugreportCollector.Predicate AT_START

一个预定义的谓词,会在首次调用开始时触发

公共构造函数

BugreportCollector(ITestInvocationListener listener, ITestDevice testDevice)

公共方法

void addPredicate(BugreportCollector.Predicate p)
void blockUntilIdle()

阻塞,直到收集器停止收集任何 bug 报告。

TestSummary getSummary()

void invocationEnded(long elapsedTime)

void invocationFailed(Throwable cause)

void invocationStarted(IInvocationContext context)

void setAsynchronous(boolean asynchronous)

设置 bugreport 收集功能是应在其他线程中收集 bugreport (asynchronous = true),还是应在捕获 bugreport 之前阻塞调用方 (asynchronous = false)。

void setDescriptiveName(String name)

设置在记录 bug 报告时要使用的描述性名称。

void setDeviceWaitTime(int waitTime)

设置在尝试捕获 bug 报告之前等待设备处于在线状态的时长(以秒为单位)。

void testAssumptionFailure(TestDescription test, String trace)

void testEnded(TestDescription test, testMetrics)
void testFailed(TestDescription test, String trace)

void testIgnored(TestDescription test)
void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)

void testRunEnded(long elapsedTime, runMetrics)

void testRunFailed(String errorMessage)

void testRunStarted(String runName, int testCount)

void testRunStopped(long elapsedTime)

void testStarted(TestDescription test)

字段

AFTER_FAILED_TESTCASES

public static final BugreportCollector.Predicate AFTER_FAILED_TESTCASES

一个预定义的谓词,用于在每次失败的测试用例后触发

AT_START

public static final BugreportCollector.Predicate AT_START

一个预定义的谓词,会在首次调用开始时触发

公共构造函数

BugreportCollector

public BugreportCollector (ITestInvocationListener listener, 
                ITestDevice testDevice)

参数
listener ITestInvocationListener

testDevice ITestDevice

公共方法

addPredicate

public void addPredicate (BugreportCollector.Predicate p)

参数
p BugreportCollector.Predicate

blockUntilIdle

public void blockUntilIdle ()

阻塞,直到收集器停止收集任何 bug 报告。如果收集器未在积极收集 bugreport,则立即返回

getSummary

public TestSummary getSummary ()

返回
TestSummary

invocationEnded

public void invocationEnded (long elapsedTime)

参数
elapsedTime long

invocationFailed

public void invocationFailed (Throwable cause)

参数
cause Throwable

invocationStarted

public void invocationStarted (IInvocationContext context)

参数
context IInvocationContext

setAsynchronous

public void setAsynchronous (boolean asynchronous)

设置 bugreport 收集功能是应在其他线程中收集 bugreport (asynchronous = true),还是应在捕获 bugreport 之前阻塞调用方 (asynchronous = false)。

参数
asynchronous boolean

setDescriptiveName

public void setDescriptiveName (String name)

设置在记录 bug 报告时要使用的描述性名称。如果为 nullBugreportCollector 将回退到默认行为,即序列化导致收集 bugreport 的事件的名称。

参数
name String

setDeviceWaitTime

public void setDeviceWaitTime (int waitTime)

设置在尝试捕获 bug 报告之前等待设备处于在线状态的时长(以秒为单位)。如果为负,则不会执行任何检查。在此检查期间遇到的任何 DeviceNotAvailableException 都将记录并忽略。

参数
waitTime int

testAssumptionFailure

public void testAssumptionFailure (TestDescription test, 
                String trace)

参数
test TestDescription

trace String

testEnded

public void testEnded (TestDescription test, 
                 testMetrics)

参数
test TestDescription

testMetrics

testFailed

public void testFailed (TestDescription test, 
                String trace)

参数
test TestDescription

trace String

testIgnored

public void testIgnored (TestDescription test)

参数
test TestDescription

testLog

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

参数
dataName String

dataType LogDataType

dataStream InputStreamSource

testRunEnded

public void testRunEnded (long elapsedTime, 
                 runMetrics)

参数
elapsedTime long

runMetrics

testRunFailed

public void testRunFailed (String errorMessage)

参数
errorMessage String

testRunStarted

public void testRunStarted (String runName, 
                int testCount)

参数
runName String

testCount int

testRunStopped

public void testRunStopped (long elapsedTime)

参数
elapsedTime long

testStarted

public void testStarted (TestDescription test)

参数
test TestDescription