tesseract v5.3.3.20231005
googletest-failfast-unittest.GTestFailFastUnitTest Class Reference
Inheritance diagram for googletest-failfast-unittest.GTestFailFastUnitTest:

Public Member Functions

def testDefaultBehavior (self)
 
def testGoogletestFlag (self)
 
def testGoogletestEnvVar (self)
 
def testBazelEnvVar (self)
 
def testFlagOverridesEnvVar (self)
 
def testGoogletestEnvVarOverridesBazelEnvVar (self)
 
def testEventListener (self)
 
def assertXmlResultCount (self, result, count, xml)
 
def assertXmlStatusCount (self, status, count, xml)
 
def assertFailFastXmlAndTxtOutput (self, fail_fast, test_suite, passed_count, failure_count, skipped_count, suppressed_count, run_disabled=False)
 
def assertFailFastBehavior (self, test_suite, passed_count, failure_count, skipped_count, suppressed_count, run_disabled=False)
 
def assertNotFailFastBehavior (self, test_suite, passed_count, failure_count, skipped_count, suppressed_count, run_disabled=False)
 
def testFlag_HasFixtureTest (self)
 
def testFlag_HasSimpleTest (self)
 
def testFlag_HasParametersTest (self)
 
def testFlag_HasDisabledTest (self)
 
def testFlag_HasDisabledRunDisabledTest (self)
 
def testFlag_HasDisabledSuiteTest (self)
 
def testFlag_HasDisabledSuiteRunDisabledTest (self)
 
def testFlag_HasDeathTest (self)
 

Detailed Description

Tests the env variable or the command line flag for fail_fast.

Definition at line 113 of file googletest-failfast-unittest.py.

Member Function Documentation

◆ assertFailFastBehavior()

def googletest-failfast-unittest.GTestFailFastUnitTest.assertFailFastBehavior (   self,
  test_suite,
  passed_count,
  failure_count,
  skipped_count,
  suppressed_count,
  run_disabled = False 
)
Assert --fail_fast via flag.

Definition at line 250 of file googletest-failfast-unittest.py.

256 run_disabled=False):
257 """Assert --fail_fast via flag."""
258
259 for fail_fast in ('true', '1', 't', True):
260 self.assertFailFastXmlAndTxtOutput(fail_fast, test_suite, passed_count,
261 failure_count, skipped_count,
262 suppressed_count, run_disabled)
263

◆ assertFailFastXmlAndTxtOutput()

def googletest-failfast-unittest.GTestFailFastUnitTest.assertFailFastXmlAndTxtOutput (   self,
  fail_fast,
  test_suite,
  passed_count,
  failure_count,
  skipped_count,
  suppressed_count,
  run_disabled = False 
)
Assert XML and text output of a test execution.

Definition at line 226 of file googletest-failfast-unittest.py.

233 run_disabled=False):
234 """Assert XML and text output of a test execution."""
235
236 txt, xml = RunAndReturnOutput(test_suite, fail_fast, run_disabled)
237 if failure_count > 0:
238 self.assertIn('%s FAILED TEST' % failure_count, txt)
239 if suppressed_count > 0:
240 self.assertIn('%s DISABLED TEST' % suppressed_count, txt)
241 if skipped_count > 0:
242 self.assertIn('[ SKIPPED ] %s tests' % skipped_count, txt)
243 self.assertXmlStatusCount('run',
244 passed_count + failure_count + skipped_count, xml)
245 self.assertXmlStatusCount('notrun', suppressed_count, xml)
246 self.assertXmlResultCount('completed', passed_count + failure_count, xml)
247 self.assertXmlResultCount('skipped', skipped_count, xml)
248 self.assertXmlResultCount('suppressed', suppressed_count, xml)
249
def RunAndReturnOutput(test_suite=None, fail_fast=None, run_disabled=False)

◆ assertNotFailFastBehavior()

def googletest-failfast-unittest.GTestFailFastUnitTest.assertNotFailFastBehavior (   self,
  test_suite,
  passed_count,
  failure_count,
  skipped_count,
  suppressed_count,
  run_disabled = False 
)
Assert --nofail_fast via flag.

Definition at line 264 of file googletest-failfast-unittest.py.

270 run_disabled=False):
271 """Assert --nofail_fast via flag."""
272
273 for fail_fast in ('false', '0', 'f', False):
274 self.assertFailFastXmlAndTxtOutput(fail_fast, test_suite, passed_count,
275 failure_count, skipped_count,
276 suppressed_count, run_disabled)
277

◆ assertXmlResultCount()

def googletest-failfast-unittest.GTestFailFastUnitTest.assertXmlResultCount (   self,
  result,
  count,
  xml 
)

Definition at line 214 of file googletest-failfast-unittest.py.

214 def assertXmlResultCount(self, result, count, xml):
215 self.assertEqual(
216 count, xml.count('result="%s"' % result),
217 'Expected \'result="%s"\' match count of %s: %s ' %
218 (result, count, xml))
219

◆ assertXmlStatusCount()

def googletest-failfast-unittest.GTestFailFastUnitTest.assertXmlStatusCount (   self,
  status,
  count,
  xml 
)

Definition at line 220 of file googletest-failfast-unittest.py.

220 def assertXmlStatusCount(self, status, count, xml):
221 self.assertEqual(
222 count, xml.count('status="%s"' % status),
223 'Expected \'status="%s"\' match count of %s: %s ' %
224 (status, count, xml))
225

◆ testBazelEnvVar()

def googletest-failfast-unittest.GTestFailFastUnitTest.testBazelEnvVar (   self)
Tests the behavior of specifying fail_fast via Bazel testbridge.

Definition at line 147 of file googletest-failfast-unittest.py.

147 def testBazelEnvVar(self):
148 """Tests the behavior of specifying fail_fast via Bazel testbridge."""
149
150 try:
151 SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, '1')
152 txt, _ = RunAndReturnOutput('HasSimpleTest')
153 self.assertIn('1 FAILED TEST', txt)
154 self.assertIn('[ SKIPPED ] 3 tests', txt)
155
156 SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, '0')
157 txt, _ = RunAndReturnOutput('HasSimpleTest')
158 self.assertIn('4 FAILED TEST', txt)
159 self.assertNotIn('[ SKIPPED ]', txt)
160 finally:
161 SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, None)
162

◆ testDefaultBehavior()

def googletest-failfast-unittest.GTestFailFastUnitTest.testDefaultBehavior (   self)
Tests the behavior of not specifying the fail_fast.

Definition at line 116 of file googletest-failfast-unittest.py.

116 def testDefaultBehavior(self):
117 """Tests the behavior of not specifying the fail_fast."""
118
119 txt, _ = RunAndReturnOutput()
120 self.assertIn('22 FAILED TEST', txt)
121

◆ testEventListener()

def googletest-failfast-unittest.GTestFailFastUnitTest.testEventListener (   self)

Definition at line 187 of file googletest-failfast-unittest.py.

187 def testEventListener(self):
188 txt, _ = RunAndReturnOutput(test_suite='HasSkipTest', fail_fast=True)
189 self.assertIn('1 FAILED TEST', txt)
190 self.assertIn('[ SKIPPED ] 3 tests', txt)
191 for expected_count, callback in [(1, 'OnTestSuiteStart'),
192 (5, 'OnTestStart'),
193 (5, 'OnTestEnd'),
194 (5, 'OnTestPartResult'),
195 (1, 'OnTestSuiteEnd')]:
196 self.assertEqual(
197 expected_count, txt.count(callback),
198 'Expected %d calls to callback %s match count on output: %s ' %
199 (expected_count, callback, txt))
200
201 txt, _ = RunAndReturnOutput(test_suite='HasSkipTest', fail_fast=False)
202 self.assertIn('3 FAILED TEST', txt)
203 self.assertIn('[ SKIPPED ] 1 test', txt)
204 for expected_count, callback in [(1, 'OnTestSuiteStart'),
205 (5, 'OnTestStart'),
206 (5, 'OnTestEnd'),
207 (5, 'OnTestPartResult'),
208 (1, 'OnTestSuiteEnd')]:
209 self.assertEqual(
210 expected_count, txt.count(callback),
211 'Expected %d calls to callback %s match count on output: %s ' %
212 (expected_count, callback, txt))
213

◆ testFlag_HasDeathTest()

def googletest-failfast-unittest.GTestFailFastUnitTest.testFlag_HasDeathTest (   self)
Tests the behavior of fail_fast and death tests.

Definition at line 393 of file googletest-failfast-unittest.py.

393 def testFlag_HasDeathTest(self):
394 """Tests the behavior of fail_fast and death tests."""
395 self.assertFailFastBehavior(
396 test_suite='HasDeathTest',
397 passed_count=1,
398 failure_count=1,
399 skipped_count=3,
400 suppressed_count=0)
401 self.assertNotFailFastBehavior(
402 test_suite='HasDeathTest',
403 passed_count=1,
404 failure_count=4,
405 skipped_count=0,
406 suppressed_count=0)
407
408

◆ testFlag_HasDisabledRunDisabledTest()

def googletest-failfast-unittest.GTestFailFastUnitTest.testFlag_HasDisabledRunDisabledTest (   self)
Tests the behavior of fail_fast and Disabled test cases enabled.

Definition at line 340 of file googletest-failfast-unittest.py.

340 def testFlag_HasDisabledRunDisabledTest(self):
341 """Tests the behavior of fail_fast and Disabled test cases enabled."""
342 self.assertFailFastBehavior(
343 test_suite='HasDisabledTest',
344 passed_count=1,
345 failure_count=1,
346 skipped_count=3,
347 suppressed_count=0,
348 run_disabled=True)
349 self.assertNotFailFastBehavior(
350 test_suite='HasDisabledTest',
351 passed_count=1,
352 failure_count=4,
353 skipped_count=0,
354 suppressed_count=0,
355 run_disabled=True)
356

◆ testFlag_HasDisabledSuiteRunDisabledTest()

def googletest-failfast-unittest.GTestFailFastUnitTest.testFlag_HasDisabledSuiteRunDisabledTest (   self)
Tests the behavior of fail_fast and Disabled test suites enabled.

Definition at line 374 of file googletest-failfast-unittest.py.

374 def testFlag_HasDisabledSuiteRunDisabledTest(self):
375 """Tests the behavior of fail_fast and Disabled test suites enabled."""
376 self.assertFailFastBehavior(
377 test_suite='DISABLED_HasDisabledSuite',
378 passed_count=1,
379 failure_count=1,
380 skipped_count=3,
381 suppressed_count=0,
382 run_disabled=True)
383 self.assertNotFailFastBehavior(
384 test_suite='DISABLED_HasDisabledSuite',
385 passed_count=1,
386 failure_count=4,
387 skipped_count=0,
388 suppressed_count=0,
389 run_disabled=True)
390

◆ testFlag_HasDisabledSuiteTest()

def googletest-failfast-unittest.GTestFailFastUnitTest.testFlag_HasDisabledSuiteTest (   self)
Tests the behavior of fail_fast and Disabled test suites.

Definition at line 357 of file googletest-failfast-unittest.py.

357 def testFlag_HasDisabledSuiteTest(self):
358 """Tests the behavior of fail_fast and Disabled test suites."""
359 self.assertFailFastBehavior(
360 test_suite='DISABLED_HasDisabledSuite',
361 passed_count=0,
362 failure_count=0,
363 skipped_count=0,
364 suppressed_count=5,
365 run_disabled=False)
366 self.assertNotFailFastBehavior(
367 test_suite='DISABLED_HasDisabledSuite',
368 passed_count=0,
369 failure_count=0,
370 skipped_count=0,
371 suppressed_count=5,
372 run_disabled=False)
373

◆ testFlag_HasDisabledTest()

def googletest-failfast-unittest.GTestFailFastUnitTest.testFlag_HasDisabledTest (   self)
Tests the behavior of fail_fast and Disabled test cases.

Definition at line 323 of file googletest-failfast-unittest.py.

323 def testFlag_HasDisabledTest(self):
324 """Tests the behavior of fail_fast and Disabled test cases."""
325 self.assertFailFastBehavior(
326 test_suite='HasDisabledTest',
327 passed_count=1,
328 failure_count=1,
329 skipped_count=2,
330 suppressed_count=1,
331 run_disabled=False)
332 self.assertNotFailFastBehavior(
333 test_suite='HasDisabledTest',
334 passed_count=1,
335 failure_count=3,
336 skipped_count=0,
337 suppressed_count=1,
338 run_disabled=False)
339

◆ testFlag_HasFixtureTest()

def googletest-failfast-unittest.GTestFailFastUnitTest.testFlag_HasFixtureTest (   self)
Tests the behavior of fail_fast and TEST_F.

Definition at line 278 of file googletest-failfast-unittest.py.

278 def testFlag_HasFixtureTest(self):
279 """Tests the behavior of fail_fast and TEST_F."""
280 self.assertFailFastBehavior(
281 test_suite='HasFixtureTest',
282 passed_count=1,
283 failure_count=1,
284 skipped_count=3,
285 suppressed_count=0)
286 self.assertNotFailFastBehavior(
287 test_suite='HasFixtureTest',
288 passed_count=1,
289 failure_count=4,
290 skipped_count=0,
291 suppressed_count=0)
292

◆ testFlag_HasParametersTest()

def googletest-failfast-unittest.GTestFailFastUnitTest.testFlag_HasParametersTest (   self)
Tests the behavior of fail_fast and TEST_P.

Definition at line 308 of file googletest-failfast-unittest.py.

308 def testFlag_HasParametersTest(self):
309 """Tests the behavior of fail_fast and TEST_P."""
310 self.assertFailFastBehavior(
311 test_suite='HasParametersSuite/HasParametersTest',
312 passed_count=0,
313 failure_count=1,
314 skipped_count=3,
315 suppressed_count=0)
316 self.assertNotFailFastBehavior(
317 test_suite='HasParametersSuite/HasParametersTest',
318 passed_count=0,
319 failure_count=4,
320 skipped_count=0,
321 suppressed_count=0)
322

◆ testFlag_HasSimpleTest()

def googletest-failfast-unittest.GTestFailFastUnitTest.testFlag_HasSimpleTest (   self)
Tests the behavior of fail_fast and TEST.

Definition at line 293 of file googletest-failfast-unittest.py.

293 def testFlag_HasSimpleTest(self):
294 """Tests the behavior of fail_fast and TEST."""
295 self.assertFailFastBehavior(
296 test_suite='HasSimpleTest',
297 passed_count=1,
298 failure_count=1,
299 skipped_count=3,
300 suppressed_count=0)
301 self.assertNotFailFastBehavior(
302 test_suite='HasSimpleTest',
303 passed_count=1,
304 failure_count=4,
305 skipped_count=0,
306 suppressed_count=0)
307

◆ testFlagOverridesEnvVar()

def googletest-failfast-unittest.GTestFailFastUnitTest.testFlagOverridesEnvVar (   self)
Tests precedence of flag over env var.

Definition at line 163 of file googletest-failfast-unittest.py.

163 def testFlagOverridesEnvVar(self):
164 """Tests precedence of flag over env var."""
165
166 try:
167 SetEnvVar(FAIL_FAST_ENV_VAR, '0')
168 txt, _ = RunAndReturnOutput('HasSimpleTest', True)
169 self.assertIn('1 FAILED TEST', txt)
170 self.assertIn('[ SKIPPED ] 3 tests', txt)
171 finally:
172 SetEnvVar(FAIL_FAST_ENV_VAR, None)
173

◆ testGoogletestEnvVar()

def googletest-failfast-unittest.GTestFailFastUnitTest.testGoogletestEnvVar (   self)
Tests the behavior of specifying fail_fast via Googletest env var.

Definition at line 131 of file googletest-failfast-unittest.py.

131 def testGoogletestEnvVar(self):
132 """Tests the behavior of specifying fail_fast via Googletest env var."""
133
134 try:
135 SetEnvVar(FAIL_FAST_ENV_VAR, '1')
136 txt, _ = RunAndReturnOutput('HasSimpleTest')
137 self.assertIn('1 FAILED TEST', txt)
138 self.assertIn('[ SKIPPED ] 3 tests', txt)
139
140 SetEnvVar(FAIL_FAST_ENV_VAR, '0')
141 txt, _ = RunAndReturnOutput('HasSimpleTest')
142 self.assertIn('4 FAILED TEST', txt)
143 self.assertNotIn('[ SKIPPED ]', txt)
144 finally:
145 SetEnvVar(FAIL_FAST_ENV_VAR, None)
146

◆ testGoogletestEnvVarOverridesBazelEnvVar()

def googletest-failfast-unittest.GTestFailFastUnitTest.testGoogletestEnvVarOverridesBazelEnvVar (   self)
Tests that the Googletest native env var over Bazel testbridge.

Definition at line 174 of file googletest-failfast-unittest.py.

174 def testGoogletestEnvVarOverridesBazelEnvVar(self):
175 """Tests that the Googletest native env var over Bazel testbridge."""
176
177 try:
178 SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, '0')
179 SetEnvVar(FAIL_FAST_ENV_VAR, '1')
180 txt, _ = RunAndReturnOutput('HasSimpleTest')
181 self.assertIn('1 FAILED TEST', txt)
182 self.assertIn('[ SKIPPED ] 3 tests', txt)
183 finally:
184 SetEnvVar(FAIL_FAST_ENV_VAR, None)
185 SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, None)
186

◆ testGoogletestFlag()

def googletest-failfast-unittest.GTestFailFastUnitTest.testGoogletestFlag (   self)

Definition at line 122 of file googletest-failfast-unittest.py.

122 def testGoogletestFlag(self):
123 txt, _ = RunAndReturnOutput(test_suite='HasSimpleTest', fail_fast=True)
124 self.assertIn('1 FAILED TEST', txt)
125 self.assertIn('[ SKIPPED ] 3 tests', txt)
126
127 txt, _ = RunAndReturnOutput(test_suite='HasSimpleTest', fail_fast=False)
128 self.assertIn('4 FAILED TEST', txt)
129 self.assertNotIn('[ SKIPPED ]', txt)
130

The documentation for this class was generated from the following file: