Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
JUnit files are appended to with RSpec formatters #40
Hello, found an interesting case while using this gem.
I'm trying to add JUnit formatter to use the results in Jenkins using the
Jenkins (and from what I can see, XML parsers in general) don't like when there are multiple
The more important piece is this:
Detail on the error is in this stackoverflow: http://stackoverflow.com/questions/19889132/error-the-processing-instruction-target-matching-xxmmll-is-not-allowed
I can see an "after hook" of sorts be helpful here because we could just rename the file afterwards to something that won't be appended to and Jenkins can read the multiple files just fine.
I could create custom JUnit formatter. I did similar thing for summary:
After that the formatter could be specified in the knapsack command similar as here:
referenced this issue
May 22, 2017
I've tried the approach with hook and I did an example with hook after a subset of tests executed from the queue to rename the output rspec.xml file but then I figure out that actually the junit formatter cumulate results so each new rspec.xml has inside of it all results from previous subset queue run and there are multiple opening xml tags.
Related PR: #41
So it seems the only way would be to write custom junit formatter then. I will look into that or I will fork the gem to adjust it to knapsack_pro case.
Yes, that's what I did but the problem is with the way how formatter works when I execute multiple times the
The junit formatter keeps in memory xml from previous run so the next rspec.xml file has double xml tags even when the first rspec.xml file was renamed.
I did custom formatter for RSpec Queue Summary so I will have to do a similar thing for junit formatter.
This is how junit formatter dump xml to file:
I noticed when I use just junit formtter without my "after" hook then sometimes the xml file has weird content like the content was incorrectly appended to the file.
When I did rename rspec.xml file after each subset of work queue then the last generated rspec.xml file has correct content with duplicated xml tags. The last one xml tag contains the full report. So it means we would have to remove from rspec.xml the content till the last opening xml tag.
Here is short example of how last generated rspec.xml file looks like.
I will play more with this idea tomorrow.
@bobbytables I figured out this. Could you update knapsack_pro version and add the hook as described here:
Basically, we need to rename the rspec.xml in after subset queue so the file won't be appended with duplicated xml content. The last execution of tests subset from work queue will create the rspec.xml with xml that contains the tests from all subset runs (all tests from the particular CI node).
Please let me know if this works for you.