Wednesday, August 12, 2009

Visual Studio Unit test in fly

Unit testing:

Visual Studio 2008 automatically generates test script for your project.

If you have any project which is free of errors and build successfully and you want to write a unit test for that,you can do that easily in Visual studio 2008.
  1. Add a New test project from the Solution (Right click on Solution->New Project)
  2. Select Test project from Templates
  3. or Right Click on the function which you want to write a test script->Select Create Unit tests.. It will display the Classes and below that all the functions associated to it.. Just select the functions you want to test and click Ok.
  4. It will create a new File in the Test project with code for that functions.
  5. Now Initialize an appropriate value for the expected and actual results.
  6. Build the project and you can Debug only this particular function in the solution by placing the cursor on the function and click on Debug Tests in Current Contest button .






No comments:

Post a Comment