Search code examples
c#wcfunit-testingvisual-studio-2013

Run other project when running unit tests in Visual Studio 2013


I have a setup with some VS projects which depend on each other. Simplified, imagine these projects:

  1. API Project (ASP.NET WebAPI 2)
  2. DummyBackendServer (WinForms with a WCF Service)
  3. API.Test Project (Unit Test Project which should Test API-Project's Controllers)

Usually, there would be (for example) an android client, which connects to the API-Server (1) and requests some information. The API-Server would then connect to the DummyBackendServer (2) to request these information, generate an appropriate format and send an answer to the android client.

Now I need to create some unit tests for the API-Server. My problem is, that I don't find a way to tell VS to start the DummyBackendServer (2), when it runs the unit tests. When I first start the DummyServer I can't run the tests, because the menu option is grayed out.

So, is there any way to tell VS to start another project the tests depend on?


Solution

  • Divide and conquer!

    If the test (some will say that those are not unit test, but that is not part of this question) requires some services to be up - make that happen! Have them deployed to some dev or staging environment, then you only need to configure the connection from the API test assembly.

    I would split the solution in two and call them integration tests. If you want them to bee unit test you have what you need from the post above.