Test error code by invoking it with a CrashTestDummy object that throws an exception instead of doing real work. One of the TestingPatterns in KentBeck's book, TestDrivenDevelopment. Also described in JbRainsberger's book, "JUnit Recipes: Practical Programmer Testing Methods" (Summer 2004) ---- Simulating an exception is much easier than recreating it. This generally implies that the exception thrower and the exception catcher are different objects and that one constructs the catcher by passing it a thrower as a parameter. If the thrower is represented as an interface, then one can easily substitute a "crash test dummy" implementation -- one that always throws the desired exception -- in the required test. -- JbRainsberger ---- CategoryTesting