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

any unit test result referring to any scala test class (using scalatest) won't show in the sonar #8

Open
kknd22 opened this issue Mar 21, 2016 · 6 comments

Comments

@kknd22
Copy link

kknd22 commented Mar 21, 2016

I have issue for sonar to understand the test result from scalatest. And I found the following reference.
Do you have answer for it? For me, code coverage is fine the problem is only for unit test result from the test-results directory, where contains the result *.xml files. If the xml refer to a java class then is fine. If it points to a scalatest file then it won't show up.

How to make SonarQube analyzing SBT projects (with Java and Scala) and importing code coverage & unit test coverage?

Thanks
-cl

@hcoles
Copy link
Contributor

hcoles commented Mar 22, 2016

The scalastyle plugin doesn't do anything with test results - it's narrowly focussed on running scalastyle.

We'd prefer not to make this into a general Scala plugin, but as one doesn't currently exist we're happy to accept pull requests here until there's enough non scala style functionality for it to be moved out elsewhere (see #7)

That said, I'm not clear on what is involved in getting this to work. The issue might only be fixable in whichever plugin is currently responsible for reading that XML file.

@maiflai
Copy link

maiflai commented Mar 23, 2016

I think this relates to maiflai/gradle-scalatest#29. The underlying problem seems to be that the SurefireSensor expects Java source files, not Scala.

It seems appropriate to create a ScalaTest plugin?

@kknd22
Copy link
Author

kknd22 commented Mar 23, 2016

thanks Stu.
It looks like groovy community has similar problem, maybe we can use similar approach to solve the issue?

http://grepcode.com/file/repo1.maven.org/maven2/org.codehaus.sonar-plugins/sonar-groovy-plugin/0.6/org/sonar/plugins/groovy/surefire/SurefireSensor.java#SurefireSensor

-cl

@maiflai
Copy link

maiflai commented Mar 23, 2016

Yes, it looks like they have forked the Java implementation. Sadly this looks like a lot of copy-paste.

@kknd22
Copy link
Author

kknd22 commented Mar 30, 2016

I am looking at if using the similar approach, how much effort is it for scala... anyone else have a general feelings on this?

@maiflai
Copy link

maiflai commented Mar 31, 2016

"It depends".

I think that the Groovy implementation only works for tests which are defined in a file with a name which matches their classname. Groovy doesn't actually require this, so there is an opportunity for the reported metrics to be wrong. Scala has a similarly loose approach to source files.

I think it might be possible to supply a dummy InputFile rather than dropping the tests for which no source can be found.

It doesn't look like much work to implement a simple JUnit parser and SonarQube writer; the java and groovy plugins look complicated because they combine multiple analysers.

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

No branches or pull requests

3 participants