aspnet/Testing

What is TestServer, really?

gzak opened this issue · 2 comments

gzak commented

It's pretty lightweight to host an instance of a server with Kestrel for the scope of an integration test suite, so I was curious what TestServer really adds or brings to the table. And what are the technical internal details of TestServer, in the sense of what are the big differences between it and a "real" host like Kestrel?

Yet another question is why not just have the integration tests point to real endpoints, and only use an HttpClient within the tests (no dedicated test server).

This isn't really an issue, more of a discussion.

gzak commented

Here's something that would be pretty useful if TestServer provided it: code coverage reports.

Eilon commented

I assume this is in reference to https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNetCore.TestHost/TestServer.cs?

TestServer is different from Kestrel in many ways:

  1. First of all, it's just for testing :trollface: But seriously, it has zero features, is not meant to be high-performance, lifetime management, or anything like that.
  2. But more importantly, it doesn't listen on any port: it's a 100% in-memory server that accepts only direct requests.

As for features such as code coverage, that's usually not part of a server, but rather an external code coverage tool that collects data for particular assemblies under test.