Original article: Visual Studio unit test 2-sequential unit test
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.
Now, all the ordered unit tests have been completed. Please follow my next blog post: Visual Studio unit test 3 --- stress testing
If you need to reprint, please indicate the original from the wolf's blog: http://blog.csdn.net/tjvictor
Visual Studio unit test 2-sequential unit test