Hi, When testing our application i have runned into a little problem.
We want to test the cases where the execution of different DBI commands could fail, and are trying to do so with the Test::MockObject modules ( More specifically Test::MockDBI ). The problem is the following: In order to create fake functionality the Test::MockObject package override the typeglobs related to DBI (Please enlighten me if i am wrong). For those interested you can have a peek inside the Test::MockObject module at line 322. This will naturally cause that tests that is executed after this and requires the real DBI with database connection will fail. So, i need to restore them to the correct state before i can continue with my tests. My first attempt was something like this: use Symbol qw(delete_package); delete_package('DBI'); eval{ require DBI; DBI->import(); 1; }or do{ warn $@ ."\n"; }; But it doesnt seems to work, i get the error message that DBI is not loaded. I have also tried to delete the DBI from the Symbol Table and remove $INC{DBI} instead of using the Symbol package, only to find out that this also does not work, and learning that the symbol table is only read at compile time ( Is this right btw? ). So my question is essentially is it possible to completely reload the DBI and all its related packages at runtime? Another solution could be to copy the original typeglobs before the Test::MockObject package override those, and then restore them afterwards, if this is even possible? I should add that i am using Test::Class at the moment and that i would like to avoid forking off to create a seperate new perl interpeter for such cases as i describe. - Joakim