-
Notifications
You must be signed in to change notification settings - Fork 274
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
Objc : Unable to locate test source file ****.swift #242
Comments
From those logs, it looks like your test is contained in a test class named GenericViewController (wether it's swift or objective-c). -Did you set the |
Hi David, here are my answers: -Did you set the sonar.tests path property in sonar-project.properties file? it is the directory where the tests files are. -Make sure your test class file is in that path (or in a folder in that path) My understanding is that the tool look for Tests_GenericViewController.swift but it should be Tests_GenericViewController.m ??? |
Did you set |
@egr-ext actually it looks for both. That's why you also have the log Can you provide a sample of your TEST-report.xml file? |
yes: sonar.language=objc |
here is an extract:
|
The classname should be |
The filename is Tests_AngelContactGenericTableViewCell.m Here is an objc sample: file path: ./MyApp-unitTests/Tests_AngelContactGenericTableViewCell.m
|
I tried with backelite-sonar-swift-plugin-0.4.5.jar but I still does NOT have the number pf tests reported. Is it an issue with tests files name containing "_" ? |
Indeed I think your issue is related to that. |
Hi Gael, Yes but no success again:
2/ I ran the analysis -> in Sonar I can see all indicators (coverage) but the number of tests is still missing. I have no clue .... Additionnal info: I ran an analysis using the same environnement (CI, Tools, ...) on a basic "Hello Word" swift project and the number of tests is showing in Sonar. For info: I have this warning:
|
Which version of xcode and xcpretty do you use? Looking back at your TEST-report.xml file, I see that the value of classname is : In mine, I have the package name as a prefix, something like Here is how it currently works: given a test report, a test case with classname So it searches for If no file is found, it then takes the last path component, here If nothing is found, it can't provide the tests to your SonarQube report. Does it help? |
Xcode: Version 10.3 (10G8)
Yes but I can see only that on a swift project. On an Objective C project it seems it is not prefixed by the directory name
My project file structure is like that : In the file sonar-project.properties I configured the tests directory:
Here is the Fastfile for Fastlane:
|
Anyway can we re-open this issue ? |
Your scan command seems to be running directly on test scheme. That may be the reason why your junit report file doesn't include the package name as a prefix. |
I get the same result. They are not prefixed with package name.
My guess is the issue is related to Objective C language analysis. |
Can you provide this project sample so we can reproduce? (attach the zip here) |
Here it is: |
Looks like the Junit is malformated. |
You might also want to have a look at my PR #241 For fastlane integration with the same behavior as the bash script |
Sorry I don't understand which script ? |
The script detailed in the README, section Launching the analysis. |
OK. The script keep saying some swift parameters are missing ex: sonar.swift.appScheme parameter is missing in sonar-project.properties. You must specify which scheme is used to build your application. But I have a Objective C project ... DO I have to set swift parameters ? Plus I use Fastlane so I use this script to understand but it is not easy to find why it does not work with Fastlane |
So I ran the script run-sonar-swift.sh. I have the same result. TEST-report.xml:
And I don't have the numer of tests. Here is the zip of the objc project: |
I'am 100% convinced that it is a bug for Objective C source code only. @gaelfoppolo or @davidy4ng do you have an ObjC project that works as an example I can check ? |
I added some logs to the Logger.. I keep analysing |
I found the issue !!! |
Thanks @egr-ext |
Nice work @egr-ext! I'll have a look at your PR! |
Fix issue #242 when objc test classes and files are not found
PR merged ! |
Describe the bug
The sonar report has 0 tests reported but the coverage is ok.
I saw these warnings:
INFO: Processing Surefire report TEST-report.xml
INFO: Unable to locate test source file Tests_GenericViewController.swift
INFO: Unable to locate test source file Tests_GenericViewController.m
INFO: Unable to locate test source file Tests_GenericViewController.swift
But as my project is in Objective C the test file names end with .m not .swift.
So the tool does not find the files.
The text was updated successfully, but these errors were encountered: