Test the. Net program with nunit-common test attribute 3 Category

Source: Internet
Author: User

I have been using nunit for testing our. Net program for a few days. Have you noticed that there is another unused nunit field on the left?

This is categories. Click to open this project:

Empty. Don't worry. Let's get to know this categories. We add [category ("Category A")] In testdivide ().

[Test] [category ("Category A")] // [expectedexception (typeof (dividebyzeroexception)] public void testdivide () {int result = Cal. divide (a, B); assert. areequal (5, result );}

 

Compile and check the categories. Is there a Category?

Click Add to add category A to selected categories.

Switch to the test tab again, select the entire test project, and click Run. Only testdivide () Run of Category A has passed.

 

In, the following check box means to exclude groups in selected categories. That is, if you select the check box, these groups will not run in nunit.

 

In the test, we can divide our test method into many category for separate testing or non-testing. This is more powerful than the previously mentioned ignore and explicit attributes.

 

We will continue to use practical practices to practice the knowledge we have learned !!!

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.