├── .gitignore ├── report.png ├── demo.py ├── README.md ├── demo_report.html ├── test_BSTestRunner.py ├── bs_test_result.html └── BSTestRunner.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .python-version 3 | -------------------------------------------------------------------------------- /report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easonhan007/HTMLTestRunner/HEAD/report.png -------------------------------------------------------------------------------- /demo.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import BSTestRunner 3 | 4 | class DemoTest(unittest.TestCase): 5 | 6 | def test_pass(self): 7 | self.assertTrue(True) 8 | 9 | def test_fail(self): 10 | self.assertTrue(False) 11 | 12 | if __name__ == '__main__': 13 | BSTestRunner.main() 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## BSTestRunner is bootstrap3 version of HTMLTestRunner 2 | 3 | **Now support both python2 and python3** 4 | 5 |  6 | 7 | ## How to use 8 | 9 | A TestRunner for use with the Python unit testing framework. It generates a HTML report to show the result at a glance. 10 | 11 | The simplest way to use this is to invoke its main method. E.g. 12 | 13 | ```python 14 | import unittest 15 | import BSTestRunner 16 | 17 | if __name__ == '__main__': 18 | BSTestRunner.main() 19 | ``` 20 | 21 | 22 | For more customization options, instantiates a BSTestRunner object. 23 | BSTestRunner is a counterpart to unittest's TextTestRunner. E.g. 24 | 25 | ```python 26 | # output to a file 27 | fp = file('my_report.html', 'wb') 28 | runner = BSTestRunner.BSTestRunner( 29 | stream=fp, 30 | title='My unit test', 31 | description='This demonstrates the report output by BSTestRunner.' 32 | ) 33 | 34 | # Use an external stylesheet. 35 | # See the Template_mixin class for more customizable options 36 | runner.STYLESHEET_TMPL = '' 37 | 38 | # run the test 39 | runner.run(my_test_suite) 40 | ``` 41 | -------------------------------------------------------------------------------- /demo_report.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 |Start Time: 2017-11-19 19:53:51
154 |Duration: 0:00:00.000427
155 |Status: Pass 1 Failure 1
156 | 157 | 158 |163 | Summary 164 | Failed 165 | All 166 |
167 || Test Group/Test case 171 | | Count 172 | | Pass 173 | | Fail 174 | | Error 175 | | View 176 | |
|---|---|---|---|---|---|
| DemoTest | 182 |2 | 183 |1 | 184 |1 | 185 |0 | 186 |Detail | 187 |
test_fail |
191 |
192 |
193 |
194 |
195 | fail
196 |
197 |
198 |
212 |
213 |
214 |
199 |
200 | [x]
201 |
202 | 203 | 204 | ft1.1: Traceback (most recent call last): 205 | File "demo.py", line 10, in test_fail 206 | self.assertTrue(False) 207 | AssertionError: False is not true 208 | 209 | 210 |211 | |
215 | ||||
test_pass |
219 | pass | 220 |||||
| Total | 226 |2 | 227 |1 | 228 |1 | 229 |0 | 230 |231 | |