简体   繁体   中英

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.

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 . When you debug Visual Studio automatically hosts your website for you; 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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