Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio unit tests and client server programs

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

like image 875
Fred Thomas Avatar asked Mar 20 '26 05:03

Fred Thomas


1 Answers

Pedant point: if the server is needed, it isn't a unit-test - it is an integration test. That doesn't change the very real need to do it, though :)

When I need this, I design the server as something I can spin up from a few classes anywhere (the simpler, the better); then, you can start the server in a few classes from the test suite (and shut down). The server "application" is then just a thin shell around the same set of classes.

It depends on what you are doing, of course.

like image 131
Marc Gravell Avatar answered Mar 21 '26 17:03

Marc Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!