PythonUnitTestResultParser
public
class
PythonUnitTestResultParser
extends MultiLineReceiver
| java.lang.Object | ||
| ↳ | com.android.ddmlib.MultiLineReceiver | |
| ↳ | com.android.tradefed.testtype.PythonUnitTestResultParser | |
ตีความเอาต์พุตของการทดสอบที่เรียกใช้ด้วยเฟรมเวิร์ก unittest ของ Python และแปลเป็นคำสั่งเรียกใช้
ใน 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
ตกลง
ตัวอย่างเอาต์พุต (ไม่ผ่าน) test_size (test_rangelib.RangeSetTest) ... ERROR
====================================================================== ERROR: test_size (test_rangelib.RangeSetTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_rangelib.py", line 129, in test_rangelib raise ValueError() ValueError ---------------------------------------------------------------------- Ran 1 test in 0.001s FAILED (errors=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
FAILED (failures=2, errors=1, skipped=1, expected failures=1, unexpected successes=1)
TODO: พิจารณาการปรับโครงสร้างคลาสทั้งหมด เนื่องจากตอนนี้การจัดการค่อนข้างซับซ้อน
สรุป
เครื่องมือสร้างสาธารณะ | |
|---|---|
PythonUnitTestResultParser(ITestInvocationListener listener, String runName)
สร้าง |
|
PythonUnitTestResultParser(Collection<ITestInvocationListener> listeners, String runName)
สร้าง |
|
PythonUnitTestResultParser(Collection<ITestInvocationListener> listeners, String runName, Set<String> includeFilters, Set<String> excludeFilters)
สร้าง |
|
เมธอดสาธารณะ | |
|---|---|
void
|
finalizeParser()
|
boolean
|
isCancelled()
|
void
|
processNewLines(String[] lines)
ประมวลผลเอาต์พุต unittest ของ Python และรายงานผลลัพธ์ที่แยกวิเคราะห์แล้ว |
void
|
setFinalizeWhenParsing(boolean shouldFinalize)
|
เครื่องมือสร้างสาธารณะ
PythonUnitTestResultParser
public PythonUnitTestResultParser (ITestInvocationListener listener, String runName)
สร้าง PythonUnitTestResultParser ใหม่ที่รายงานไปยัง ITestInvocationListener ที่ระบุ
| พารามิเตอร์ | |
|---|---|
listener |
ITestInvocationListener |
runName |
String |
PythonUnitTestResultParser
public PythonUnitTestResultParser (Collection<ITestInvocationListener> listeners, String runName)
สร้าง PythonUnitTestResultParser ใหม่ที่รายงานไปยัง ITestInvocationListener ที่ระบุ
| พารามิเตอร์ | |
|---|---|
listeners |
Collection |
runName |
String |
PythonUnitTestResultParser
public PythonUnitTestResultParser (Collection<ITestInvocationListener> listeners, String runName, Set<String> includeFilters, Set<String> excludeFilters)
สร้าง PythonUnitTestResultParser ใหม่ที่รายงานไปยัง ITestInvocationListener ที่ระบุ พร้อมตัวกรองรวมและยกเว้นที่ระบุ
| พารามิเตอร์ | |
|---|---|
listeners |
Collection |
runName |
String |
includeFilters |
Set |
excludeFilters |
Set |
เมธอดสาธารณะ
finalizeParser
public void finalizeParser ()
isCancelled
public boolean isCancelled ()
| การคืนสินค้า | |
|---|---|
boolean |
|
processNewLines
public void processNewLines (String[] lines)
ประมวลผลเอาต์พุต unittest ของ Python และรายงานผลลัพธ์ที่แยกวิเคราะห์แล้ว
ควรเรียกใช้เมธอดนี้เพียงครั้งเดียวด้วยเอาต์พุตทั้งหมด ซึ่งแตกต่างจากเมธอดฐานใน
MultiLineReceiver
| พารามิเตอร์ | |
|---|---|
lines |
String: อาร์เรย์ที่มีบรรทัดใหม่ |
setFinalizeWhenParsing
public void setFinalizeWhenParsing (boolean shouldFinalize)
| พารามิเตอร์ | |
|---|---|
shouldFinalize |
boolean |