I have an object that user typically creates using my factory. I want to make sure my user calls object.undo() before they throw it into the garbage collector.
This class setups the necessary resources so the user isn't writing to production services and instead use test specific services. The user needs to call undo to revert their override.
Here is what I want the user to do
// in setup()
FooObject object = FooFactory.overrideProductionServicesToTestServices();
// do your testing in test*()
// in tearDown()
object.undo()
Here is what the user end up doing
// in setup()
FooFactory.overrideProductionServicesToTestServices()
// do their testing. Everything works.
// Another test, everything breaks
How do I notify the user either via throwing an exception or via class design that the user should call undo()?