27 @type bool |
27 @type bool |
28 """ |
28 """ |
29 TestResult.__init__(self) |
29 TestResult.__init__(self) |
30 self.__dbgClient = dbgClient |
30 self.__dbgClient = dbgClient |
31 self.failfast = failfast |
31 self.failfast = failfast |
32 |
32 |
33 def addFailure(self, test, err): |
33 def addFailure(self, test, err): |
34 """ |
34 """ |
35 Public method called if a test failed. |
35 Public method called if a test failed. |
36 |
36 |
37 @param test Reference to the test object |
37 @param test Reference to the test object |
42 self.__dbgClient.sendJsonCommand("ResponseUTTestFailed", { |
42 self.__dbgClient.sendJsonCommand("ResponseUTTestFailed", { |
43 "testname": str(test), |
43 "testname": str(test), |
44 "traceback": tracebackLines, |
44 "traceback": tracebackLines, |
45 "id": test.id(), |
45 "id": test.id(), |
46 }) |
46 }) |
47 |
47 |
48 def addError(self, test, err): |
48 def addError(self, test, err): |
49 """ |
49 """ |
50 Public method called if a test errored. |
50 Public method called if a test errored. |
51 |
51 |
52 @param test Reference to the test object |
52 @param test Reference to the test object |
57 self.__dbgClient.sendJsonCommand("ResponseUTTestErrored", { |
57 self.__dbgClient.sendJsonCommand("ResponseUTTestErrored", { |
58 "testname": str(test), |
58 "testname": str(test), |
59 "traceback": tracebackLines, |
59 "traceback": tracebackLines, |
60 "id": test.id(), |
60 "id": test.id(), |
61 }) |
61 }) |
|
62 |
|
63 def addSubTest(self, test, subtest, err): |
|
64 """ |
|
65 Public method called for each subtest to record its result. |
62 |
66 |
|
67 @param test reference to the test object |
|
68 @param subtest reference to the subtest object |
|
69 @param err error traceback |
|
70 """ |
|
71 if err is not None: |
|
72 TestResult.addSubTest(self, test, subtest, err) |
|
73 tracebackLines = self._exc_info_to_string(err, test) |
|
74 if issubclass(err[0], test.failureException): |
|
75 self.__dbgClient.sendJsonCommand("ResponseUTTestFailed", { |
|
76 "testname": str(subtest), |
|
77 "traceback": tracebackLines, |
|
78 "id": test.id(), |
|
79 }) |
|
80 else: |
|
81 self.__dbgClient.sendJsonCommand("ResponseUTTestErrored", { |
|
82 "testname": str(subtest), |
|
83 "traceback": tracebackLines, |
|
84 "id": test.id(), |
|
85 }) |
|
86 |
63 def addSkip(self, test, reason): |
87 def addSkip(self, test, reason): |
64 """ |
88 """ |
65 Public method called if a test was skipped. |
89 Public method called if a test was skipped. |
66 |
90 |
67 @param test reference to the test object |
91 @param test reference to the test object |
71 self.__dbgClient.sendJsonCommand("ResponseUTTestSkipped", { |
95 self.__dbgClient.sendJsonCommand("ResponseUTTestSkipped", { |
72 "testname": str(test), |
96 "testname": str(test), |
73 "reason": reason, |
97 "reason": reason, |
74 "id": test.id(), |
98 "id": test.id(), |
75 }) |
99 }) |
76 |
100 |
77 def addExpectedFailure(self, test, err): |
101 def addExpectedFailure(self, test, err): |
78 """ |
102 """ |
79 Public method called if a test failed expected. |
103 Public method called if a test failed expected. |
80 |
104 |
81 @param test reference to the test object |
105 @param test reference to the test object |
86 self.__dbgClient.sendJsonCommand("ResponseUTTestFailedExpected", { |
110 self.__dbgClient.sendJsonCommand("ResponseUTTestFailedExpected", { |
87 "testname": str(test), |
111 "testname": str(test), |
88 "traceback": tracebackLines, |
112 "traceback": tracebackLines, |
89 "id": test.id(), |
113 "id": test.id(), |
90 }) |
114 }) |
91 |
115 |
92 def addUnexpectedSuccess(self, test): |
116 def addUnexpectedSuccess(self, test): |
93 """ |
117 """ |
94 Public method called if a test succeeded expectedly. |
118 Public method called if a test succeeded expectedly. |
95 |
119 |
96 @param test reference to the test object |
120 @param test reference to the test object |
98 TestResult.addUnexpectedSuccess(self, test) |
122 TestResult.addUnexpectedSuccess(self, test) |
99 self.__dbgClient.sendJsonCommand("ResponseUTTestSucceededUnexpected", { |
123 self.__dbgClient.sendJsonCommand("ResponseUTTestSucceededUnexpected", { |
100 "testname": str(test), |
124 "testname": str(test), |
101 "id": test.id(), |
125 "id": test.id(), |
102 }) |
126 }) |
103 |
127 |
104 def startTest(self, test): |
128 def startTest(self, test): |
105 """ |
129 """ |
106 Public method called at the start of a test. |
130 Public method called at the start of a test. |
107 |
131 |
108 @param test Reference to the test object |
132 @param test Reference to the test object |
110 TestResult.startTest(self, test) |
134 TestResult.startTest(self, test) |
111 self.__dbgClient.sendJsonCommand("ResponseUTStartTest", { |
135 self.__dbgClient.sendJsonCommand("ResponseUTStartTest", { |
112 "testname": str(test), |
136 "testname": str(test), |
113 "description": test.shortDescription(), |
137 "description": test.shortDescription(), |
114 }) |
138 }) |
115 |
139 |
116 def stopTest(self, test): |
140 def stopTest(self, test): |
117 """ |
141 """ |
118 Public method called at the end of a test. |
142 Public method called at the end of a test. |
119 |
143 |
120 @param test Reference to the test object |
144 @param test Reference to the test object |