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 !!!