Introduction to Unit Testing Framework of VS 2008 - Part III
This article gives an introduction to creation of Test List and configuration of Test Project of VS 2008 Testing Framework.
In previous article, we discussed about Ordered Tests and its configuration. Now, we will have a look into some other features of this framework. I will start with configuration of Test Project followed by creation of Test List. I am using same old application used in previous article. First, open the sample code. We can see LocalTestRun.testrunconfig file in Solution Explorer under Solution Items. This file is used to configure our test project. Double-click on that file, it will open a dialog box as shown below:
In General tab, we can make changes to naming convention of test runs. Change Test run naming scheme as per your choice, we can give project name along with date and time. Select user-defined scheme and change prefix text to TargetApplication and make sure Append date-time stamp checked (by this only we can differentiate test cases run in different times). Now click on Apply and run all test cases (go to Test --> Run --> All Tests in Solution). Test Result window will show results of test cases as shown below with an option to sort test cases based on time of execution:
Now, go back to configuration file and select Test timeouts. Here, we can specify timeouts for individual as well as whole test cases execution. To see how it works, just set timeout as one minute for individual test cases. So, if any test case takes more than one minute to execute, it will show result as Timeout and continues with execution of next test case. By using this option, we can make sure that all test cases are executed, if any deadlock occurs in execution of test cases.
Next go to Deployment tab, here we can enable/disable deployment and add additional files/folders to be deployed along with target assemblies.
Deployment should be enabled in order to use following features:
- Code Coverage.
- Remote execution of Test cases.
Next go to Setup and Cleanup Scripts tab, here we can specify the scripts that should be run before and after execution of test cases.
Now, we will look into creation of Test List. Test Lists are used to group related test cases. Open TargetApplication2.vsmdi file present in solution explorer, right click on List Tests and select New Test List. Give a name to it and click Ok. Drag test cases onto Sample List which are to be grouped as shown below:
In coming article, I will discuss other important features of this Framework. I am attaching code for reference. I hope this code will be useful for all.