如何在 Visual Studio 中对 Windows 10 应用进行单元测试? [英] How to unit test a Windows 10 app in Visual Studio?
问题描述
如何在 Visual Studio 2015 中对 Windows 10 应用进行单元测试?
How can I unit test a Windows 10 app in Visual Studio 2015?
我创建了一个空白应用程序通用 Windows 项目并向解决方案添加了一个新的单元测试项目,但是当我尝试在测试项目中添加对我的 UWP 应用程序的引用时,我收到一条错误消息无法添加引用项目项目名称"'.
I created a Blank App Universal Windows project and added a new Unit Test Project to the solution, but when I try to add a reference to my UWP app in the Test Project, I get an error saying 'Unable to add a reference to project "Project Name"'.
推荐答案
右键单击您的解决方案并选择 Add >新项目
.然后选择 Unit Test App (Windows Universal)
.确保您没有选择Unit Test Library
或Unit Test Project
.它必须是通用的.这应该会生成一个基类供您使用.
Right click on your solution and choose Add > New Project
. Then select Unit Test App (Windows Universal)
. Make sure that you don't select Unit Test Library
or Unit Test Project
. It must be the Universal one. This should generate a base class for you to work with.
然后您可能想要添加对主项目的引用.为此,右键单击您的测试项目并选择 Add >参考
,然后选择你的主项目.您现在应该能够从主项目创建类进行测试.
You'll probably then want to add a reference to your main project. To do this, right click on your test project and select Add > Reference
and then choose your main project. You should now be able to create classes from your main project to test.
这篇关于如何在 Visual Studio 中对 Windows 10 应用进行单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!