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

Generate JUnit/XML test report #204

Merged
merged 15 commits into from
Apr 10, 2019
Merged

Generate JUnit/XML test report #204

merged 15 commits into from
Apr 10, 2019

Conversation

fchauvel
Copy link
Contributor

@fchauvel fchauvel commented Apr 8, 2019

Hi,

I added an option -j (or --junit-report) that serializes a GreenTestResult into an JUnit/XML file. I think this addresses Issue #104, a feature I also need.

I added a new module reporting.py, which contains an JUnitXML class. I then import this class in the cmdline.py module, once tests are run. A few preliminary unit tests are in the module test.test_reporting.py. Note that I had to comment out the deletion of captured output, once they have been displayed (see result.py) otherwise they are no longer available and I cannot include them in the report. The tests seems to pass (on my machine), but there may be consequences I do not foresee.

This implies a new dependency to lxml 4.3.3, which I use to generate the XML tree.

Does it sounds like a good approach? I can refine or adjust as needed.

@CleanCut CleanCut self-requested a review April 8, 2019 21:15
Copy link
Owner

@CleanCut CleanCut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, what a great feature! Take a look at my requested changes and let me know what you think.

green/test/test_result.py Outdated Show resolved Hide resolved
requirements.txt Show resolved Hide resolved
green/result.py Outdated Show resolved Hide resolved
green/config.py Outdated Show resolved Hide resolved
green/cmdline.py Outdated Show resolved Hide resolved
green/test/test_reporting.py Outdated Show resolved Hide resolved
green/cmdline.py Show resolved Hide resolved
green/reporting.py Outdated Show resolved Hide resolved
@fchauvel
Copy link
Contributor Author

fchauvel commented Apr 9, 2019

Thanks for looking at my code. I implemented the changes you suggested. There are other features I'd like to implement, including:

  • Reporting the time individually spent on each test. I haven't understood whether Green measures this.
  • Reporting the time spent per test suites.
  • Reporting the environment used to tests (python version, os, etc.)
  • Adding count of failing, skipped, erroneous tests per test suite. Seems straightforward.

What do you think?

@CleanCut
Copy link
Owner

I'm certainly open to your ideas (though I suggest they should each come in separate pull requests!). Given that I have never had anyone request these features, I would definitely want to focus on keeping the code fairly clean and making the new output optional in most cases. You did a good job on both of those in this PR. 😄

Green does not currently do any time measurements other than the one from start-to-finish of the entire run. You could add more timing measurements and output as a new option. Same with more fine-grained count summaries (I assume you mean per-module, because suites are a messy catch-all recursive construct and don't map one-to-one to modules at all). Where would you put the output? Are you thinking in-line with verbose output, or as a supplemental report after the run?

Oh, you should also be aware that Green runs tests simultaneously in multiple subprocesses. You'll want to take that into account if you start timing individual parts, because the times of tests from different processes will overlap. It would be really nice to get a sum of all processor time and combine that with the total time to produce a "speedup" measurement.

Some of the environment is output already if you do --version or lots of verbosity -vvv. That could certainly be expanded to include things like Operating System, etc.

@CleanCut CleanCut merged commit e400770 into CleanCut:master Apr 10, 2019
CleanCut added a commit that referenced this pull request Apr 11, 2019
@CleanCut
Copy link
Owner

✅ This shipped in 2.15.0, which was just released.

@CleanCut CleanCut mentioned this pull request Apr 11, 2019
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

Successfully merging this pull request may close these issues.

2 participants