Bird
0
0

What will be the result of running this test suite code?

medium📝 Predict Output Q5 of 15
Testing Fundamentals - Test Documentation
What will be the result of running this test suite code?
import unittest

class TestExample(unittest.TestCase):
    def test_true(self):
        self.assertTrue(True)
    def test_false(self):
        self.assertTrue(False)

suite = unittest.TestSuite()
suite.addTests([TestExample('test_true'), TestExample('test_false')])
runner = unittest.TextTestRunner()
result = runner.run(suite)
ABoth tests pass successfully
BSyntax error prevents running tests
CBoth tests fail
DOne test passes, one test fails; summary shows 1 failure
Step-by-Step Solution
Solution:
  1. Step 1: Check assertions in test methods

    test_true asserts True (passes), test_false asserts False (fails).
  2. Step 2: Understand test suite execution

    Both tests run; one passes, one fails, summary shows 1 failure.
  3. Final Answer:

    One test passes, one test fails; summary shows 1 failure -> Option D
  4. Quick Check:

    One pass + one fail = 1 failure [OK]
Quick Trick: Check each assertion to predict pass/fail [OK]
Common Mistakes:
  • Assuming both tests pass without checking assertions
  • Confusing assertTrue(False) as pass
  • Thinking syntax error exists without error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Testing Fundamentals Quizzes