GTestResultParser

public class GTestResultParser
extends MultiLineReceiver

java.lang.Object 中
   ↳ com.android.ddmlib.MultiLineReceiver
     ↳ com.android.tradefed.testtype.GTestResultParser


解析“原始输出模式”使用 GTest 从 shell 运行的原生测试的结果,并告知 结果的 ITestInvocationListener。

预期的输出格式示例:

 [==========] Running 15 tests from 1 test case.
 [----------] Global test environment set-up.
 [----------] 15 tests from MessageTest
 [ RUN      ] MessageTest.DefaultConstructor
 [       OK ] MessageTest.DefaultConstructor (1 ms)
 [ RUN      ] MessageTest.CopyConstructor
 external/gtest/test/gtest-message_test.cc:67: Failure
 Value of: 5
 Expected: 2
 external/gtest/test/gtest-message_test.cc:68: Failure
 Value of: 1 == 1
 Actual: true
 Expected: false
 [  FAILED  ] MessageTest.CopyConstructor (2 ms)
  ...
 [ RUN      ] MessageTest.DoesNotTakeUpMuchStackSpace
 [       OK ] MessageTest.DoesNotTakeUpMuchStackSpace (0 ms)
 [----------] 15 tests from MessageTest (26 ms total)

 [----------] Global test environment tear-down
 [==========] 15 tests from 1 test case ran. (26 ms total)
 [  PASSED  ] 6 tests.
 [  FAILED  ] 9 tests, listed below:
 [  FAILED  ] MessageTest.CopyConstructor
 [  FAILED  ] MessageTest.ConstructsFromCString
 [  FAILED  ] MessageTest.StreamsCString
 [  FAILED  ] MessageTest.StreamsNullCString
 [  FAILED  ] MessageTest.StreamsString
 [  FAILED  ] MessageTest.StreamsStringWithEmbeddedNUL
 [  FAILED  ] MessageTest.StreamsNULChar
 [  FAILED  ] MessageTest.StreamsInt
 [  FAILED  ] MessageTest.StreamsBasicIoManip
 9 FAILED TESTS
 

其中,以下代码用于指示特定事件:

 [==========]: the first occurrence indicates a new run started, including the number of tests
                  to be expected in this run
 [ RUN      ]: indicates a new test has started to run; a series of zero or more lines may
                  follow a test start, and will be captured in case of a test failure or error
 [       OK ]: the preceding test has completed successfully, optionally including the time it
                  took to run (in ms)
 [  FAILED  ]: the preceding test has failed, optionally including the time it took to run (in ms)
 [==========]: the preceding test run has completed, optionally including the time it took to run
                  (in ms)
 
系统会忽略其他所有行。

摘要

公共构造函数

GTestResultParser(String testRunName, listeners)

创建 GTestResultParser。

公共方法

void cancel()

请求取消测试运行。

void done()

在 adb 会话完成时由父级调用。

getFailedTests()

返回在当前测试运行期间失败的测试列表。

boolean getPrependFileName()
boolean isCancelled()

如果已取消测试运行,则返回 true。

boolean isTestRunIncomplete()

测试运行是否未完成。

void processNewLines(String[] lines)

void setPrependFileName(boolean prepend)

受保护的方法

boolean isUnexpectedTestFound()

公开用于单元测试。

公共构造函数

GTestResultParser

public GTestResultParser (String testRunName, 
                 listeners)

创建 GTestResultParser。

参数
testRunName String:要提供给 ITestLifeCycleReceiver.testRunStarted(String, int) 的测试运行名称

listeners :在测试执行时获知测试结果

公共方法

取消

public void cancel ()

请求取消测试运行。

done

public void done ()

在 adb 会话完成时由父级调用。

getFailedTest

public  getFailedTests ()

返回在当前测试运行期间失败的测试列表。

返回

getPrependFileName

public boolean getPrependFileName ()

返回
boolean

已取消

public boolean isCancelled ()

如果已取消测试运行,则返回 true。

返回
boolean

isTestRunIncomplete

public boolean isTestRunIncomplete ()

测试运行是否未完成。

返回
boolean 如果测试运行由于解析问题或崩溃而未完成,则为 true。

processNewLines

public void processNewLines (String[] lines)

参数
lines String

setPrependFileName

public void setPrependFileName (boolean prepend)

参数
prepend boolean

受保护的方法

isUnexpectedTestFound

protected boolean isUnexpectedTestFound ()

公开用于单元测试。

返回
boolean