In the process of a programmer doing a project, each time a function is completed, the first one needs to test the completed function, and the project I am working on now is VS2012, so let's talk about how to create a unit test in VS2012.
How do I create a unit test?
In VS2012, the right-click class name is not the option to create unit tests by default, and you need to add the settings-- 工具 自定义 :
Then select 命令 - 上下文菜单 编辑器上下文菜单|代码窗口 -and then locate and 创建单元测试 move it up and down to the location shown:
Then reopen vs, right-click on the class name to see the gray, in the 创建单元测试 disabled state:
Add a unit test project to the solution:
And in the unit test project that you just created---and 右键 添加 单元测试 :
First 保存 , then to the class that you just tested, right-click, select 创建单元测试 创建单元测试 , select the class and method to test, and output to the Unit test class you just created:
Then the basic setup is done, open the test Explorer in VS and Right-run the selected test and you can test it:
Give it a try! ~
Novice Test----Unit Test (unit tests)