您的位置:首页 > 其它

Unit Test in Visual Studio

2015-04-27 10:34 597 查看
一直develop code, 突然有人要求写unit test.... 傻眼了。

- Visual Studio 2013 里面已经有现成的unit test流程。

1)新建unit test project (C#-> Unit Test Project)

2)右键项目,add reference, 在这里导入需要被测试的project(可以使用browser定位到相关的project)

3)写unit test的code.

4) On
the Build menu,
choose Build Solution.

5) choose Test on
the menu, then choose Windows,
and then choose Test Explorer.

6) Choose Run
All

===========================================================================================

- unit test is to verify the behavior of the code in response tostandard, boundary, and incorrect cases
of input data
, and that verify anyexplicit or implicit assumptions made by the code

The [TestClass] attribute is required in the Microsoft unit testing framework for managed code for any class that contains unit test methods that you want to run in
Test Explorer.


Test method requirements

A test method must meet the following requirements:

The method must be decorated with the [TestMethod] attribute.

The method must return void.

The method cannot have parameters.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: