Question

I have some Web API and some proxy class based on HttpClient for this Web API.

Now I want to have some unit tests that will operate with the proxy class that will interact with Web API.

I have all these three projects organized as one solution in VS 2013. But the problem here that in order to run the tests I have to have Web API project running as well. But if I run Web API I can't run tests. If I run tests, Web API is not started because VS put it down every time when I stop debugging Web API.

Is it possible somehow to keep running Web API while I run unit tests? In a previous VS versions it was possible to keep running web application in IIS express even if you are not debugging it. How to do the same in VS 2013?

For now I've found only one possible solution - open two Visual Studios and run Web API in one of them and tests in another one. But its not convenient and I'm sure there is more elegant solution for the situation...

Was it helpful?

Solution

Use in-memory hosting of your API. That way it will all run in the same process, it will generate zero network traffic and your tests will run much faster.

Other than that, I would always run the Web API in a different VS instance. It is a much more elegant solution in my opinion.

OTHER TIPS

You Can Also start your project with out debugging this will launch an instance of the application but will still allow you to run unit tests.

Start with out Debugging: 1. Right click on the project you want to run. a. Select set as startup project. 2. Go go the debug menu and click start without debugging.

This will launch an instance of your API and will allow you to test your end points.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top