Create a unit test project

https://msdn.microsoft.com/en-us/library/hh598957.aspx

Unit tests often mirror the structure of the code under test.

For example, a unit test project would be created for each code project in the product.

The test project can be in the same solution as the production code, or it can be in a separate solution.

You can have multiple unit test projects in a solution.

 

To create a unit test project:

  1. On the File menu, choose New and then choose Project (Keyboard Ctrl + Shift + N).

  2. In the New Project dialog box, expand the Installed node, choose the language that you want to use for your test project, and then chooseTest.

  3. To use one of the Microsoft unit test frameworks, choose Unit Test Project from the list of project templates. Otherwise, choose the project template of the unit test framework that you want to use. To test the Accounts project of our example, you would name the project AccountsTests.

  4. In your unit test project, add a reference to the code under test. Here’s how to create the reference to a code project in the same solution:

     

    1. Select the project in Solution Explorer.

    2. On the Project menu, choose Add Reference....

    3. In the Reference Manager dialog box, open the Solution node and choose Projects. Check the code project name and close the dialog box.

  5. If the code that you want to test is in another location, see Managing references in a project for information about adding references.

新建一个单元测试项目,并把待测试的项目作为引用添加 
 

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(308)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2015-01-12 C#中将一个引用赋值null的作用
2015-01-12 关于C#中的垃圾回收
2015-01-12 触发事件,检查是否注册过事件的方法
点击右上角即可分享
微信分享提示