Dear all,

With respect to the submitted bug with ID 972992, of which a detailed account can be found at:
http://sourceforge.net/tracker/index.php?func=detail&aid=972992&group_id=61302&atid=497982


This most likely is not a jWebUnit memory leak, as we can see it. Since the WebTester instance is created at construction time, and it *is* an instance variable, it will be marked for gc at the end of the life of the WebTestCase.

Normally this is not an issue. However, my and Jim's assertion is that Budi Boentaran runs the tests from within ant. The ant taskrunner first creates all testcase instances for each test it runs. Then it runs the test (calling setUp before, and tearDown afterwards). Only after all tests have been run, the tests will be cleaned up.

The only way I see to solve this problem is by *NOT* overriding TestCase.tearDown(), but to override TestCase.runBare(). The problem with overriding TestCase.tearDown() and TestCase.setUp() is that the clients of jWebUnit *have* to call super.setUp() and super.tearDown(). In my opinion this is not good, as it breaks encapsulation.

Overriding TestCase.runBare() allows us to move the allocation of WebTester prior to the call to setUp(), and to clean up after the tearDown() has been called:

   public void runBare() throws Throwable {
       try {
           tester = new WebTester();
           super.runBare();
       } finally {
           tester = null;
       }
   }

This *does* open us to a vulnerability: if the internals of junit, or the ant-task, or some other plugin of some IDE doesn't use the runBare() method but its own method of setting up/tearing down a test, then we are in trouble. Also, some other genius (ahum) could have overridden the runBare method, and then our solution won't be called, if the super.runBare isn't called.
I *do* think the risk is minimal, since most IDE's/plugin's will call TestCase.run() as this does some tricky stuff regarding exception handling.


The last solution I would consider is: don't subclass junit.framework.TestCase, but subclass junit.framework.Assert, implement junit.framework.Test, and delegate all calls to Test.* to an TestCase instance. However, this is a rather big refactoring. It should not break anything.

The questions are:
* do we fix this, as it isn't a direct jWebUnit problem
* if we fix, do we override the runBare() method?
* fix it in another way?

Martijn


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Jwebunit-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to