views:

38

answers:

1

I program simple control library that checks user input from text and format the input.I want to make a unit test.How can I do that ?

+4  A: 

I would take a look at this SO question. There are some good responses there. Marek Grzenkowicz's CodeProject article has some information on unit testing a TextBox he developed.


Edit: Testing the UI can be a challenge and I generally try to pull as much out of the UI as I can and put it into a more testable class. Obviously, you want your unit tests to be run without any need for user interaction, so if your class method takes in the input string and formats it, you can write a test (using NUnit, MS Test, etc) to provide the input and test the actual output against the expected results.

I'd point you at NUnit and see if that does what you need. It is easy enough, also, to create New tests in Visual Studio under the Test->New Test... menu item. I know this is available in the VS 2008 Professional and assume it is available in other versions too.

Also, I'd take a look at this SO question about NUnit examples. There are some links to some examples there too.

itsmatt
Thank you for great explanation.
Bug
@Bug -That's an awesome answer. You need to mark this as the accepted answer tho. Cheers
Berryl