I have set of xUnit tests that have to make requests to running Kestrel servers. These tests are placed in .Net Core App project. There is a code that runs the only once before tests in the beginning and has to run Kestrel servers on the specific ports.
So I need that my servers were runned and tests were passed. For my server host I have the next code:
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel()
.UseUrls("http://*:8000")
.UseContentRoot(Directory.GetCurrentDirectory())
.Build()
- If I run server via
IWebHost.Runthen main thread is blocked and tests are not performed. But server starts and is able to get requests - If I run server via
IWebHost.Runin the separate thread then nothing happens (there is no server port in list of ports ofnetstat -a) - I got the same effect If I use
IWebHost.Startin separate thread - And if I use just
IWebHost.Startthen main thread is not blocked, there is a port in the list of ports but server doesn't respond to request from browser
Is there a way to run Kestrel server from .Net Core App test project and perform tests?
Aucun commentaire:
Enregistrer un commentaire