如何使用C#为我在Vs2012开发的项目创建单元测试用例? [英] How Do I Create Unit Test Cases Using C# For My Project Developed In Vs2012 ?

查看:136
本文介绍了如何使用C#为我在Vs2012开发的项目创建单元测试用例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为在VS2012中开发的项目创建单元测试用例?



我在VS2012中开发了一个Web应用程序。我想用c#为该项目编写单元测试用例。我怎样才能做到这一点?如何在visual studio中创建单元测试项目?



如何编写它?我怎么能执行它?我可以传递输入参数吗?

How do i create unit test case for my project developed in VS2012 ?

I have developed one web application in VS2012. I would like to write unit test cases using c# for that project. How can i do that? How can i create a unit testing project in visual studio?

How do i write it ? How can i execute it ? Where i can pass input parameters ?

推荐答案

参考:如何:创建单元测试项目 [ ^ ]


为您的项目创建单元测试用例,



1.打开包含要测试的方法的类。

2.右键单击其中一种方法,然后选择创建单元测试用例

3.将打开单元测试用例窗口,其中包含该页面中使用的所有方法名称。选择所有方法,然后单击OK。

4.给测试项目的名称,然后单击OK

5.将创建测试项目,您可以在那里看到您的方法。

6.设置参数值然后右键单击 - >运行测试

7.完成!你可以在结果窗口看到测试结果。



上面我已经解释得非常简单。如果您想了解更多信息,请参阅以下链接: https:// msdn .microsoft.com / zh-CN / library / ms182532%28v = vs.90%29.aspx [ ^ ]
To create unit test case for your project,

1. Open the class contains the methods which you want to test.
2. Right click on one of the method then select 'Create unit test case'
3. Unit test case window will open with all method names which are using in that page. Select all methods then click on OK.
4.Give name for the testing project then click on OK
5.Testing project will be created and you can see your methods there.
6.Set the parameter value there then right click -> Run Tests
7.Done ! you can see the test results in result window.

Above i have explained very simply. If you want to know more please refer below link: https://msdn.microsoft.com/en-us/library/ms182532%28v=vs.90%29.aspx[^]


这篇关于如何使用C#为我在Vs2012开发的项目创建单元测试用例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆