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
Is there a good example of excluding modules from code coverage using vstest.console.exe only? #2038
Comments
@shueybubbles Also, how are you trying to collect code coverage? We recommend folks to always use vstest.console to gather coverage. Can you also share logs? https://github.com/microsoft/vstest-docs/blob/master/docs/diagnose.md contains how to collect logs for test paltform. |
Here's a sample command line using a .runsettings file. Notice I'm trying to use the Microsoft.TestPlatform nuget package so I don't have to install VS on build agents.
the test immediately pops up an error dialog with this output
Alternately, if I remove the .runsettings file and use --collect, no problem:
The only issue I have with this usage is the .coverage file has data for DLLs I don't care about like moq and NUnit which I want to exclude. |
@shueybubbles
This is the exact runsettings I provided: https://docs.microsoft.com/en-gb/visualstudio/test/customizing-code-coverage-analysis?view=vs-2019#sample-runsettings-file Can you please share your runsettings file as well as diag logs with us? |
It works for me with the same file, but as soon as I remove a few of the excludes sections (my binaries use the same public key listed , for example) it fails with this error in the log.host
|
ok. I figured out that the settings file parser is not resilient to improperly formed regular expression on excludes IE this leads to the failure:
So it's a user error but the tool should be more resilient. |
This issue is a different issue. #2008. We will be giving fix for this soon.
Seems like you are able to exclude modules in code coverage now. |
I'm pulling my hair out trying to get this to work. I am using the sample .runsettings file from the previously linked path. I am running: (do I need --enablecodecoverage? Seems to be the same with or without it) Then: The XML contains DLLs with Microsoft in the name. (which to me looks like they should be excluded). I have added XUnit to exclude and still get XUnit listed in the XML and the report generated from it with report generator. .*\.dll$ .*\.exe$ .*CPPUnitTestFramework.* .*XUnit.*XUnit dlls are included in the reports as well. I have looked at the log and it shows my runsettings with the added XUnit exclusion. BTW: I am running this in the mcr.microsoft.com/dotnet/framework/sdk:4.8 windows container. Any help appreciated. I would expect not to see Microsoft.SignalR.xx or XUnit.* dlls at all. |
I have seen examples of using a .runsettings file to exclude modules, but when I try to use a runsettings file with my tests and the vstest.console from the microsoft.testplatform nuget package it gives me an error about not being able to launch codecoverage.exe.
I see that vstest.console.exe accepts Runsettings parameters; is there a way to list modules to exclude in that command line?
The text was updated successfully, but these errors were encountered: