Closed philipogorman closed 8 years ago
The addin should automatically pick it up. If you have the cpp file open, you might need to close it and open it again.
On first sight it seems like cmocka simply executes from main, which means your project will compile to a EXE. You can try to right-click on that project and select 'run code coverage', which should work.
If that's no luck, could you verify if:
Attached is the Coverage.xml file that I am using. I have it in the same folder as the .sln file. You are correct, cmocka is run from within simple console application. I tried right-click and select 'run code coverage' but I get a "Object reference not set to an instance of an object" error.
The code am I testing is all c, so maybe that is causing an issue? I can send you the solution via dropbox, I'm really eager to get this running - this looks like a great add on!
I just checked the xml file, it should be fine.
If you can share the solution, that's probably the fastest way to figure out what the problem is. You can sent the link to [cens].
Ok - I just sent the dropbox invitation. The VS test solution is actually a subfolder in a larger IAR embedded project. All the source files tested are located in different directories to the sln folder. Maybe this causes issues? Let me know if I can help in any way. Thanks again
I just checked and made a small update. You can download the new VISX for a fix.
The main issue here was that I expect all projects to be x64. Your solution was set to x64, while the project was not.
I've just added support for Win32 targets and some auto-detection mechanism that gives you a proper error (you do need to install OpenCPPCoverage x86 for that!).
If you now execute the coverage (right click...), it'll work. You can get a report from tools -> coverage report, that gives you results.
One other problem might be that the solution file is not in a folder that also contains all the code that you want to check for coverage. This is a requirement from my part, to ensure we're not measuring coverage from f.ex. stdlib, third party libraries, etc. Unfortunately there's no good solution for this, which is why I use the solution folder as a 'sources' filter...
Basically what happens is that I call:
opencppcoverage.exe --quiet --export_type cobertura:"coverage.xml" --continue_after_cpp_exception --cover_children --sources [path-to-solution] -- YourTest.exe
That should give you all the information that you need.
Excellent. I'll tested and its works great! I just had to move my soln file up one directory level. This is a fantastic add-on!
Some things I found 1) The tools expects opencoverage to have this path: "C:\Program Files (x86)\OpenCppCoverage\x86\OpenCppCoverage.exe". The default install path is actually "C:\Program Files (x86)\OpenCppCoverage\OpenCppCoverage.exe" 2) The tool looks for a file named "CodeCoverage.xml" not "Coverage.xml" like the documentation says.
Also, is there anyway to toggle the highlighting on/off?
Thanks again for your help and the tool. This really adds another level of usefulness to my testing.
1) The tools expects opencoverage to have this path: "C:\Program Files (x86)\OpenCppCoverage\x86\OpenCppCoverage.exe". The default install path is actually "C:\Program Files (x86)\OpenCppCoverage\OpenCppCoverage.exe"
Actually I've implemented the latter to be a fallback. At least, that's what I thought I did.
The tool looks for a file named "CodeCoverage.xml" not "Coverage.xml" like the documentation says.
Thanks, I'll look into it.
Also, is there anyway to toggle the highlighting on/off?
Well, yes and no. I had been thinking about that. Currently, if you change a file, save and re-open, it will remove the highlighting. Basically the time stamp of the coverage file is compared to the timestamp of the code files. Still, I have to think about that a bit more.
I've been thinking of adding a button somewhere to toggle it as you suggest, but so far I haven't come up with a good solution. If you have a good suggestion, please make a new ticket and tell me, and if I like it I'd happily implement it. :-)
I am using a different test framework (cmocka). I can generate the Coverage.xml file, I copy it the solution folder. How do I view it within visual studio? "If you don't use MSTest, you can still use the Cobertura XML file generated by OpenCPPCoverage as "Coverage.xml" to the solution folder."
Thanks, Philip