C # Unit Testing

What is unit testing (unit testing)?

It refers to the smallest testable software unit checking and validation. For the meaning of the unit test unit, in general, be determined according to the actual situation of its specific meaning, such as C language, refers to a function unit, Java classes in a cell refers to, the graphical software may refer to a window or a menu Wait. In general, the smallest unit measured is a predetermined function module human. Unit testing is the lowest level of testing activities in the software development process to be carried out, an independent software unit will be tested in the case of the rest of the program phase isolated.

step

1, create a unit test project

 

2、

The introduction of the item being tested (my test project is MyWPFProject)

 

3, my projects have a class called MyClass, which has a method is GetSum

 

4, the following test is a test method which is

Instantiate the class to be tested, which then calls the method, with Assert.AreEqual to determine whether to return the expected result, if the return is not 3, then here you will be prompted.

5, the verification unit tests whether the right way, in the test explorer view, the unit test item by right -> selected test run; may be right in the code - running tests or right - commissioning tests

6, see the code coverage

And then view the code coverage results

 

Guess you like

Origin www.cnblogs.com/cuigzh/p/12018519.html