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"
}
}
}
}
To show me the code coverage.
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'.
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
I tried to debug it in the dotnet-test-xunit, and added a Debugger.Launch();
in it's Main.
It's called when I discover/run the tests in any way, but not when I run "Analyze Code Coverage".
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"
}
}
}
}
I'm also seeing this but I'm just trying to get vanilla tests to run..
------ Discover test started ------
Discovering tests in 'C:\Code\Foundatio\test\Foundatio.AWS.Tests\project.json' ["C:\Program Files\dotnet\dotnet.exe" test "C:\Code\Foundatio\test\Foundatio.AWS.Tests\project.json" --output "C:\Code\Foundatio\test\Foundatio.AWS.Tests\bin\Debug\net46\win7-x64" --port 26870 --parentProcessId 16516 --no-build]
'test-xunit' returned '-532462766'.
Discovering tests in 'C:\Code\Foundatio\test\Foundatio.Azure.Tests\project.json' ["C:\Program Files\dotnet\dotnet.exe" test "C:\Code\Foundatio\test\Foundatio.Azure.Tests\project.json" --output "C:\Code\Foundatio\test\Foundatio.Azure.Tests\bin\Debug\net46\win7-x64" --port 26875 --parentProcessId 16516 --no-build]
'test-xunit' returned '-532462766'.
Discovering tests in 'C:\Code\Foundatio\test\Foundatio.Redis.Tests\project.json' ["C:\Program Files\dotnet\dotnet.exe" test "C:\Code\Foundatio\test\Foundatio.Redis.Tests\project.json" --output "C:\Code\Foundatio\test\Foundatio.Redis.Tests\bin\Debug\net46\win7-x64" --port 26880 --parentProcessId 16516 --no-build]
'test-xunit' returned '-532462766'.
Discovering tests in 'C:\Code\Foundatio\test\Foundatio.Tests\project.json' ["C:\Program Files\dotnet\dotnet.exe" test "C:\Code\Foundatio\test\Foundatio.Tests\project.json" --output "C:\Code\Foundatio\test\Foundatio.Tests\bin\Debug\netcoreapp1.0" --port 26887 --parentProcessId 16516 --no-build]
[xUnit.net 00:00:00.0597555] Skipping: Foundatio.Tests (no reference to xUnit.net)
I don't have any code coverage..
I think it's failing because Foundatio.Redis.Tests references Foundatio.Tests
I created a new issue: https://github.com/dotnet/cli/issues/3759
I ran into this issue as well, but your provided fix doesn't seem to be working.
Not sure what I am doing wrong here, or if there is some regression since RC2.
Error NU1002 The dependency Microsoft.CodeCoverage 1.0.0 does not support framework
{
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies": {
"NETStandard.Library": "1.6.0",
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Microsoft.CodeCoverage": "1.0.1"
}
}
}
}
.NET Command Line Tools (1.0.0-preview2-003121)
Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: 1e9d529bc5
@jderus me too. How fix this bug?
@jderus me 3
@jderus Try adding "imports" section with one of package's supported TFM, e.g:
"imports": ["dnxcore50"]
Most helpful comment
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: