在visual studio中自定义顺序执行测试用例

来源:互联网 发布:中国互联网主干网络 编辑:程序博客网 时间:2024/06/09 16:04

1. Select the test project from Solution Explorer, right-click and selectAdd Ordered Test.


2. Select the cases and put them in the order that you want. Also check “Continue afterfailure”, then Save the ordered test by choosing theFile | Save option.


3. Select the orderedtest in Test List Editor and schedule to run.

4. Check the results inVS or website.



Note:

The Select test list to view dropdown has the option to choose the display of tests in the available Test Lists. Thisdropdown has the defaultAll Loaded Tests, which displays all available tests under the project. The other options in the dropdown are Lists of Tests andTests Not in a List. The List of Tests will display the test lists created using theTest List Editor. It is easier to include the number of tests grouped together and order them. The next option,Tests Not in a List, displays the available tests, which are not part of any Test Lists.

The preceding screenshot shows that most of theproperties are the same as the properties of the other test types. We canassociate this test with the TFS work items, iterations, and area.

Executing an ordered test

An ordered test can be run like any other test. Open the TestView window or theTest List Editor and select the ordered test fromthe list, then right-click and choose theRun Selection option from TestView or Run Checked Tests from theTest List Editor. Once theoption is selected, we can see the tests running one after the other in thesame order in which they are placed in the ordered test. After the execution ofthe ordered tests, theTest Results window will show the status of theordered test. If any of the tests in the list fails, then the ordered teststatus will beFailed. The summary of statuses of all the tests in theordered test is shown in the following screenshot in the toolbar. The sampleordered test application had four tests in the ordered tests, but two of themfailed and one had an error.

The Available tests list displays all the tests from the test project based on the option chosen in the dropdown.

Selected tests contains the tests that are selected from the available tests list to be placed in order.

The two right and left arrows are used for selecting and unselecting the tests from the Available tests list to theSelected Tests list. We can also select multiple tests by pressing theCtrl keyand selecting the tests.

The up-down arrows on the right of the selected tests list are used for moving up or down the tests and setting the order for the testing in theSelected tests list.

The last option, the Continue after failure checkbox at the bottom of the window, is to override the default behavior of the ordered tests, aborting the execution after the failure of any test. If the optionContinue after failure is unchecked, and if any test in the order fails, then all remaining tests will get aborted. In case the tests are not dependent, we can check this option and override the default behavior to allow the application to continue running the remaining tests in order.

Properties of an ordered test

Ordered tests have properties similar to the other test types, in addition to some specific properties. To view the properties, select the ordered test in theTest View or Test List Editor window,right-click and select theProperties option. The Properties dialog box displays the available properties for the ordered test.

An ordered test can be run like any other test. Open theTestView window or the Test List Editor and select the ordered test fromthe list, then right-click and choose theRun Selection option from TestView or Run Checked Tests from theTest List Editor. Once theoption is selected, we can see the tests running one after the other in thesame order in which they are placed in the ordered test. After the execution ofthe ordered tests, theTest Results window will show the status of theordered test. If any of the tests in the list fails, then the ordered teststatus will beFailed. The summary of statuses of all the tests in theordered test is shown in the following screenshot in the toolbar. The sampleordered test application had four tests in the ordered tests, but two of themfailed and one had an error.


<p class="MsoNormal" style=""margin-top:4.8pt;margin-right:0in;margin-bottom:9.6pt;">Clicking theTest run failed hyperlink in thestatus bar shows a detailed view of the test run summary:

<p class="MsoNormal" style=""margin-top:4.8pt;margin-right:0in;margin-bottom:9.6pt;">TheTest Results window also provides detailedinformation about the tests run so far. To get these details, choose the testfrom theTest Results window and then right-click and choose the option,View Test Results Details, which opens the details window and displaysthe common results information such asTest Name, Result, Durationof the test run,Start Time, End Time, and so on.

The details window also displays the status of each andevery test run within the ordered test. In addition it displays the durationfor each test run, name, owner, and type of test in the list. Even though thesecond test in the list fails, the other tests continue to execute as if the Continueafter failure option was checked.

原创粉丝点击