PyUnitReport icon indicating copy to clipboard operation
PyUnitReport copied to clipboard

如何只生成一个测试报告呢

Open pjxxcc opened this issue 7 years ago • 5 comments

一个testSuite加载了来自不同测试类的多个测试方法,测试完毕后每个测试类都会生成一次测试报告。 暂时不知道如何控制合并测试数据并生成一份统一的报告。

pjxxcc avatar Jan 25 '18 13:01 pjxxcc

Fellow this example in Readme.md: from unittest import TestLoader, TestSuite from pyunitreport import HTMLTestRunner import ExampleTest import Example2Test

example_tests = TestLoader().loadTestsFromTestCase(ExampleTests) example2_tests = TestLoader().loadTestsFromTestCase(Example2Test)

suite = TestSuite([example_tests, example2_tests]) kwargs = { "output": output_folder_name, "report_name": report_name, "failfast": True } runner = HTMLTestRunner(**kwargs) runner.run(suite) ############################################################################# Take the serial testcases in some testsuites ,and nest the testsuites in one testsuites , maybe you would like to call it as testplan. Hope it help you!

banrieen avatar Apr 04 '18 06:04 banrieen

Hi. I'm facing the same problem - I have 3 TestCases and run them in one TestSuite. I've tried the way, described above: all tests from all TestCases are runned, but in the report I see results only from TestCase, which was added last in TestSuite.

After running of all tests, in the console I see that report generation repeated 3 times. If I add only 2 TestCases in TestSuite, report generation repeats 2 times: screenshot_20180510_163316

rbrylunov-wehal avatar May 10 '18 11:05 rbrylunov-wehal

I have a similar issue I have three one test suite with three different classes which contains several test cases each of these classes. One Test Suite is exported to the HTML report: ''' login_test.Login # Class with Login test cases ,register_test,sign_on_test page_without_func_test.PageWithoutFuncTest # Class with other test cases and the list goes on '''

login_test_loader = unittest.TestLoader().loadTestsFromTestCase(login_test.Login) sign_on_test_loader = unittest.TestLoader().loadTestsFromTestCase(sign_on_test.SignOn) without_funct_loader = unittest.TestLoader().loadTestsFromTestCase(page_without_func_test.PageWithoutFuncTest) register_test_loader = unittest.TestLoader().loadTestsFromTestCase(register_test.RegisterTest)

all_tests_suite = unittest.TestSuite([login_test_loader,sign_on_test_loader,without_funct_loader,register_test_loader]) kwargs_all = { "output": cfg.report_path, "report_name": "all_test_report_new", "failfast": False } runner_all = HTMLTestRunner(**kwargs_all) runner_all.run(all_tests_suite)

egramajo34 avatar Jun 23 '18 23:06 egramajo34

Hey I have a solution to this issue. However I am new to github. How can i post a review for the change? Can I be one of the contributors? If yes, how?

krchug avatar Jun 25 '18 19:06 krchug

you need to make a fork and then a pull request. It will depend on the owner of this repository to allow you to introduce changes in the current sourcode.

egramajo34 avatar Jun 25 '18 23:06 egramajo34