Novice Test----Unit Test (unit tests)

Source: Internet
Author: User

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)

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.