Reputation: 4482
How can I get code coverage for a .net core web application which targets net452 in VS2017 (or VS2015)?
I have my tests set up with xUnit but I get no coverage results for the .net core web application. The tests run fine, but I get no coverage!
Is this a known issue?
It doesn't work with MS's test library either.
Quick to repro:
WebApplication1
TestClass.cs
as belowUnitTestProject1
WebApplication1
in UnitTestProject1
UnitTest1.cs
as belowTest -> Analyze Code Coverage -> All Tests
Test -> Windows -> Code Coverage Results
unittestproject1.dll
TestClass.cs
namespace WebApplication1
{
public class TestClass
{
public bool TestMethod(bool test)
{
if (test) { return true; }
return false;
}
}
}
UnitTest1.cs
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTestProject3
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var testClass = new WebApplication1.TestClass();
var val = testClass.TestMethod(true);
Assert.IsTrue(val);
}
}
}
Upvotes: 1
Views: 214
Reputation: 4482
Code coverage is not implemented for netcore projects yet. This support requires datacollectors infrastructure (https://github.com/Microsoft/vstest/issues/309) . It will come post RTW. We recommend that you follow the above issue for updates and fix notifications.
Upvotes: 0