简体   繁体   English

一起运行时单元测试超时,单独运行时成功吗?

[英]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.

相关问题 单元测试在一起运行时失败,单独传递 - Unit Tests fail when run together, pass individually 为什么我的测试一起运行时失败,但单独通过? - Why do my tests fail when run together, but pass individually? 单元测试在Visual Studio中“全部运行”但单独传递时失败 - Unit Tests Fail when “Run All” in Visual Studio but passes individually Flurl&HttpTest:单元测试在全部运行时失败,但在单独运行时通过 - Flurl & HttpTest: Unit tests fail when Run All, but pass when run individually 为什么使用HostType(“ Moles”)进行的单元测试中的断言在单独运行时可以通过,而在一组测试中运行时却失败? - Why would an assert on a unit test with HostType(“Moles”) pass when run individually, but fail when run with a group of tests? C#Selenium WebDriver测试在连续运行时失败但在单独运行时成功 - C# Selenium WebDriver tests failing when run consecutively but succeeding when run individually 单元测试在“全部运行”时失败,但在单次运行时通过 - Unit tests fail on Run All but pass when are run single 编码的UI测试一起运行时无法正常运行 - Coded UI Tests not running properly when run together MSTest单元测试自行通过,在运行其他测试时失败 - MSTest unit test passes by itself, fails when other tests are run 正常运行时阻塞,但在单元测试期间不阻塞(StoreAsync) - blocking when run normally, but not during unit tests (StoreAsync)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM