测试模块 [英] Test Modules

查看:50
本文介绍了测试模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果可能的话,如何在一个解决方案中运行测试模块和测试模块,而不是主程序?在我的情况下,我有一个解决方案,其中Main是一个WPF表单,但我也有一个模块,我想测试各种程序 - 我b $ b仍然相对较新的编程和在孤立的模块中编写小程序帮助我更熟悉编码。我知道我可以在Form的代码隐藏或不同的解决方案中的子程序中编写这些测试程序,共计
但是我想看看其他人如何测试他们的代码。


谢谢,


FreyGuy

解决方案

Hi FreyGuy,


欢迎来到MSDN论坛。


>>

如果可能,如何运行测试模块和解决方案中只有测试模块不是主程序?


如果我的理解是正确的,你想为WPF表单应用程序进行单元测试,对吗?


< span style ="color:#666666;行高:107%; font-family:'Segoe UI',sans-serif; font-size:10pt">请添加新的
单元测试项目。右键单击解决方案资源管理器中的解决方案,
添加 - > ;新项目......


将WPF表单应用程序添加到单元测试项目引用中。右键单击单元测试项目的
引用,选择添加引用... ,在
参考管理器对话框中,选择
项目
节点下的WPF表单应用程序。


完成上述步骤后,您可以对WPF表单应用程序进行单元测试。然后,您可以在
测试资源管理器中运行所选的测试方法。


欲了解更多信息,请参考:

https://docs.microsoft.com/en-us/visualstudio/test/getting-started-with-unit-testing


注意:单元测试框架只是测试代码逻辑,不适合测试WPF应用程序的UI。


如果我误解了你的问题,请告诉我。


问候,


Judyzh


If possible how does one run a Test Module and only the Test Module in a solution for which it is not the Main procedure? In my case I have a solution for which the Main is a WPF form but I also have a module in which I would like to test various procedures—I'm still relatively new to programming and writing small procedures in isolated modules has helped me become more familiar with coding. I am aware that I can write these test procedures in sub procedures in the Form's code-behind or in a different solution altogether but I would like to see how others test their code.

Thanks,

FreyGuy

解决方案

Hi FreyGuy,

Welcome to the MSDN forum.

>> If possible how does one run a Test Module and only the Test Module in a solution for which it is not the Main procedure?

If my understanding is correctly, you want to do unit test for WPF form application, right?

Please add a new Unit Test Project. Right click solution in Solution Explorer, Add ->New Project….

Add WPF form application to the unit test project references. Right click the References of the Unit Test Project, choose Add Reference…, in Reference Manager dialog box, select WPF form application under Projects node.

After above steps, you could unit test the WPF form application. Then, you could run the selected test methods in Test Explorer.

For more information, please reference: https://docs.microsoft.com/en-us/visualstudio/test/getting-started-with-unit-testing

Note: Unit Test Framework just test code logic, is not suitable for testing UI of WPF applications.

Please let me know if I have misunderstood your issue.

Regards,

Judyzh


这篇关于测试模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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