Visual Studio unit test 2-sequential unit test

Source: Internet
Author: User

This article is the previous blog post: One of Visual Studio unit tests-the subsequent chapter of common unit tests. If you are not familiar with the unit test of Visual Studio, refer to the previous article. Http://blog.csdn.net/tjvictor/archive/2011/02/09/6175362.aspx

This article will automatically skip the concepts and methods mentioned in the previous article. The example in this article can be downloaded using the following link:

 

Http://download.csdn.net/source/3014236

In the previous test, we performed the test one by one. Of course, we can select multiple test methods at a time. However, the Test Run sequence is determined by the default list order in the test List editor window. In actual scenarios, we need to perform sequential unit tests, such as the electronic archive process: create an electronic archive-> preliminary review-> confirm-> archive. So each of the above four steps may be an independent unit test function. What if we want them to be executed in a certain order? This is what we will discuss in this article.

In the previous article, we have created four methods: addtest (), dividetest (), minustest (), and multiplytest (), which are assumed to be the four steps of the above electronic archiving.

Right-click utproject-> Add-> new test-> ordered test, for example:

 

 

Note: basic unit test is a unit test file template that only includes [testmethod]. unit test includes [classinitialize ()], [classcleanup ()] mentioned above. [testinitialize ()], [testcleanup ()], and [testmethod] unit test file templates. I will introduce other templates one by one in subsequent chapters.

 

After selecting orderedtest, we will find an additional orderedtest1.orderedtest file (for convenience, I used the default vs naming rule. In actual applications, you should change the file name to a unified real name ). After opening, a sequence selection window appears, such:

 

 

The running mode is the same as running a common unit test method. In the test List editor window, for example:

 

 

Finally, we will introduce how to use test List editor to classify unit test cases.

When there are multiple test cases, it is very difficult to find a test method, and you need to classify them.

Open test List editor-> right-click lists of test-> Add test list: as shown in Figure

 

 

Drag the test file to the new category one by one, so that you can classify and search in multiple testing methods. When this classification is selected, all the test methods in the classification are also selected, and the comparison chart after the classification is displayed.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.