I have a solution that is client server. The client and the server are projects in the same solution.
I want to unit test the client, which, obviously, requires that the server be running. Is there some way to specify in the unit test project that the server project should be started before running a particular unit test? I suppose I could explicitly start the program, but I’d rather have the testing infrastructure do that for me.
I imagine this is a pretty common requirement. How do people typically approach it? (VS2010, C# if it matters.)
The best approach to this is to actually write REAL unit tests. What you are running now is considered an integration test.
A true unit test is system indepenent and repeatable, and should make one assertion of functionality for one component. By system independent I mean that it should not depend on a running instance of a server, web services, database, file resource, etc…
You can acheive this unit test by ‘Mocking’ the server component to return predictable controlled output for the purposes of testing your client code. There are a variety of mocking frameworks available for you to sample.