Code duplication / Unit test number not correct
jaernouts opened this issue · 7 comments
Hello,
I almost set up the project correctly, nevertheless some things are not working. My unit test coverage, my issues are shown correctly and also my number of lines / comments are correct.
Code duplication is not working and I can't find what I'm doing wrong.. Do I have to enable something somewhere? Also, I have a folder 'tests/classes' with subfolders model, viewmodel, etc. If i set 'sonar.tests' to 'tests/classes', the number of tests is not shown (the test coverage is). If I add all the subfolders separately, they do. So it appears that that call is not working recursively. Do I need to change a setting for that or do I really need to add all my subfolders manually?
Kind regards!
Jens
No one...?
I need to check but if I remember right it's sonar.objectivec.testScheme that is used to run the tests and get the unit test report and coverage report.
sonar.tests is a default SonarQube parameter, I have to check what it exactly does in case of this plugin. What happens if you don't set it?
I indeed set 'sonar.objectivec.testScheme' to my test scheme, so that's correct for sure. The tests are running, so that's not the problem. I also see the coverage report as you see in the image attached, the problem is that I don't see how many Unit Tests I have, how many are succeeded and/or how many are failed...
My folder structure is like this:
<main_folder>:
--app
--tests
----model
------test1.m
------test2.m
------...
----util
------test3.m
------test4.m
------...
When I set sonar.tests to <main_folder>/tests, I have the issue like on the image attached. When I set sonar.tests to <main_folder>/tests/model,<main_folder>/tests/util (so added the subfolders separately), the number of tests are shown correctly. Nevertheless, when I now add a test in <main_folder>/tests, I don't see it added, except when I also add <main_folder>/tests to sonar.tests. But when I try that, I get an error that I can't add a folder multiple times to sonar.tests (because <main_folder>/tests/model/ and <main_folder>/tests/util/ are subfolders of <main_folder>/tests/)
can you check what is the content of TEST-report.xml in the folder 'sonar-reports' at the root of your project? Does it contain all test cases, or only the one from the folders sonar.tests?
I have checked my personal projects, and I am not setting sonar.tests. Could try that?
Otherwise have you tried to put a wildcard in sonar.tests? Like /tests/** (I have not tried it, sorry)?
- The TEST-report.xml contains all my tests and the total test amount is correct
- When I remove sonar.tests, I have the same issue (And in the sonar-project.properties you provide as example, there's also stated that removing will just ignore them "# Path to test directories (comment if no test)")
- I can't use a wildcard, when I do, Sonar cannot be executed: "The folder 'UnitTests/**' does not exist for ..."
Could you maybe give me an example project where you have the same situation working? So with the folder structure I described...?
Any JUnit reporter for Xcode projects I've tried using does not record a fully qualified class name (with the package representing the directory to the class file) in the XML.
PR #97 fixes this by searching the test sources index for **/ClassName.m
. However this only works if the test class name matches the file name it's in. Searching by the real class name would require implementing the lexer.
Hi Cyril, I'm also setting up an objc project and I have the exact same problem. It only looks directly under the folders setup in source.tests, not recursively. I have a mixed objc/swift project, and when I use the swift plugin it drills through all the subfolders and finds the tests.
Hence I think the problem is with the plugin. Do you have any time to look into this?
Thanks