Alex Rivera | Logout

Unit Testing, Deadlocks, and Race Conditions

Asked 2008-10-06T23:21:02.540
12

Any suggestions on how to write repeatable unit tests for code that may be susceptible to deadlocks and race conditions?

Right now I'm leaning towards skipping unit tests and focusing on stress tests. The problem with that is you can run a stress test 5 times and see five different results.

EDIT: I know its probably just a dream, but if there were a way to control individual threads and cause them to execute one instruction at a time then I might get somewhere.

Edit
Report

1 Answer

0

I have previously used artificial delays in the code that are triggered by some parameters in the request. For example one request tells the server to delay write between two writes and another to do them with no delay in between.

A Mark Bessey writes, this is only useful for creating repro, not for discovering the problem.

answered 2008-10-20T13:22:34.723

Your Answer