简体   繁体   English

调试UWP单元测试

[英]Debug UWP Unit tests

I am using MSTest in a UWP Test App. 我在UWP测试应用程序中使用MSTest。 I am trying to debug unit tests. 我正在尝试调试单元测试。 I would like to set a breakpoint in them and step through them. 我想在其中设置一个断点并逐步执行。

I am using Visual Studio 2017 Community Edition. 我正在使用Visual Studio 2017社区版。

I watched an old Channel 9 video on unit tests, but it did not give me enough information. 我观看了第9频道关于单元测试的旧视频,但是它没有提供足够的信息。 I know UWP apps run in a sandbox and that's why you may have to attach to process. 我知道UWP应用程序在沙盒中运行,这就是为什么您可能必须附加到流程中的原因。 I have tried this but if the tests are not running it does not show up in the list. 我已经尝试过了,但是如果测试没有运行,它不会显示在列表中。 If the app is running then the test app does show up in the attach to process dialog, but is greyed out (unselectable). 如果该应用程序正在运行,则测试应用程序确实会显示在“附加到进程”对话框中,但显示为灰色(不可选择)。

Not sure if this is still the case that I have to attach to process. 不确定是否仍然需要附加到流程中。

Does anyone know the process for debugging UWP unit tests. 有谁知道调试UWP单元测试的过程。

The Process without attach to process: 没有附加到流程的流程:

I created a default UWP app and UWP test app, add a reference to the main project from the test project, add some code in the default unit test, set a break point and run all tests. 我创建了一个默认的UWP应用程序和UWP测试应用程序,在测试项目中添加了对主项目的引用,在默认的单元测试中添加了一些代码,设置了断点并运行了所有测试。 The build is set to Debug x86 on both. 两者的构建均设置为Debug x86。 And it does not stop at breakpoint. 并且它不会在断点处停止。

Tried devenc /resetuserprofile I think it was. 我试过了devenc / resetuserprofile。 something like that. 这样的事情。 Has no effect. 没有效果。

Anyone have any ideas? 有人有想法么?

thanks 谢谢

In Visual Studio 2017 Community debugging UWP Test Apps is just the same as debugging any other unit test: Open your Test Explorer (Test->Windows->Test Explorer), right click on the unit test you want to debug and click on Debug Selected Tests . 在Visual Studio 2017社区中,调试UWP测试应用程序与调试任何其他单元测试相同:打开测试资源管理器(Test-> Windows-> Test Explorer),右键单击要调试的单元测试,然后单击Debug Selected测试 Also described somewhere in this article (though for Visual Studio 2015, but seems to be the same for Visual Studio 2017). 本文中的某处也进行了描述(虽然适用于Visual Studio 2015,但对于Visual Studio 2017似乎相同)。

If your unit test does not show up, you can click on Run All in the Test Explorer, which will first build your solution and then discover and run all tests. 如果未显示单元测试,则可以在“测试资源管理器中单击“全部运行” ,这将首先构建您的解决方案,然后发现并运行所有测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM