Unit-testing multithreaded applications

前端 未结 4 1257
不思量自难忘°
不思量自难忘° 2021-01-06 09:16

Has anyone got any advice or know of any frameworks for unit-testing of multithreaded applications?

4条回答
  •  感动是毒
    2021-01-06 09:38

    Typically you don't unit test the concurrency of multi threaded applications as the unit tests aren't dependable and reproducible - because of the nature of concurrency bugs its not generally possible to write unit tests that consistently either fail or succeed, and so unit tests of concurrent code generally don't make very useful unit tests.

    Instead you unit test each single threaded components of your application as normal and rely on load testing sessions to identify concurrency issues.

    That said, there are some experimental load testing frameworks for testing concurrent applications, such as Microsoft CHESS - CHESS repeatedly runs a given unit test and systematically explores every possible interleaving of a concurrent test. This makes your unit tests dependable and reproducible.

    For the moment however CHESS is still experimental (and probably not usable with the JVM) - for now stick with load testing to weed out concurrency issues.

提交回复
热议问题