During generation of a test case, in response to a predictable interrupt condition a dynamic portion of a dynamic trap handler is created. The static portion of the dynamic trap handler is generic trap handler code that is not dynamically created and performs such routine tasks as loading the trap number of the interrupt condition, loading a trap code pointer and preparing the processor to branch to the location pointed to by the trap code pointer. The dynamic portion of the trap handler, however, is dynamically created in response to each interrupt condition which occurs. The unique series of instructions of the dynamic portion of the trap handler may be tailored as desired to perform any number of tasks, including verifying the trap handler, verifying trap parameters, generating code to return to a new location upon completion of the trap handler, fixing the interrupt condition, updating the trap vector table, and updating the trap code pointer and a trap data pointer. Any number of other tasks may also be added to the dynamic portion of the trap handler.