-
Notifications
You must be signed in to change notification settings - Fork 171
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
New functionality (combine reports etc) #32
Conversation
- support for combining reports into single report (combine_reports kwarg) - support for test cases with underscores in name - optional timestamping of filenames (add_timestamp kwarg) - optional automatic opening of generated reports in browser tab (paths to reports are returned from test result) (open_in_browser kwarg) - support for optional user variables to be passed to jinja2 template (template_args kwarg) - added tracebacks to reports - added stdout to reports (so tests that pass can also be expanded - print relative paths to generated reports - made default output directory the current working directory so there are now no required args also: - updated and adjusted readme - changed use of deprecated _TextTestResult -> TextTestResult - changed format of template slightly
…oid clashes from duplicate names) - simplified test method names
HI @JamesMTSloan, Thanks for this huge PR, i will be reviewving and testing it. |
…f a string to allow the user to customise their template more easily. also some other small tweaks.
Hi I have one idea of functionality. It may be good to add your own report name. |
Gracias @oldani, let me know. @durisv: that is something that I have considered yeah and it is a good idea. At the moment you can set the title of the reports (i.e. the text at the top of the page) but I expect you are referring to the filename (i.e. what goes before the timestamp and '.html'). For combined reports or test suites with only one test this would be straight forward but would be complicated for cases where separate reports are being produced because they could all end up with the same name. One solution could be to always combine reports and remove the option of not doing so. Alternatively, we could append the TestCase name to then end of whatever you say should be the title when making separate reports. Do you have an example of what you would like to be able to achieve easily? |
reduced prepended paths to testcase names except for when common testcase names need to be distinguished
I've quickly added optional report naming with the last strategy outlined above. Use the For example if you wanted a combined report to be produced with the name "MyReports.html" you could do so as follows: import unittest
from HtmlTestRunner import HTMLTestRunner
unittest.main(
testRunner=HTMLTestRunner(
combine_reports=True,
add_timestamp=False,
report_name="MyReports"
)
) I'll add it to the README when I can. |
Is there any recent activity on this? I would like to use JamesMTSloans changes, as combining report is huge thing for me now. Anyway great job on HtmlTestRunner, really making things good! 👍 |
…ting test suites, including case where name collision between similarly named test cases is handled. combined reports and separate reports are shown.
I've added a couple of psuedo-tests just to make demonstrating the changes a little easier for @oldani. Really it is just down to whenever he gets the time though. |
Hi, I'm also very interested in this (and very new to python, unittest and selenium, too). Is there any way I can try this new feature before it it included in the trunk? |
@Eki23 you could always check out from my own master branch and install using the -e flag for pip install. |
If that is the case then my implementation needs to be changed. I think I can see where the grouping is being effected and will look at changing it when I get the chance. Thanks for the feedback. |
OK @Eki23 I've pushed a fix for the alphabetical ordering. Cheers. |
That's greate @JamesMTSloan !!! It's working great for me now! I might get back to you for some recommendations on how best use this. Thanks a lot. |
Any updates @oldani ? If there's anything you'd like me to do to make reviewing and testing easier then let me know. |
Hola @JamesMTSloan, I love the idea of combining test case results in a single report! I checked out your master branch and installed v1.1.2 locally; however, I'm having an issue: import unittest
import HtmlTestRunner
from tests.test_anagrams import AnagramsTests
from tests.test_bst import BinarySearchTreeTests
from tests.test_capitalize import CapitalizeTests
loader = unittest.TestLoader()
anagrams = loader.loadTestsFromTestCase(AnagramsTests)
bst = loader.loadTestsFromTestCase(BinarySearchTreeTests)
capitalize = loader.loadTestsFromTestCase(CapitalizeTests)
suite = unittest.TestSuite([anagrams, bst, capitalize])
runner = HtmlTestRunner.HTMLTestRunner(combine_reports=True)
runner.run(suite) Returns
There doesn't seem to be a way to raise an issue on your repo, so I'm asking here 😊 |
Hola @kimfucious My initial guess would be that you have the original version of HtmlTestRunner installed in your virtual environment instead of this branch and that your import statement is pulling in the version without the new report combining functionality. If you debug the code without the If the above isn't taking you to the expected file then you may need to uninstall the version of HtmlTestRunner without this kwarg, and reinstall from the branch. Look into virtual environments in Python if you are not already familiar with them as they are useful (necessary) for managing these kinds of package management issues. Cheers. |
Spot on, Señor @JamesMTSloan! My globals were a mess. I wound up discovering pipenv, and it's a beautiful thing. You know what else is beautiful? The test results from your master branch. ¡Olé! 🎉 Looking forward to this PR getting merged. |
Hello, Hopefully this PR gets merged soon. Super useful. |
added support for skipped tests skip reasons changed template to support subtests in sub-tables fixed bug where non-combined tests had summaries with details from all tests tweaked format of HTML has that info buttons line up better
Support added for sub-tests in sub-tables (#35) I've also tweaked the layout a bit. This required some hacking away at the template and with HTML and I'm no ace with HTML so if anyone wants to suggest some improvements that'd be nice. Either edit the template directly or edit a generated report and give it to me to change the template to reflect the changes. Note that summaries do not include individual subtests. |
…a stub in the report. this needed some rather ugly filtering but unittest seems to insist on calling addSuccess() in this case removed support for std.out in subtests for now as this was being accumulated across subtests
Hi there, @JamesMTSloan sorry it's this long time and I haven't merged this PR yet. Please add your name to the AUTHORS file. I will merge this temporarily in a feature branch so everybody can install it via pip + git url, until I can take time review it, merge it with some changes I have locally and release v2 which will have a lots improvements. Thanks for all the work done here, next time try not to put a lots of thing in a single PR (different features/issues on same PR). With the foloowing cmd you will be able to install this branch:
|
Hello,
|
#2) * Updated results.py to use the copy library so that it can be run using Python 2.7 * changed import order
Good feature but 6 months passed... |
Hello, Otherwise: well done! |
Sorry everyone I have abandoned this project, I will be merging this and releasing a new version. @JamesMTSloan Thanks again for this. |
* Fixed Template Wording * added following functionality: - support for combining reports into single report (combine_reports kwarg) - support for test cases with underscores in name - optional timestamping of filenames (add_timestamp kwarg) - optional automatic opening of generated reports in browser tab (paths to reports are returned from test result) (open_in_browser kwarg) - support for optional user variables to be passed to jinja2 template (template_args kwarg) - added tracebacks to reports - added stdout to reports (so tests that pass can also be expanded - print relative paths to generated reports - made default output directory the current working directory so there are now no required args also: - updated and adjusted readme - changed use of deprecated _TextTestResult -> TextTestResult - changed format of template slightly * - expanded test case names to include full path to classes (should avoid clashes from duplicate names) - simplified test method names * updated docstrings and deleted unused method * added check for template_args to be dict-like * changed how summaries are passed to templates: using a dict instead of a string to allow the user to customise their template more easily. also some other small tweaks. * updated readme to reflect changes to template variables * added optional report naming reduced prepended paths to testcase names except for when common testcase names need to be distinguished * added report_name usage to README * added a couple of tests showing use with unittest.main() and constructing test suites, including case where name collision between similarly named test cases is handled. combined reports and separate reports are shown. * re-imposed alphabetical ordering of unittest in how tests appear in reports. * added support for subtests added support for skipped tests skip reasons changed template to support subtests in sub-tables fixed bug where non-combined tests had summaries with details from all tests tweaked format of HTML has that info buttons line up better * fixed bug where subtests that all passed were duplicated with an extra stub in the report. this needed some rather ugly filtering but unittest seems to insist on calling addSuccess() in this case removed support for std.out in subtests for now as this was being accumulated across subtests * updated authors list * Updated results.py to use the copy library so that it can be run usin… (#2) * Updated results.py to use the copy library so that it can be run using Python 2.7 * changed import order
Version 1.2 has been released with all these wonderful changes:) Sorry everybody |
Hi @Eki23 , I know i am replying to very old post .I am expecting a similar html report which clubs all the test suite results into one single html report .But i am unable to get that even after setting combine_reports=True. HTMLTestRunner is at version 1.2.1 . My code below: #Here i have a for loop to iterate over each test suite containing multiple test steps(test cases) This is generating a single html report ,for example there are 3 test suites : test suite 1 generates a html report MyReports.html the same gets overwritten by test suite2 and then test suite3 . I want all test suite1, test suite2 and test suite3 results combined in single report (MyReports.html) . Can someone please help me i am totally stuck. |
@ramasa2 it isn't possible to tell from the edited code sample that you have posted but there is a chance that your for loop isn't constructed correctly. If If that is indeed the case then the solution would be to create # create the test suite
test_suite = unittest.TestSuite()
# add the tests one by one
for objTC in my_tests:
test_suite.addTest(objTC) #objTC contains my testcases
# run the tests all together and generate the report
res = runner.run(test_suite) |
@JamesMTSloan Thanks for your swift response .You are right my suite is being created in every iteration .Because each test suite is different set of test cases .The suggested solution above combines all the test cases (cant differentiate which test case belongs to which test suite ). Please refer Eki23's July 13 2018's post .The screenshot shows Jmeter Test, Report and logs Test and Baseclass Test .I wonder how did it happen to generate such report . I want such report .Am i missing to provide any info here ? Each of the test suites have their own test steps separately . |
Can runner.run take list of test suites i,e runner.run([suite1,suite2,suite3 ..]) where suite1 has 8 test cases ,suite2 has 4 tcs and so on . |
Can some one please help me on this . I am unable to get solution for this . |
Hi @ramasa2 This is what I have:
This is generating one report for each test suite. I do not combine the test suites reports in a single one, but if I wanted to do this, I would move the instantiation of the test suite before the loops, would iterate through all test suites and test cases to add them to the suite instantiated, and have the runner instantiated and run after, outside of the nested loops. Hope this helps. |
I have added some new functionality to
HtmlTestRunner
that you will hopefully find useful.HTMLTestRunner
combine_reports
kwarg toTrue
: this will produce a single file containing a separate table for each TestCase. (combining results to one html report #6)output
argument is now optional and defaults to a folder called reports under the current working directory ("./reports/"
) (HtmlTestRunner cannot be directly used with Django DiscoverRunner #12 I think)template_args
kwarg in the form of a dict (see readme for an example of its use)add_timestamp
kwargopen_in_browser
kwargEDIT: More features have been added as I've gone (see below). This started too big and has only gotten bigger so sorry about that.