Closed polortiz4 closed 1 year ago
@polortiz4 Hey, I need to have a look in details. There is some assumptions on how the file path are specified in the coverage file. Could you send me an extract of a coverage file on a project where you are using that hierarchy?
Sorry, I just saw you replied to me. I'll try to replicate the issue and send you the file (I've switched systems since last time)
Maybe the fix is in this file/line. I changed it and worked for me, on Windows.
src/files-loader.ts line 34
From:
const coverageFileFullPath = iopath.join(workspaceFolder.uri.path, filePath, fileName);
To:
const coverageFileFullPath = iopath.join(workspaceFolder.uri.fsPath, filePath, fileName);
@elbeshenrique Had a look, that fix is probably going to fix some bugs (UNC paths and similar...) but won't fix the issue here. The part of the path "src/main/java" is neither in the Jacoco coverage file nor in the workspace points to root. I have no idea for now how to fix this properly. @polortiz4 can you share a full folder with the sources, which plugin you use to run the tests and generate the report? (Or command line if you do it using command line). The fix might in the way the report is generated.
Have a look at the first screenshot which is an extract from the jacoco file and then you can see the watch on the left with the result how the data is read. (src/main/java could be src/main/java/example/example2/... or shorter, meaning if it is not present the jacoco, I can't see how we can "guess" it)
Thanks all for your help.
try-vscode.zip Sorry again, I forgot to upload this after you requested it.
Thanks, that helps a lot. Actually I realised it is a common issue with Jacoco and Java. I had a look at https://github.com/ryanluker/vscode-coverage-gutters and realised they had to do file matching when trying to bind the coverage to the file open in the text editor. They probably realised those file path issues which might exist in different environments. In any case, I implement a similar fix, much simpler and tests are ongoing. I will build a version for you and share it here to be tested when you have time/chance. Thanks for your contributions.
@polortiz4 Sorry for delay, life kept me really busy. I published the extension to the market place with the fix. Could you test and confirm it is fixed?
Hello!
I am facing the same issue. My project structure is:
root | _ appLibrary - test | |
---|---|---|
_ demoApp |
They are separate projects, I am building a library which is in appLibrary (the one I want to test) and a demoApp which is just going to consume for viewing purposes only.
I added flutter-coverage.coverageFilePaths = ["appLibrary/coverage"] in order for the plugin to recognize only test files in appLibrary. But when I take a look on the coverage tree it displays like this:
root | | lib (inner folders), which of course don't exist.
@neirupr Hi, can you send me a zip with a sample project having the same issue? What version do you have? Thanks for the feedback
@tenninebt
Attaching the whole project. Inside it you need to run $ cd demo then $ flutter test --coverage
When you watch the coverage tree you will face the error when you click over any of the source files in that tree. I think it happens because demo project is not located directly in the root but in a subfolder. I think a good solution would be to make the path relative to value specified in "flutter-coverage.coverageFilePaths" in settings.json which you will also find in the root project.
Hi @neirupr, I will have a look in details, but as a workaround, when you have multiple projects inside your root, create a Workspace and it should work better. I use the workspace to locate folders as of now when you have more than a project in your root.
You can start with an empty VSCode window, then, File>Add Folder to Workspace and select demo. Do the same for your second folder which is demo_consumer, then File>Save Workspace As and save your workspace. Try this and let me know if it works for you, until I have a more permanent fix. (Check the zip below, contains your example but with a vscode workspace and in VScode, just do File>Open Workspace from File and select "demo.code-workspace")
As I explained before, depending on the test framework, the file path inside the coverage files are not always relative to the project root, so I had to workaround it trying to match files from the workspace to paths on the coverage file. I can't use the coverage path can not be a "reference".
I had a look, and I'm not sure there is a proper way to do it. The issue here is that you are running your flutter test command from a different "root" than your VSCode workspace "root". @neirupr check my previous suggestion and tell me if that works out for you. I will consider this issue resolved if no new from @polortiz4 in the next week. Thanks
So I'm enjoying this extension and currently have only one issue with it:
My file structure is
(among other, likely irrelevant, stuff)
Even though koverage correctly identifies the test coverage, when trying to open the source file from the koverage explorer, I can see the extension attempts to open "root/my/package/Thing.java" instead of "root/src/main/java/my/package/Thing.java" Is there a way to fix this so koverage knows the correct absolute path to my file?