oggy / junit_merge

Merges JUnit XML reports.
MIT License
12 stars 6 forks source link

add_child method undefined #2

Open dyang opened 7 years ago

dyang commented 7 years ago

Hi,

I'm using junit_merge to merge a few junit reports into one. The command I use is:

junit_merge report0.xml report1.xml report2.xml

In which report0 is the junit report for the first run, report1 and report2 are subsequent re-runs that only include those tests that are previously failed.

The error message I get is:

/Users/dyang/.rvm/gems/ruby-2.3.0/gems/junit_merge-0.1.2/lib/junit_merge/app.rb:87:in 'block in merge_file': undefined method 'add_child' for nil:NilClass (NoMethodError)
        from /Users/dyang/.rvm/gems
[report.zip](https://github.com/oggy/junit_merge/files/736358/report.zip)
/ruby-2.3.0/gems/nokogiri-1.7.0.1/lib/nokogiri/xml/node_set.rb:187:in 'block in each'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/gems/nokogiri-1.7.0.1/lib/nokogiri/xml/node_set.rb:186:in 'upto'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/gems/nokogiri-1.7.0.1/lib/nokogiri/xml/node_set.rb:186:in 'each'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/gems/junit_merge-0.1.2/lib/junit_merge/app.rb:71:in 'merge_file'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/gems/junit_merge-0.1.2/lib/junit_merge/app.rb:43:in 'block in run'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/gems/junit_merge-0.1.2/lib/junit_merge/app.rb:30:in 'each'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/gems/junit_merge-0.1.2/lib/junit_merge/app.rb:30:in 'run'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/gems/junit_merge-0.1.2/bin/junit_merge:5:in '<top (required)>'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/bin/junit_merge:23:in 'load'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/bin/junit_merge:23:in '<main>'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in 'eval'
        from /Users/dyang/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in '<main>'

Do you know where things might have gone wrong? I'm attaching the test reports for your reference.

Thanks!

dyang commented 7 years ago

report.zip Hmm, attachment doesn't seem to be uploaded in the first place...

drkibitz commented 6 years ago

Same issue

drkibitz commented 6 years ago

The issues for me is that the root of the XML is testsuites not testsuite. Seems JUnit has changed since this gem was last updated.

quintuschen commented 5 years ago

I've made a PR (https://github.com/oggy/junit_merge/pull/3) for fixing this issue. Fixed the Xpath to adapt the JUnit schema changes for testsuites, also added a step to update the total failures.