I have been looking around the internet for a long, frustrating, while, and I'm still quite confused as to what the purpose of the teardown()
method is in MiniTest and how it should be used.
The basic gist I have is that it is 1-run after each test, and 2-undoes things that were done during the test in order to allow future tests to run in a clean environment.
However, I am unclear on the nature of things it needs to undo: Does it need to empty the DB? Reset class variables? etc.
I am also unclear on whether the method is supposed to be explicitly filled out or not. I have found many examples where teardown()
is completely left out of the example.
(My best guess is that there is a super-method teardown
that runs automatically and takes care of certain things. That would explain why it is often left out, and would also explain why some things are reset in a given teardown()
method and some aren't. But I still don't know which things are and which aren't.)
In short:
Does teardown need to be explicitly created? In what circumstances would it need to be overwritten and in which wouldn't it be?