I have an integrationtest project and a web api project in the same solution. The integration tests use RestSharp to call the web api. When running the integration tests I want the web api project to launch first. Is that possible?
1 Answer
The best way I've found to do this is to Self Host the target WebApi project. Then, if you want to run these tests on a build server etc, you don't need a web server installed.
This is a pretty good walk-through on setting up a Self Host.
Essentially, you use the HttpSelfHostServer class with HttpSelfHostConfiguration to host the target project.
3 Comments
Rune
Is it possible to use RestSharp client with HttpSelfhostServer?
Davin Tryon
Yeah, you will be speaking HTTP so any HTTP client will do. Self Hosting is like creating an in memory web server.
tmaj
stackoverflow.com/questions/14698130/… suggests to use HttpServer over HttpSelfHostServer