I've been using Test Driven Development in a Seaside app I've been playing with, and all of my data is stored as objects in the image (as opposed to a database).
So when I run my tests I've had to be careful to store away the real data before it gets trashed with test data, like this:
ToDoTest>>setUp
savedTasks := Task tasklist.
Task deleteAllTasks.
savedProjects := ToDoProject projectlist.
ToDoProject deleteAllProjects.
savedPeople := Person peoplelist.
Person deleteAllPeople.
And:
ToDoTest>>tearDown
Task tasklist: savedTasks.
ToDoProject projectlist: savedProjects.
Person peoplelist: savedPeople
The problem comes when my tests fail, which of course they do, this pops up the debugger, and I can then fix away, but the tearDown doesn't always get called and so I can lose my real data.
I do save the data out to files, so it's not a huge problem, but it is not as smooth and automated as I'd like it to be.
Anyway I can improve this?