Unit test for thread safe-ness?

后端 未结 9 1782
你的背包
你的背包 2020-11-30 19:32

I\'ve written a class and many unit test, but I did not make it thread safe. Now, I want to make the class thread safe, but to prove it and use TDD, I want to write some fa

9条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 20:04

    I have seen people try to test this with standard unittests as you yourself propose. The tests are slow, and have so far failed to identify a single of the concurrency problems our company struggles with.

    After many failures, and despite my love for unittests, I have come to accept that errors in concurrency is not one of unittests strengths. I usually encourage analysis and review in favour of unittests for classes where concurrency is a subject. With total overview of the system it is in many cases possible to prove/falsify claims of thread safety.

    Anyhow I would love for someone to give me something that might point to the opposite, so I watch this question closely.

提交回复
热议问题