question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Analyze Code Coverage in VS2015 not working

See original GitHub issue

Steps to reproduce

When I create a test solution with a ClassLibrary project in the src folder, and a Test project in the test folder with the following project.json files, all tests/testrunners work just fine, but analyzing the code coverage in VS is not working.

ClassLibrary’s project.json:

{
  "version": "1.0.0-*",

  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0-rc2-3002702"
        }
      }
    },
    "net452": { }
  }
}

Test’s project.json:

{
  "version": "1.0.0-*",
  "testRunner": "xunit",

  "dependencies": {
    "xunit": "2.2.0-beta1-build3239",
    "dotnet-test-xunit": "1.0.0-rc2-build10015",
    "Test": "1.0.0-*"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0-rc2-3002702"
        }
      },
      "imports": [
        "dnxcore50",
        "portable-net45+win8"
      ]
    },
    "net452": {
      "dependencies": {
        "Microsoft.NETCore.Platforms": "1.0.1-rc2-24027"
      }
    }
  }
}

Expected behavior

To show me the code coverage.

Actual behavior

dotnet.exe has stopped working.

And the Tests output shows me: ------ Run test started ------ Discovering tests in ‘…\Test\Test\project.json’ [“C:\Program Files\dotnet\dotnet.exe” test “…\Test\Test\project.json” --output “…\Test\Test\bin\Debug\netcoreapp1.0” --port 8005 --parentProcessId 7116 --no-build] ‘test-xunit’ returned ‘-532462766’.

Environment data

dotnet --info output: .NET Command Line Tools (1.0.0-preview1-002702)

Product Information: Version: 1.0.0-preview1-002702 Commit Sha: 6cde21225e

Runtime Environment: OS Name: Windows OS Version: 6.1.7601 OS Platform: Windows RID: win7-x64

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9

github_iconTop GitHub Comments

3reactions
Ausmcommented, Jun 3, 2016

Ok, my fault. See dotnet/sdk#5440

Simply add "Microsoft.CodeCoverage": "1.0.1" to the netcoreapp1.0 dependencies, and everything works fine.

The Test’s project.json looks now like:

{
  "version": "1.0.0-*",
  "testRunner": "xunit",

  "dependencies": {
    "xunit": "2.2.0-beta1-build3239",
    "dotnet-test-xunit": "1.0.0-rc2-build10025",
    "Test": "1.0.0-*"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0-rc2-3002702"
        },
        "Microsoft.CodeCoverage": "1.0.1"
      },
      "imports": [
        "dnxcore50",
        "portable-net45+win8"
      ]
    },
    "net452": {
      "dependencies": {
        "Microsoft.NETCore.Platforms": "1.0.1-rc2-24027"
      }
    }
  }
}
2reactions
andriysavincommented, Sep 12, 2016

@jderus Try adding “imports” section with one of package’s supported TFM, e.g:

"imports": ["dnxcore50"]

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio 2015 "Analyze Code Coverage for All Tests ...
This is easily remedied on a development machine by selecting all the tests in Test Explorer, right clicking, and then selecting "Analyze Code...
Read more >
Troubleshoot code coverage - Visual Studio
In Test Explorer, select Run All to verify that the tests run successfully. Fix any failures before using Analyze Code Coverage.
Read more >
Code coverage testing - Visual Studio (Windows)
Analyze code coverage from the command line​​ To run tests from the command line, use vstest. console.exe utility.
Read more >
code coverage not working in 15.3
When I run a test from the Test Explorer using "Analyze Code Coverage for Selected Tests" in VS2017 (15.3), all I ever get...
Read more >
Code Coverage Not working for Visual Studio Test results
We're using Visual Studio 2015 Professional on our build server to create the code coverage report. Any ideas why SonarCloud is not interpreting ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found