I am doing .NET core 2 work on a mac (and my build server is linux) and I'm looking for a way to generate code coverage for integration tests that use and embedded web server as the system under test. I can get coverage for my unit tests but not for my Integration style tests.
Im relatively new to .NET but I've familiarized myself with the testing ecosystem as best I can in the last few months.
Currently I'm testing a .NET core 2.2 API using xUnit as my test framework and using the Microsoft supplied Microsoft.AspNetCore.Mvc.Testing
package to generate the test server inside of my tests. Very similar to this reference
Then I have tests that use the TestClient to make HTTP requests to the embedded SUT and assert on the response.
I can generate code coverage for my Unit tests using AltCover and this works great! But when i run altcover over my integration test project, I get no coverage results.
I Have DebugType set to Full on the projects, and debug symbol files appear to be generated for all of the relevant code.
The xUnit test fixture for my SUT
namespace Redbox.Product.Tests.Integration.Util
{
public class TestConfigurationFixture
{
private readonly WebApplicationFactory<TestStartup> _webApplicationFactory;
public TestConfigurationFixture()
{
_webApplicationFactory = new CustomWebApplicationFactory<TestStartup>();
}
public HttpClient CreateClient()
{
return _webApplicationFactory.CreateClient();
}
}
}
A Test that executes against this test fixture
[Fact]
public async Task ResultsForQueryFound_RespondsOK()
{
var response = await _client.PostAsJsonAsync("/products/search",
new ProductSearchRequest
{
Query = "foo"
})
.ToHelper();
response.Should().HaveStatus(OK);
}
I can generate code coverage for my Unit tests using AltCover and this works great! But when i run altcover over my integration test project, I get no coverage results.
Has anyone been able to generate coverage for this type of test?