Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pjxxcc opened this issue Jan 25, 2018 · 5 comments
Open

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

pjxxcc opened this issue Jan 25, 2018 · 5 comments

Comments

@pjxxcc
Copy link

pjxxcc commented Jan 25, 2018

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

@banrieen
Copy link

banrieen commented Apr 4, 2018

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!

@rbrylunov-wehal
Copy link

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

@egramajo34
Copy link

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)

@krchug
Copy link

krchug commented Jun 25, 2018

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?

@egramajo34
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants