2

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...

1
  • I am having the same issue or question. My question is how to run the test and web api project under one solution during testing. What I have to do now is run two instances of VS one for WebAPI and one for the UnitTest Commented Oct 23, 2015 at 0:43

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.