Should I unit test concurrency?

自古美人都是妖i 提交于 2019-12-11 01:54:34

问题


I have a few methods that are impacted by concurrency. Specifically "Rush" (a.k.a Race) conditions. Should I unit test them or integrate/black-box test them?

I think that setting up a unit test might be a rather difficult task, but also is integration test...


回答1:


Unit tests must be deterministic, so concurrency doesn't belong there. (I keep my unit tests completely synchronous.)

Go for integration tests to sniff out race conditions — but be prepared for false positives. In other words, the tests passing is no proof that you don't have a race condition. But a failure will alert you to something you need to fix.




回答2:


i've found this article and its quite instructive about my question: https://testing.googleblog.com/2014/02/minimizing-unreproducible-bugs.html



来源:https://stackoverflow.com/questions/20861305/should-i-unit-test-concurrency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!