I'm doing my first big project and I don't have a lot of experience in a professional programming environment. While researching anything programming-related I often see references to Unit Testing, but I am still unclear as to how to set those up or even if it would be beneficial to me.

Can someone explain unit testing to me, and how to set it up in a Visual Studio 2010 solution that has multiple projects? Is it something that occurs within your project's solution, or is it a separate solution? And is it something you'd recommend for a small development team or is it just a waste of time to setup?

Right now I just run the entire program to test whatever I am currently working on, but occasionally I have run into problems that are not easy to debug and it would be useful to run subsets of the code elsewhere... Sometimes I do setup another project with some of the libraries referenced to test a small part of the program, but I feel more time is wasted setting that up then just running the entire program because of all the dependencies involved

closed as off-topic by user40980, GlenH7, Bart van Ingen Schenau Nov 17 '15 at 19:07

  • This question does not appear to be about software engineering within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    I'm voting to close this question as off-topic because it is a question specific to the use of a tool and configuration of the tool. – user40980 Nov 17 '15 at 15:08

Setting up unit testing in VS2010 is fairly easy.

Add a new project to your solution and select the Test Project template from the New Project dialog box. Usually you create one test project for project you want to test in your solution (ie. BusinessLogic.proj would have a mate called BusinessLogicTest.proj, just as an example).

Once you have the project added, the easiest way (not necessarily the best way to do this, especially if you're goal is to get to TDD) to get started is to right-click on a function that you want to test and select "Create Unit Tests". Make sure the Output Project is the Test Project you just created and click OK. VS creates a new Test Class for you with a Test Method stubbed out.

That's the basics of getting setup. There's a lot to learn to test effectively, but you're at least on the right path by wanting to unit test. I'll see if I can find a demo or article to get you a bit further.


Found one. This article is by Deborah Kurata (an MS MVP) and she has both C# and VB code samples. She is using VS2008, but the basics are the same for VS2010

  • 1
    Thank you, that was exactly the sort of thing I wanted to get me started! Way easier than I thought it would be, and much faster then how I normally do it :) – Rachel Sep 15 '10 at 14:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.