SUnit with too many tests

Hernan Wilkinson hernan.wilkinson at gmail.com
Mon Feb 11 16:59:11 UTC 2008


Hi,
 I just wanted to share with you that we had problems running too many tests
with SUnit because of memory use.
 We have around 15,000 unit tests and while running them the memory grew
from 80 megs to 700 megs (we use VisualAge) and therefore, the machine
became really slow...
 Anyway, we realized the memory was not freed because the tests referenced
objects from their instance variables. Therefore we added a method that puts
"nil" in all test's instance variables (but 'selector').
 The amazing thing is that not only running the test now do not makes the
image to grow but it takes 50% less time to run them! So anyway, we are
happy with that and maybe this change is useful to other people.
 Here is the code:

TestCase>>runCase

    [self setUp.
    self performTest] sunitEnsure: [self tearDown;cleanUpInstanceVariables]

TestCase>>cleanUpInstanceVariables

    (TestCase allInstVarNames size + 1) to: self class allInstVarNames size
do: [ :index | self instVarAt: index put: nil ]


Bye,
Hernan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080211/75c70f42/attachment.htm


More information about the Squeak-dev mailing list