在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:oldani/HtmlTestRunner开源软件地址:https://github.com/oldani/HtmlTestRunner开源编程语言:Python 72.7%开源软件介绍:HtmlTestRunnerHtmlTest runner is a unittest test runner that saves results in a human-readable HTML format. This Package was inspired by Table of ContentInstallationTo install HtmlTestRunner, run this command in your terminal: $ pip install html-testRunner This is the preferred method to install HtmlTestRunner, as it will always install the most recent stable release. If you don't have pip installed, this Python installation guide can guide you through the process. Usage:With unittest.main()import HtmlTestRunner
import unittest
class TestStringMethods(unittest.TestCase):
""" Example test for HtmlRunner. """
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
def test_error(self):
""" This test should be marked as error one. """
raise ValueError
def test_fail(self):
""" This test should fail. """
self.assertEqual(1, 2)
@unittest.skip("This is a skipped test.")
def test_skip(self):
""" This test should be skipped. """
pass
if __name__ == '__main__':
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner()) Just import With Test Suites
from unittest import TestLoader, TestSuite
from HtmlTestRunner import HTMLTestRunner
import ExampleTest
import Example2Test
example_tests = TestLoader().loadTestsFromTestCase(ExampleTest)
example2_tests = TestLoader().loadTestsFromTestCase(Example2Test)
suite = TestSuite([example_tests, example2_tests])
runner = HTMLTestRunner(output='example_suite')
runner.run(suite) Combining Reports into a Single ReportBy default, separate reports will be produced for each import HtmlTestRunner
h = HtmlTestRunner.HTMLTestRunner(combine_reports=True).run(suite) Setting a filenameBy default the name of the HTML file(s) produced will be created by joining the names of each test case together.
The import HtmlTestRunner
h = HtmlTestRunner.HTMLTestRunner(combine_reports=True, report_name="MyReport", add_timestamp=False).run(suite) Console output:This is an example of the console output expected when using Test Result:This is a sample of the results from the template that came by default with the runner. Custom Templates:If you want to use your own template you can pass the absolute path when instantiating the import HtmlTestRunner
h = HtmlTestRunner.HTMLTestRunner(template='path/to/template') Your template must use When using any template, the following variables will be available by default for use by
Furthermore, you can provide any number of further variables to access from the template using the import getpass
import HtmlTestRunner
template_args = {
"user": getpass.getuser()
}
h = HtmlTestRunner.HTMLTestRunner(template='path/to/template', template_args=template_args) Now the user name can be accessed from a template using Click here for a template example, this is the default one shipped with the package. TODO
ContributingContributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. For more info please click here CreditsThis package was created with Cookiecutter and the |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论