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
ठीक है
आउटपुट का उदाहरण (फ़ेल हो गया) 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: Consider refactoring the full class, handling is quite messy right now.
खास जानकारी
सार्वजनिक कंस्ट्रक्टर | |
|---|---|
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)
Python unittest के आउटपुट को प्रोसेस करता है और पार्स किए गए नतीजों की रिपोर्ट करता है. |
void
|
setFinalizeWhenParsing(boolean shouldFinalize)
|
सार्वजनिक कंस्ट्रक्टर
PythonUnitTestResultParser
public PythonUnitTestResultParser (ITestInvocationListener listener, String runName)
दिए गए ITestInvocationListener के लिए, एक नया PythonUnitTestResultParser बनाएं.
| पैरामीटर | |
|---|---|
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)
Python unittest के आउटपुट को प्रोसेस करता है और पार्स किए गए नतीजों की रिपोर्ट करता है.
इस तरीके को सिर्फ़ एक बार पूरे आउटपुट के साथ कॉल किया जाना चाहिए. ऐसा MultiLineReceiver में मौजूद बुनियादी तरीके के उलट है.
| पैरामीटर | |
|---|---|
lines |
String: नई लाइनें शामिल करने वाला कलेक्शन. |
setFinalizeWhenParsing
public void setFinalizeWhenParsing (boolean shouldFinalize)
| पैरामीटर | |
|---|---|
shouldFinalize |
boolean |