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

The file name {n} was not found in any package directory. #13

Closed
fransf-wtax opened this issue May 9, 2024 · 4 comments
Closed

The file name {n} was not found in any package directory. #13

fransf-wtax opened this issue May 9, 2024 · 4 comments

Comments

@fransf-wtax
Copy link

I was very excited to try this to get my Apex unit test coverage metrics into SonarQube!

However, when I run the transformer, I just get a list of similar warnings:

Warning: The file name 0 was not found in any package directory.
Warning: The file name 1 was not found in any package directory.
Warning: The file name 2 was not found in any package directory.
Warning: The file name 3 was not found in any package directory.
Warning: The file name 4 was not found in any package directory.
Warning: The file name 5 was not found in any package directory.
Warning: The file name 6 was not found in any package directory.
Warning: The file name 7 was not found in any package directory.
Warning: The file name 8 was not found in any package directory.
Warning: The file name 9 was not found in any package directory.
Warning: The file name 10 was not found in any package directory.
Warning: The file name 11 was not found in any package directory.
Warning: The file name 12 was not found in any package directory.
Warning: The file name 13 was not found in any package directory.
Warning: The file name 14 was not found in any package directory.
Warning: The file name 15 was not found in any package directory.
Warning: The file name 16 was not found in any package directory.
Warning: The file name 17 was not found in any package directory.
.
.
.

followed by an error:
Error (1): None of the files listed in the coverage JSON were processed.

No output file is created.

I'm not sure where it gets the "file name 0" etc. from. There are actual file names (more accurately, class names) in the test coverage report, e.g. "name":"UTIL_ImportUtils"

The coverage file I'm trying to transform looks like this:

[{"id":"01p9X00000DKqDQQA1","name":"UTIL_ImportUtils","totalLines":28,"lines":{"9":1,"10":1,"11":1,"12":1,"14":1,"17":1,"20":1,"21":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"32":1,"43":1,"44":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"59":1,"60":1,"61":1,"62":1},"totalCovered":28,"coveredPercent":100},{"id":"01p9X00000DKqCiQAL","name":"DTO_PicklistValue","totalLines":11,"lines":{"11":1,"13":1,"14":1,"15":1,"18":1,"20":1,"21":1,"22":1,"23":1,"25":0,"26":1},"totalCovered":10,"coveredPercent":91},{"id":"01p9X00000DKqDLQA1","name":"UTIL_BaseImporter","totalLines":7,"lines":{"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"10":1},"totalCovered":7,"coveredPercent":100},{"id":"01p9X00000DKqCfQAL","name":"BATCH_LargeListDBOperation","totalLines":13,"lines":{"6":1,"8":1,"10":1,"13":1,"15":1,"18":1,"22":1,"23":0,"24":1,"25":1,"26":0,"27":0,"30":1},"totalCovered":10,"coveredPercent":77},{"id":"01p9X00000DKqChQAL","name":"DAL_Search","totalLines":153,"lines":{"6":1,"7":1,"8":1,"18":1,"19":1,"36":1,"37":1,"40":1,"42":1,"44":1,"47":0,"48":0,"49":0,"52":1,"53":1,"63":1,"65":1,"66":1,"68":0,"72":1,"74":1,"75":1,"77":0,"83":1,"85":1,"89":1,"91":1,"93":1,"94":0,"95":1,"96":0,"98":1,"102":1,"104":1,"105":1,"106":1,"108":0,"113":1,"115":1,"116":1,"117":1,"118":1,"119":1,"122":1,"123":1,"124":1,"125":1,"132":1,"133":1,"135":1,"136":1,"139":1,"140":1,"143":0,"144":0,"147":1,"148":1,"153":0,"154":0,"155":0,"162":1,"163":1,"165":1,"169":0,"170":0,"173":1,"174":1,"176":1,"179":1,"180":1,"182":1,"184":1,"186":1,"189":1,"190":1,"191":1,"198":1,"199":1,"201":1,"202":1,"203":1,"208":1,"210":1,"212":1,"213":1,"214":1,"215":1,"216":1,"220":1,"223":1,"224":0,"228":1,"230":1,"231":1,"232":0,"235":0,"236":0,"240":1,"241":1,"242":1,"243":1,"244":1,"245":1,"247":1,"249":1,"250":1,"251":1,"252":1,"253":1,"257":1,"260":0,"261":0,"262":0,"269":1,"270":1,"271":1,"275":1,"276":1,"279":1,"285":1,"286":1,"287":1,"288":1,"291":1,"292":1,"302":1,"303":1,"305":1,"306":1,"308":1,"310":1,"312":1,"315":1,"322":1,"323":1,"325":1,"326":1,"327":1,"331":1,"337":1,"339":1,"340":0,"344":1,"346":1,"349":1,"350":1,"351":1,"353":1,"355":1,"356":1,"357":1,"360":1,"362":1},"totalCovered":130,"coveredPercent":85},{"id":"01p9X00000DKqDMQA1","name":"UTIL_Constants","totalLines":17,"lines":{"3":1,"8":1,"9":1,"10":1,"21":1,"50":1,"58":1,"59":1,"60":1,"61":1,"62":1,"64":1,"65":1,"66":1,"67":1,"68":1,"70":1},"totalCovered":17,"coveredPercent":100},{"id":"01p9X00000DKqDOQA1","name":"UTIL_CsvReader","totalLines":58,"lines":{"5":0,"9":1,"10":1,"12":1,"13":1,"14":1,"15":1,"18":0,"19":0,"25":1,"26":1,"32":1,"33":1,"35":1,"38":1,"39":1,"41":1,"42":1,"45":1,"49":1,"51":1,"59":1,"60":1,"62":1,"64":1,"65":1,"67":1,"68":1,"72":1,"80":1,"81":1,"82":1,"84":1,"85":1,"88":1,"91":1,"93":1,"95":1,"99":1,"100":1,"102":1,"104":1,"105":0,"108":1,"110":1,"112":1,"113":1,"116":1,"118":1,"119":1,"121":1,"122":1,"124":1,"125":1,"129":1,"133":1,"134":1,"137":1},"totalCovered":54,"coveredPercent":93},

etc.

Any idea what the issue is here?

Thanks!
Frans

@fransf-wtax
Copy link
Author

OK, apparently the code coverage report you get from sf apex run test -c -r json is vastly different from the one you get when running sf project deploy start --coverage-formatters=json.
No ideas why two Salesforce CLI commands that essentially do the same thing would do that thing is such a different way...

@mcarvin8
Copy link
Owner

mcarvin8 commented May 9, 2024

@fransf-wtax - Thank you for reporting this issue.

Yes, this is due to the deltas between the JSONS created by the CLI's deploy command and the test command. I'm not sure why they follow different formats. But there are current bugs open against how deploy returns covered lines in their coverage files and I don't think the issue happens with the test command. You can refer to this issue on the CLI repo for more information on what's wrong with how deploy command return code coverage - forcedotcom/cli#1568

In regards to supporting the sf apex run test JSON coverage file, I have just released a new version of this plugin which should support the JSON interface of the test command.

Please this new version out when you can.

I tested this out with the coverage JSON example you provided (after updating file names to match my test files) and it was able to create coverage XMLs in the same format accepted by SonarQube.

sf plugins install [email protected]

To run this plugin correctly for the test command, you must supply this new command flag named --command/-c with the value "test". If you don't provide this new flag, it defaults to the "deploy" command which will use the different JSON interface.

sf apex-code-coverage transformer transform -j "coverage.json" -x "coverage.xml" -c "test"

@fransf-wtax
Copy link
Author

@mcarvin8 This is amazing! I tried out the new plugin and the support for sf apex run test reports and it works like a charm. Thank you!

@mcarvin8
Copy link
Owner

Great news! Thanks for the update!

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

2 participants