PythonUnitTestResultParser
public class PythonUnitTestResultParser
extends MultiLineReceiver
java.lang.Object | ||
↳ | com.android.ddmlib.MultiLineReceiver | |
↳ | com.android.tradefed.testtype.PythonUnitTestResultParser |
解釋使用 Python 的單元測試框架運行的測試的輸出,並將其轉換為對一系列ITestInvocationListener
的呼叫。這些測試的輸出遵循以下 EBNF 語法:
TestReport ::= TestResult* 線路 TimeMetric [FailMessage*] 狀態。 TestResult ::= 字串 \u201c(\u201cstring\u201d)\u201d \u201c\u2026\u201d SingleStatus。 FailMessage ::= EqLine \u201cERROR:\u201d string \u201c(\u201cstring\u201d)\u201d 行回溯行。 SingleStatus ::= \u201cok\u201d | 「錯誤」。 TimeMetric ::= 在浮點數中測試整數。狀態 ::= \u201cOK\u201d |失敗(錯誤=int)。回溯 ::= 字串+。
範例輸出(透過): test_size (test_rangelib.RangeSetTest) ... ok test_str (test_rangelib.RangeSetTest) ... ok test_subtract (test_rangelib.RangeSetTest) ... ok test_to_string_raw (test_rangelib.RangeSetTest) ... test test.範圍設定測試)...好的
-------------------------------------------------- -------------------- 在0.002 秒內執行5 次測試
好的
範例輸出(失敗) test_size (test_rangelib.RangeSetTest) ... 錯誤
==================================================== = ==================== 錯誤:test_size (test_rangelib.RangeSetTest) --------------------- - - - - - - - - - - - - - - - - - - - - - - - - - 追溯 (最近一次調用最後):檔案“test_rangelib.py”,第129 行,在test_rangelib 中引發ValueError( ) ValueError --------------------------- --------------------- ---------------------- 在0.001 秒內進行1 次測試失敗(錯誤=1)
具有多個邊緣情況的範例輸出(失敗): testError (foo.testFoo) ... ERROR testExpectedFailure (foo.testFoo) ... 預期失敗testFail (foo.testFoo) ... FAIL testFailWithDocString (foo.testFoo) foo bar 。 .. 失敗 testOk (foo.testFoo) ... ok testOkWithDocString (foo.testFoo) foo bar ... ok testSkipped (foo.testFoo) ... 跳過'reason foo' testUnexpectedSuccess (foo.testFoo) ... 跳過'reason foo' testUnexpectedSuccess (foo.testFoo) .. . 意外成功
==================================================== = ==================== 錯誤:testError (foo.testFoo) --------------------- - - - - - - - - - - - - - - - - - - - - - - - - - 追溯 (最近一次呼叫最後):檔案“foo.py”,第11行,在testError self.assertEqual( 2+2,5/0)ZeroDivisionError:整數除法或以零為模
==================================================== = ==================== 失敗:testFail (foo.testFoo) --------------------- - - - - - - - - - - - - - - - - - - - - - - - - - 追溯 (最近一次呼叫最後):檔案“foo.py”,第8 行,在testFail self.assertEqual( 2+2, 5) AssertionError: 4 != 5
==================================================== = ==================== 失敗:testFailWithDocString (foo.testFoo) foo bar ------------------- ------------------------------------------------- -回溯(最近一次呼叫):檔案“foo.py”,第 31 行,在 testFailWithDocString self.assertEqual(2+2, 5) AssertionError: 4 != 5
-------------------------------------------------- -------------------- 在0.001 秒內執行8 次測試
失敗(失敗=2,錯誤=1,跳過=1,預期失敗=1,意外成功=1)
TODO:考慮重構整個類,現在處理相當混亂。
概括
公共構造函數 | |
---|---|
PythonUnitTestResultParser ( ITestInvocationListener listener, String runName) 建立一個新的 | |
PythonUnitTestResultParser ( listeners, String runName) PythonUnitTestResultParser ( listeners, String runName) 建立一個新的 | |
PythonUnitTestResultParser ( listeners, String runName, includeFilters, excludeFilters) PythonUnitTestResultParser ( listeners, String runName, includeFilters, excludeFilters) PythonUnitTestResultParser ( listeners, String runName, includeFilters, excludeFilters) PythonUnitTestResultParser ( listeners, String runName, includeFilters, excludeFilters) 建立一個新的 |
公共方法 | |
---|---|
void | finalizeParser () |
boolean | isCancelled () |
void | processNewLines (String[] lines) 處理 Python 單元測試輸出並報告解析結果。 |
void | setFinalizeWhenParsing (boolean shouldFinalize) |
公共構造函數
PythonUnitTestResultParser
public PythonUnitTestResultParser (ITestInvocationListener listener, String runName)
建立一個新的PythonUnitTestResultParser
,向給定的ITestInvocationListener
報告。
參數 | |
---|---|
listener | ITestInvocationListener |
runName | String |
PythonUnitTestResultParser
public PythonUnitTestResultParser (listeners, String runName)
建立一個新的PythonUnitTestResultParser
,向給定的ITestInvocationListener
報告。
參數 | |
---|---|
listeners | |
runName | String |
PythonUnitTestResultParser
public PythonUnitTestResultParser (listeners, String runName, includeFilters, excludeFilters)
建立一個新的PythonUnitTestResultParser
,它使用指定的包含和排除過濾器向給定的ITestInvocationListener
進行報告。
參數 | |
---|---|
listeners | |
runName | String |
includeFilters | |
excludeFilters |
公共方法
完成解析器
public void finalizeParser ()
取消
public boolean isCancelled ()
退貨 | |
---|---|
boolean |
處理換行
public void processNewLines (String[] lines)
處理 Python 單元測試輸出並報告解析結果。
與MultiLineReceiver
中的基本方法不同,此方法僅應呼叫一次並獲得完整輸出。
參數 | |
---|---|
lines | String |
setFinalizeWhenParsing
public void setFinalizeWhenParsing (boolean shouldFinalize)
參數 | |
---|---|
shouldFinalize | boolean |