Add support for dotnet test --collect:"Code Coverage"
Description
Add support for code coverage through dotnet test on Windows OS machine.
dotnet test --collect:"Code Coverage"
Do you have any plans for Linux ??
(edit from @codito: there are atleast 22 more votes in https://github.com/Microsoft/vstest/issues/579#issuecomment-305374623 for code coverage support in linux. Using this comment to keep track of linux support request)
Why the "having Visual Studio 2017 Enterprise installed" limitation? Is there any plan to lift it?
I believe collecting test code coverage during a CI build (with only the .NET Core SDK being deployed) would be a very valid scenario.
:+1: I'd very much love to have working code coverage within the confines of .NET Core.
@arpit-nagar test code coverage is VS enterprise and windows only so far, current plan is to get the same level of support in dotnet test (windows + VS enterprise). Mac/linux support isn't in our immediate backlog. /cc @pvlakshm @sbaid to consider the feedback for prioritization.
@harshjain2 This is a very basic requirement. And as dotnet core is multi platform this feature should also need to be available on Linux. Is there any way we can achieve code coverage on Linux for dotnet core project.
test code coverage is VS enterprise and windows only so far, current plan is to get the same level of support in dotnet test (windows + VS enterprise).
@harshjain2 What's the rationale behind requiring VS enterprise for code coverage?
Downloaded VS2017 15.3 and .NET Core 2.0 and after entering (dotnet test --collect:"Code Coverage") I get an error:
The test source file "C:\Application2\tests\Console.UnitTests1\Coverage" provided was not found.
Tried changing this to be (dotnet test --collect:"CodeCoverage") i.e. without the space and then get this error:
dotnet exec needs a managed .dll or .exe extension. The application specified was 'C:\Program' Object reference not set to an instance of an object.
It sounds to me like the status is that we cannot do code coverage for asp.net core 1.X using dotnet test at the command line. Is this correct?
I get the same as @rol-dave-overall. This is a show-stopper for us trying to get our solution build on Visual Studio Team Services. Disabling code coverage is not really an option.
Any available workarounds?
actually have the same problem. the vso test with --collect Coverage or "Code Coverage" not working. the runsettings tried with both names
code coverage - this is the most basic requirement. what serious organisation will commit to using dot net core in non Windows environment if such a basic functionality is not there? how business can make a decision to release something in production where test coverage is not known? It can be as fast and awesome - but without this basic support it pretty much unusable outside MS/Windows worlds. The Linux community would like to embrace dot net core on board - but look it just simply can't.
Yes, this feature should be available for all target platforms. It should not require an installation of Visual Studio.
Code coverage used to be a reason to upgrade to vs enterprise, but the rise of free alternatives such as OpenCover has removed the value proposition. Thus, code coverage should be added to the dotnet cli on all platforms to keep developers from using the alternative products available.
@harshjain2 Is there a timeframe for when this will be available? Add support for dotnet test --collect:"Code Coverage" microsoft/vstest#981
Supporting CC with the dotnet test command line is presently not scheduled in our pans leading up to Nov 2017.
However, the following will be possible with .NET Core tests:
- you can
vstest.console.execommand line runner and generate CC information (the CC data collectors are supported on .NET45). - If you are working from within VS on tests targeting .NET Core, then you will need to add a reference to the
Microsoft.CodeCoverageNuGet package to your test project, and update both the test and app-under-test projects to generate ‘Full’ debug info. Please see "Working with Code Coverage" here: https://github.com/Microsoft/vstest-docs/blob/master/docs/analyze.md (note that this is only a temporary workaround).
We are eager to get to this once we finish addressing a few more scenarios that are already underway.
@pvlakshm regarding point 2. Is it possible to get CC on windows build environment which have Test agent, and don't have VS?
@arpit-nagar, we are working towards that.
Code coverage is an essential part of CI. By all means, have a premium version available in a nice helpful way in VS but there should be, for example, a dotnet test --with-coverage=True --fail-under=95 type command for CI.
Hi, I was able to run vstest.console.exe with code coverage for .net core 2.0 project locally, but on build agent, with the same setup( i think it is same :)) I've receiving next error : "Failed to initialize client proxy: could not connect to test process."
Hi!
So as far as i understand code coverage can only be generated localy by VS Enterprise users? There are no howtos for setting it up in TFS with a build agent (on premises) without installing VS enterprise on a build agent machine?