-
Notifications
You must be signed in to change notification settings - Fork 144
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
How to name a test classname with a dot in it to match Sonar schema #69
Comments
Ran into this problem myself today. I think that the issue is really with the JsTestDriverSensor.java implementation from the sonar-javascript-plugin v2.8. That class has a method to get the test file names (AKA the "spec" file names). The method implementation cannot work when you have dots in the file name because it replaces all dots with "/". It does this because it assumes you are using dots as directory delimiters and that your file naming strategy is compatible with Java, (which doesn't allow dots in class names). Here is the method implementation I'm speaking of: protected String getUnitTestFileName(String className) { |
Spent some time on this, found a way to make it work w/ john papa's guidelines. In
Then, in your tests, the first describe block has to match the path and filename exactly; so dir/subdir/avengers.controller.spec.js needs to start with Then, in your karma.conf.js, configure the junit reporter:
When you run tests, karma-junit-reporter will write a
With those in place, sonar-runner can read the xml, use the classname to find the path to the test, combines that with the |
thanks @ryepup. I ended up writing my own sonar plugin to handle the test report xml. My plugin does not require that the describe block have any particular name. I found it too restrictive and brittle to limit what developers could name the describe blocks. For anyone interested, see the free plugin I wrote here: https://github.com/acwatson/sonar-karma-test-report-plugin |
Thank you @ryepup! I was trying to do this for a long time! |
I see that sonar will use a new schema (see bug #78). I think that this problem should dissapear as soon as this new schema is implemented. |
I'm tyring to rename my unit tests to get an JUnit output that is readable from Sonar. But I'm following the naming conventions of John Papas Angular Styleguide that includes dots in the filename. For examle:
avengers.controller.js
If this file is in dir/subdir/avengers.controller.js my classname shoult be:
according to the README here.
But this would try to find the file in
dir/subdir/avengers/controller.js
How should I name my test classname to find the file?
The text was updated successfully, but these errors were encountered: