Skip to content
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

Lack of clear documentation for running tests with code coverage on MacOS #1053

Closed
wli3 opened this issue Sep 7, 2017 · 5 comments
Closed
Assignees

Comments

@wli3
Copy link

wli3 commented Sep 7, 2017

From @a-h on September 7, 2017 18:32

I'm confused as to how to run unit tests with code coverage on Linux and OSX for .NET Core 2.0 projects using the built-in tools.

Steps to reproduce

  • Create a test project:
    • dotnet new xunit
  • Run the test command line:
    • dotnet test
  • Try and find code coverage in the help (hmm, no instructions).
    • dotnet test --help | grep cover
  • Google for how to do Code Coverage, find you have to do something with dotnet vstest or something.
  • Find this page https://github.com/Microsoft/vstest-docs/blob/master/docs/analyze.md and read coverage
  • Add the specified Nuget package to my test project.
    • dotnet add package Microsoft.CodeCoverage
  • Run the test without coverage:
    • dotnet vstest ./bin/Debug/netcoreapp2.0/Updater.Tests.dll
      • Works fine!
  • Run it with code coverage:
    • dotnet vstest --collect:"Code Coverage" --framework:".NETCoreApp,Version=v2.0" ./bin/Debug/netcoreapp2.0/Updater.Tests.dll

Expected behavior

  • Run dotnet test --cover and code coverage files would be output, and a summary table of results printed to the console.
  • vscode would pick this up and highlight covered vs uncovered code.

Actual behavior

Error message shown:

screen shot 2017-09-07 at 19 26 03

Then I find this comment:

#579 (comment)

I thought .NET Core was cross platform? I'm confused...

Environment data

dotnet --info output:

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.0.0/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

Copied from original issue: dotnet/cli#7612

@IvanAlekseev
Copy link

As I understand right now coverage is only available on Windows. More info here #981

@harshjain2
Copy link
Contributor

harshjain2 commented Sep 10, 2017

@a-h, @wli3 Code coverage is currently supported for Windows OS. On Windows OS, you can get Code Coverage for dotnet core test projects using vstest.console.exe.

As pointed out by @IvanAlekseev, support for Code Coverage in dotnet test for Windows OS is not yet there.
We are tracking this feature here : #981

@harshjain2
Copy link
Contributor

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 @sudiptadmsft to consider the feedback for prioritisation.

@harshjain2 harshjain2 self-assigned this Sep 10, 2017
@a-h
Copy link

a-h commented Sep 10, 2017

Thanks for the clarification.

@codito
Copy link
Contributor

codito commented Sep 11, 2017

Closing this as dupe of #981

@codito codito closed this as completed Sep 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants