Bird
0
0

What is wrong with this code snippet for generating an HTML report using HtmlTestRunner?

medium📝 Debug Q14 of 15
Selenium Python - Test Framework Integration (pytest)
What is wrong with this code snippet for generating an HTML report using HtmlTestRunner?
import unittest
import HtmlTestRunner

class TestExample(unittest.TestCase):
    def test_fail(self):
        self.assertEqual(1, 2)

if __name__ == '__main__':
    unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output=''))
AEmpty output string causes report not to save
BassertEqual syntax is incorrect
CMissing import for HtmlTestRunner
DTest class must inherit from HtmlTestRunner
Step-by-Step Solution
Solution:
  1. Step 1: Check the output parameter usage

    Setting output='' means no folder is specified, which can cause HtmlTestRunner to fail saving reports properly.
  2. Step 2: Verify other parts

    assertEqual syntax is correct, HtmlTestRunner is imported, and test class inheritance is correct.
  3. Final Answer:

    Empty output string causes report not to save -> Option A
  4. Quick Check:

    output='' disables report folder, causing save issues [OK]
Quick Trick: Provide a valid folder name in output to save reports [OK]
Common Mistakes:
  • Thinking assertEqual(1, 2) is syntax error
  • Believing test class must inherit HtmlTestRunner
  • Ignoring output parameter effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes