-
Notifications
You must be signed in to change notification settings - Fork 326
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
Add support for dotnet test --collect:"Code Coverage" #981
Comments
Do you have any plans for Linux ?? (edit from @codito: there are atleast 22 more votes in #579 (comment) 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. |
👍 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. |
@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' |
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? |
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? |
Supporting CC with the
We are eager to get to this once we finish addressing a few more scenarios that are already underway. |
@pvlakshm regarding point 2. |
@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 |
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 : |
Wooo I look forward to that! |
Cobertura support is added to code coverage. It is available in the following version. https://dev.azure.com/dnceng/public/_packaging?_a=package&feed=test-tools&package=Microsoft.CodeCoverage&protocolType=NuGet&version=17.1.0-preview-20211118-03 To get cobertura report, add
Available format options: Coverage (default binary file format) |
In package https://dev.azure.com/dnceng/public/_packaging?_a=package&feed=test-tools&package=Microsoft.CodeCoverage&protocolType=NuGet&version=17.2.0-preview-20211214-01&view=overview Currently we support:
|
Based on microsoft/vstest#981 (and @jakubch1 can confirm it) This can now be accomplished on other platforms as well, assuming the use of Microsoft.NET.Test.Sdk 17.0.0.+
Thanks to the preview version here indicated (now I use the 17.1.0-preview-20211130-02 version) I'm now able to generate code coverage in two different way for obtains Full coverage and the Diff coverage (for Pull Requests) on Azure DevOps. The problem:If I understood well, in Azure DevOps if you want the "Code coverage" tab on the build page and you want to visualize the report directly in a friendly way (and not to download it), your pipeline have to generate files in supported formats, like cobertura.xml, as poorly described here. Solution:My solution involves in creating two different pipelines. The first pipeline is for the Full Coverage.
This works really well. Please note that:
The second pipeline is for the Diff Coverage on the Pull Request.
Now, this works but is not good enough. Is lovely to have PR Diff coverage policy (that part works well) but I find awful to have two pipeline instead of one. There have too much in common. And is strange that the native Microsoft .coverage format is not supported by Azure DevOps for report visualization on the build. Apart from these problems to which I hope to find a solution soon, I believe I have successfully obtained the two different code coverage. Tell me what you think or if you think there are improvements to be made. 2022/02/19 - EDIT :
|
Hi @gioce90, I have a slight clarification does the above pull request builds run all [old+newly added] tests or only the newly added tests would be ran when a PR is raised? |
Hi @Manikandanmani , this builds and run all them (old and new tests). |
Hey, @nehsharmMS mentioned in her comment that Microsoft has a new preview version of the Azure DevOps for code coverage, as I understood now it's possible to display Code Coverage tab and info when just publishing .coverage file. Is that true? |
I don't know @simonachmueller , I'm not so sure about that.... |
I could be missing something, but would anyone be able to explain why this works in linux for one project and not another project where the only difference is MSTest vs XUnit? The error indicates that it'll only work on Windows. |
For version >= 17.5.0-preview-20221021-01 |
@sjd2021 Probably 1 of your projects is referencing old version of Microsoft.CodeCoverage package. Please try upgrading both to latest. |
Hi @simonachmueller , now it seems possible (how I already pointed out here) |
Description
Add support for code coverage through
dotnet test
on Windows OS machine.dotnet test --collect:"Code Coverage"
The text was updated successfully, but these errors were encountered: