I am reading one book about JUnit now and writer advises nulling resources in tearDown method. Why? Isn\'t this GC\'s job? Can it seriously make any harm?
Lets think
Yes, this can indeed be necessary.
You see, JUnit will actually create a separate instance of the Test
class for each test method, and the Junit3 test runner (not so with JUnit4) will keep these instances around until the entire test suite has finished.
Therefore, if your (JUnit3) test class has fields that take up a lot of memory, you can easily run out of heap space when you have a large number of test methods. Of course, if those collections in your example code only ever contain a handful of short strings, it doesn't matter.