Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help me get started with unit testing in Visual Studio 2008

After spending some hours reading about Unit Testing and test driven development here on StackOverflow and on other sites posts pointed me to, I know two things:

  1. I want to use it
  2. I don't know where to start

There are lots of good posts here about details, best practices etc, but what I am looking for is a beginners tutorial/introduction - maybe even a book.

Where do I start? Assume I know nothing. :)

like image 810
Kjensen Avatar asked Apr 03 '09 19:04

Kjensen


4 Answers

Get the book Pragmatic Unit Testing in C# with NUnit or Test-Driven Development with Microsoft.NET and work through one of them. The principles will be applicable to many different testing frameworks although the specific idioms may be different.

like image 82
tvanfosson Avatar answered Nov 09 '22 15:11

tvanfosson


Watch unit testing related screencasts and videos at http://www.asp.net/learn/

And also check here (MSDN Webcasts related to Unit Testing):

http://www.google.com/search?q=unit+testing+site%3Amsevents.microsoft.com

like image 39
Konstantin Tarkus Avatar answered Nov 09 '22 17:11

Konstantin Tarkus


Write a simple calculator class with a few methods for operations and a property for the indicator. Create unit tests as you write the class.

Then read Working Effectively With Legacy Code -- it will show you how to add unit-testing to old nasty projects.

like image 2
Stop Putin Stop War Avatar answered Nov 09 '22 17:11

Stop Putin Stop War


For me I got started by writing unit tests for some of our low-level string manipulation code. I created a new project to be the tests and linked in the string library. Then, i went thru each method and wrote unit tests for them - boundary conditions, expected outputs for known inputs, etc. At first it seemed like a mindless excersize but then.........

I found a BUG!!

I'm sold.

So now I'm adding to the testing project as i move higher up the foodchain in our libraries.

like image 2
n8wrl Avatar answered Nov 09 '22 17:11

n8wrl