4

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?

Darrel Miller
  • 139,164
  • 32
  • 194
  • 243
Rune
  • 381
  • 1
  • 3
  • 14

1 Answers1

4

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.

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132
  • Is it possible to use RestSharp client with HttpSelfhostServer? – Rune Jan 28 '14 at 16:42
  • Yeah, you will be speaking HTTP so any HTTP client will do. Self Hosting is like creating an in memory web server. – Davin Tryon Jan 28 '14 at 16:50
  • http://stackoverflow.com/questions/14698130/unit-testing-web-api-using-httpserver-or-httpselfhostserver#14698335 suggests to use HttpServer over HttpSelfHostServer – tymtam May 04 '16 at 23:50