Testing Multithreaded Code
It’s hard enough to write code that works as expected. That’s one reason to write unit tests. It’s dramatically harder to write concurrent code that works and even harder to verify that it’s safe enough to ship.
In one sense, testing application code that requires concurrent processing is technically out of the realm of unit testing. It’s better classified as integration testing. You’re verifying that you can integrate the notion of your application-specific logic with the ability to execute portions of it concurrently.
Tests for threaded code tend to be slower because you must expand the scope of execution time to ensure that you have no concurrency issues. Threading defects sometimes sneakily lie in wait, surfacing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access