XmlResultReporter
  public
  
  
  
  class
  XmlResultReporter
  
  
  
  
    extends CollectingTestListener
  
  
  
  
  
      implements
      
        ILogSaverListener
      
  
  
| java.lang.Object | ||
| ↳ | com.android.tradefed.result.CollectingTestListener | |
| ↳ | com.android.tradefed.result.XmlResultReporter | |
将 JUnit 结果以与 Ant 的 XMLJUnitResultFormatter 一致的格式写入 XML 文件。
与 Ant 的格式设置器不同,此类不会报告测试的执行时间。
收集内存中的所有测试信息,然后在调用完成时转储到文件。
从 dalvik 运行程序 XmlReportPrinter 移植而来。
结果文件将存储在通过 [--output-file-path]/[build_id] 构建的路径中
摘要
公共构造函数 | |
|---|---|
      
      XmlResultReporter()
      
      
     | 
  |
公共方法 | |
|---|---|
        
        
        
        
        
        void
     | 
  
    
      
      invocationEnded(long elapsedTime)
      
      
        报告调用已终止,无论是成功终止还是因某种错误条件而终止。  | 
  
        
        
        
        
        
        void
     | 
  
    
      
      setLogSaver(ILogSaver logSaver)
      
      
        设置   | 
  
        
        
        
        
        
        void
     | 
  
    
      
      testFailed(TestDescription test, String trace)
      
      
        报告单个测试用例的失败。  | 
  
        
        
        
        
        
        void
     | 
  
    
      
      testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)
      
      
        提供测试调用中的关联日志或调试数据。  | 
  
        
        
        
        
        
        void
     | 
  
    
      
      testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)
      
      
        在保存测试日志时调用。  | 
  
公共构造函数
XmlResultReporter
public XmlResultReporter ()
公共方法
invocationEnded
public void invocationEnded (long elapsedTime)
报告调用已终止,无论是成功终止还是因某种错误条件而终止。
将由 TradeFederation 框架自动调用。
| 参数 | |
|---|---|
elapsedTime | 
        
          long:调用的用时(以毫秒为单位) | 
      
setLogSaver
public void setLogSaver (ILogSaver logSaver)
设置 ILogSaver 以允许实现者保存文件。
| 参数 | |
|---|---|
logSaver | 
        
          ILogSaver:ILogSaver | 
      
testFailed
public void testFailed (TestDescription test, String trace)
报告单个测试用例的失败。
将在 testStarted 和 testEnded 之间调用。
| 参数 | |
|---|---|
test | 
        
          TestDescription:用于标识测试 | 
      
trace | 
        
          String:失败的堆栈轨迹 | 
      
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 方法完成之前保持存在且可访问。 | 
      
testLogSaved
public void testLogSaved (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream, 
                LogFile logFile)在保存测试日志时调用。
应改为使用 ITestInvocationListener.testLog(String, LogDataType,
 InputStreamSource)。
| 参数 | |
|---|---|
dataName | 
        
          String:数据的 String 描述性名称,例如“device_logcat”。注意:每次调用时,dataName 可能不唯一。即,实现者必须能够处理具有相同 dataName 的多次调用 | 
      
dataType | 
        
          LogDataType:数据的 LogDataType | 
      
dataStream | 
        
          InputStreamSource:数据的 InputStreamSource。实现人员应调用 createInputStream 以开始读取数据,并确保在完成后关闭生成的 InputStream。 | 
      
logFile | 
        
          LogFile:包含已保存文件的元数据的 LogFile。 |