PythonUnitTestResultParser

public class PythonUnitTestResultParser
extends MultiLineReceiver

java.lang.Object
   ↳ com.android.ddmlib.MultiLineReceiver
     ↳ com.android.tradefed.testtype.PythonUnitTestResultParser


Python の unittest フレームワークで実行されたテストの出力を解釈し、一連の ITestInvocationListener への呼び出しに変換します。これらのテストの出力は、次の EBNF 文法に従います。

TestReport ::= TestResult* Line TimeMetric [FailMessage*] Status. TestResult ::= string \u201c(\u201cstring\u201d)\u201d \u201c\u2026\u201d SingleStatus。FailMessage ::= EqLine \u201cERROR:\u201d string \u201c(\u201cstring\u201d)\u201d Line Traceback Line. SingleStatus ::= \u201cok\u201d | \u201cERROR\u201d。TimeMetric ::= \u201cRan\u201d integer \u201ctests in\u201d float \u201ds\u201d。Status ::= \u201cOK\u201d | \u201cFAILED (errors=\u201d int \u201c)\u201d。Traceback ::= string+.

出力例(合格): 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) ... ok test_union (test_rangelib.RangeSetTest) ... ok

---------------------------------------------------------------------- Ran 5 tests in 0.002s

OK

出力例(失敗)test_size(test_rangelib.RangeSetTest)... エラー

===================================================================== エラー: test_size (test_rangelib.RangeSetTest) ---------------------------------------------------------------------- トレースバック(最新の呼び出しが最後): ファイル「test_rangelib.py」、129 行目、test_rangelib で ValueError を発生させました。 ---------------------------------------------------------------------- 1 件のテストを 0.001 秒で実行しました。 失敗しました(エラー数: 1)

いくつかのエッジケース(失敗)を含む出力例: testError (foo.testFoo) ... ERROR testExpectedFailure (foo.testFoo) ... expected failure testFail (foo.testFoo) ... FAIL testFailWithDocString (foo.testFoo) foo bar ... FAIL testOk (foo.testFoo) ... ok testOkWithDocString (foo.testFoo) foo bar ... ok testSkipped (foo.testFoo) ... skipped 'reason foo' testUnexpectedSuccess (foo.testFoo) ... unexpected success

====================================================================== ERROR: testError (foo.testFoo) ---------------------------------------------------------------------- Traceback (most recent call last): File "foo.py", line 11, in testError self.assertEqual(2+2, 5/0) ZeroDivisionError: integer division or modulo by zero

===================================================================== FAIL: testFail (foo.testFoo) ---------------------------------------------------------------------- Traceback (most recent call last): File "foo.py", line 8, in testFail self.assertEqual(2+2, 5) AssertionError: 4 != 5

===================================================================== FAIL: testFailWithDocString (foo.testFoo) foo bar ---------------------------------------------------------------------- Traceback (most recent call last): File "foo.py", line 31, in testFailWithDocString self.assertEqual(2+2, 5) AssertionError: 4 != 5

---------------------------------------------------------------------- Ran 8 tests in 0.001s

失敗(failures=2、errors=1、skipped=1、expected failures=1、unexpected successes=1)

TODO: クラス全体のリファクタリングを検討します。現在の処理はかなり複雑です。

概要

パブリック コンストラクタ

PythonUnitTestResultParser( listeners, String runName)

指定された ITestInvocationListener にレポートする新しい PythonUnitTestResultParser を作成します。

PythonUnitTestResultParser( listeners, String runName, includeFilters, excludeFilters)

指定されたインクルード フィルタと除外フィルタを使用して、指定された ITestInvocationListener にレポートする新しい PythonUnitTestResultParser を作成します。

パブリック メソッド

void finalizeParser()
boolean isCancelled()
void processNewLines(String[] lines)

Python unittest の出力を処理し、解析された結果を報告します。

void setFinalizeWhenParsing(boolean shouldFinalize)

パブリック コンストラクタ

PythonUnitTestResultParser

public PythonUnitTestResultParser ( listeners, 
                String runName)

指定された ITestInvocationListener にレポートする新しい PythonUnitTestResultParser を作成します。

パラメータ
listeners

runName String

PythonUnitTestResultParser

public PythonUnitTestResultParser ( listeners, 
                String runName, 
                 includeFilters, 
                 excludeFilters)

指定されたインクルード フィルタと除外フィルタを使用して、指定された ITestInvocationListener にレポートする新しい PythonUnitTestResultParser を作成します。

パラメータ
listeners

runName String

includeFilters

excludeFilters

パブリック メソッド

finalizeParser

public void finalizeParser ()

isCancelled

public boolean isCancelled ()

戻り値
boolean

processNewLines

public void processNewLines (String[] lines)

Python unittest の出力を処理し、解析された結果を報告します。

このメソッドは、MultiLineReceiver の基本メソッドとは異なり、完全な出力で 1 回だけ呼び出す必要があります。

パラメータ
lines String: 新しい行を含む配列。

setFinalizeWhenParsing

public void setFinalizeWhenParsing (boolean shouldFinalize)

パラメータ
shouldFinalize boolean