Unit tests are good to detect most bugs in your code but not all bugs. When you are writing standard unit tests for a class you are doing the following
- Create a fresh class instance (ex using Setup method in DUnit framework);
- Run a code under test (usually a single call of a single method) on the instance;
- Free the instance (ex using TearDown method in DUnit framework).
And this is how unit tests should be written; if your test detects a bug you immediately know the bug’s origin.
The problem with the above scenario is that it is ideal to hide some badly reproducible bugs such as access violation (AV) bugs. To detect such a bad bug with good probability you need something different, probably to do multiple calls of a method on the same instance, or to call different methods in the same test, and this approach is quite opposite to the idea of unit testing.