karma-junit-reporter icon indicating copy to clipboard operation
karma-junit-reporter copied to clipboard

SonarQube don't import unit test results anymore

Open americoneto1 opened this issue 9 years ago • 11 comments

The latest version of JavaScript Plugin (2.10) from SonarQube removes the ability to import unit test results using JUnit format, they recommend to use another plugin (Generic Coverage) that uses a different XSD Schema.

Anyone uses this feature? Do you have any solution for that?

It's related to #69

americoneto1 avatar Feb 08 '16 18:02 americoneto1

This another reporter is compliance with Generic Coverage Plugin: https://github.com/tornaia/karma-sonarqube-unit-reporter

americoneto1 avatar Feb 08 '16 20:02 americoneto1

the mentioned plugin isn't functional on my project; but imho it is a very good feature for this plugin to comply to the somewhat more strict XSD Schema so SonarQube is supported out-of-the-box with some settings

tubbynl avatar May 04 '16 07:05 tubbynl

Sorry, what is imho? Do you import test results from Karma execution to SonarQube using other tool? Which setting do you use?

americoneto1 avatar May 04 '16 10:05 americoneto1

I also faced that issue when make integration with Sonar

fetis avatar Nov 30 '16 15:11 fetis

Hi,

Is there any plan to support new Sonar format for reporting test result ? https://docs.sonarqube.org/display/PLUG/Generic+Test+Coverage

Reporters out there supporting this new format are not actively maintained. It would be great if the karma team supports it !

Maybe a new plugin to keep backward compatibility with the old format ? Or an option in this plugin asking for format ?

Best regards.

r0main avatar Jan 13 '17 22:01 r0main

Good question, whether to keep this plugin as-is and make a new one. @r0main

Anyhow, on the surface, the new Sonar XSD (schema) would mean only changing a couple of strings in the index.js of this plugin.

So if the "rules" themselves are as they were in the older schema, the change is quite small. (Does someone read XSD ? :)

I'll take a shot at it.

jpaulin avatar Jan 19 '17 08:01 jpaulin

Code ready in PR 117, please try it out and report on findings.

I have validated the new XML being produced by the pull request, against Sonar's XSD schema file. What I would really like to know is does the new XML satisfy a running SonarQube.

Of course also very interested to see whether there's any other issue. Tried to keep everything already working in status quo, ie. not disturb old code.

Two things for testing: i) add a new config line into karma.conf.js The essential line is thus the last line in snippet below:

junitReporter: {
      outputDir: './test_out',
      outputFile: undefined,
      suite: '',
      useBrowserName: 'false',
      nameFormatter: undefined,
      classNameFormatter: undefined,
      properties: {},
      xmlVersion: 1
    }

ii) place the new index.js from the pull request, blob below: https://github.com/jpaulin/karma-junit-reporter/blob/34303edae95d967d06dfd31d91f7b179d3bbcba8/index.js

jpaulin avatar Jan 26 '17 14:01 jpaulin

tnx for the effort @jpaulin PR #117 is merged is see 👍

tubbynl avatar Apr 13 '17 14:04 tubbynl

Thank you @jpaulin very much for adding this support! I have done some testing and found a couple of open items: "skipped" tests require a message attribute. A element is needed with name=full path of test file for each test. Is this possible to get from the karma result?

bmorenc avatar Apr 18 '17 20:04 bmorenc

@bmorenc This is good feedback, big thanks. As the code in my PR was rather large, I see that definitely missed these - I had too narrow test coverage, kind of, and thus was only testing for the obvious "positive" cases of test results, ie: 1. test passes or 2. A test fails. I see there are those issues in the code, will fix these.

jpaulin avatar May 05 '17 08:05 jpaulin

Thanks @jpaulin for this!

I noticed that the output has: <file path="fixedString">

SonarQube documentation says that this should be either absolute or relative path the the test file.

Is this maybe something that is already being worked on or something that could be contributed with?

arhohuttunen avatar Dec 08 '17 12:12 arhohuttunen