简体   繁体   English

如何在调试时运行测试

[英]How to run tests while debugging

I've been using ReSharper test runner in Visual Studio for quite a while, and there is one thing about it that I can't figure out. 我一直在Visual Studio中使用ReSharper测试运行器已经有一段时间了,有一点我无法弄清楚。

I used to have some integrational tests in my solution that performed web requests to my local web server. 我曾经在我的解决方案中进行了一些集成测试,这些测试向我的本地Web服务器执行了Web请求。 I used to be able to launch my web application in debug mode, then launch a test with Resharper test runner within the same Visual Studio instance (that was currently running a debug session), and the test would run normally. 我曾经能够以调试模式启动我的Web应用程序,然后在同一个Visual Studio实例(当前正在运行调试会话)中使用Resharper测试运行器启动测试,并且测试将正常运行。 The breakpoints in my application were hit, and I was able to debug the requests sent from the test. 我的应用程序中的断点被击中,我能够调试从测试发送的请求。

However, when I was trying to do the same thing for a new project, the tests fail to launch. 但是,当我试图为新项目做同样的事情时,测试无法启动。 When I run any test, Visual Studio displays a modal window asking Do you want to stop debugging? 当我运行任何测试时,Visual Studio会显示一个模式窗口,询问Do you want to stop debugging? . Why am I unable to run tests while having an active debugging session anymore? 为什么我在进行活动调试会话时无法运行测试? What does the ability to do this depend on? 这样做的能力取决于什么? Visual Studio version? Visual Studio版本? Resharper version? Resharper版本? Unit testing framework (I'm currently using MSTest)? 单元测试框架(我目前正在使用MSTest)?

I think I've seen this behavior before, it seemed to be driven by the fact that Resharper was feeling the need to always build my project/solution before running tests. 我想我以前见过这种行为,似乎是因为Resharper感觉需要在运行测试之前总是构建我的项目/解决方案。

Try changing the Build Policy to Never (at first at least) from the Unit Test Sessions window: 尝试从“单元测试会话”窗口将“构建策略”更改为“从不(至少起初)”:

在此输入图像描述

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

相关问题 没有发现要运行的测试 - 在调试/运行单元测试用例时 - Visual Studio 2017 15.5.1 - No tests found to run - while debugging/running Unit test cases -- Visual studio 2017 15.5.1 如何确定在构建服务器中构建时要运行或忽略的nunit测试 - How to determine which nunit tests to run or ignore while building in build server 如何使用Visual Studio 2015设置量角器测试以进行调试 - How to setup protractor tests for debugging with Visual studio 2015 如何启用MSpec测试的断点/调试? - How do I enable breakpoints/debugging of MSpec tests? Visual Studio 2015在调试时运行脚本/代码 - Visual Studio 2015 run script/code while debugging 在调试时使用visual studio命令运行实例方法 - Run instance method with visual studio command while debugging Dockerfile 在 Visual Studio 2019 中调试时似乎没有运行 - Dockerfile doesn't seem to run while debugging in Visual Studio 2019 调试时如何在 Visual Studio 中检查“这个”object? - How to inspect “this” object in Visual Studio while debugging? 如何在调试时看到IEnumerable的元素? - How to see the elements of IEnumerable while debugging? 在Visual Studio中调试时如何执行GetLastError() - How to execute GetLastError() while debugging in Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM