Skip to content

Instantly share code, notes, and snippets.

@jayakumarc
Created July 9, 2011 07:47
Show Gist options
  • Save jayakumarc/1073424 to your computer and use it in GitHub Desktop.
Save jayakumarc/1073424 to your computer and use it in GitHub Desktop.
HTMLTestRunner usage
import unittest
import HTMLTestRunner
class SampleTest(unittest.TestCase):
def test_pass(self):
"""Test to demonstrate pass condition"""
self.assertTrue(True)
def test_fail(self):
"""Test to demonstrate fail condition"""
self.assertTrue(False)
def suite():
s1 = unittest.TestLoader().loadTestsFromTestCase(SampleTest)
return unittest.TestSuite([s1])
def run(suite, report = "report.html"):
with open(report, "w") as f:
HTMLTestRunner.HTMLTestRunner(
stream = f,
title = 'Sample report',
verbosity = 2,
description = 'Sample test for HTMLTestRunner usage'
).run(suite)
if __name__ == "__main__":
run(suite())
@anand853
Copy link

its generating bank html. can you pls let me know how to generate the report with results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment