[英]Unit Tests timeout when run together, succeed when run individually?
I've been searching around and haven't seen anyone noting this particular issue, basically I'm writing some fairly basic unit tests to assess a web API for a university module and where the tests all succeed or fail in the way they are supposed to, running them using the 'Run All' option causes them all to timeout. 我一直在搜索,没有人注意到这个特定问题,基本上,我正在编写一些相当基本的单元测试,以评估大学模块的Web API,以及其中的测试均以预期的方式成功或失败,使用“全部运行”选项运行它们会使它们全部超时。
Any tips would be really helpful. 任何提示将非常有帮助。
OK, based on what you have said, the most likely explanation is that you are not doing Run
in the first scenario, you are doing Debug
. 好的,根据您的发言,最可能的解释是您没有在第一种情况下执行
Run
,而是在进行Debug
。 When you debug Visual Studio automatically hosts your website for you; 调试时,Visual Studio会自动为您托管网站; meaning that your test code connects to the automatically hosted website.
这意味着您的测试代码将连接到自动托管的网站。 When you do
Run All
there is no site there to debug so it just times out. 当您执行
Run All
那里没有要调试的站点,因此它只是超时。
As Yishai points out you are not unit testing: unit testing at the very least would only test code on one side of the service boundary - by definition if you need to have a web server running for your tests to pass then they are not unit tests, they are integration tests. 正如Yishai指出的那样,您不是单元测试:单元测试至少只会在服务边界的一侧测试代码-根据定义,如果您需要运行Web服务器以通过测试,那么它们就不是单元测试,它们是集成测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.