There have been some changes to the class hierarchy involving JBossTestCase. It used to
subclass from junit.framework.TestCase. It now subclasses from org.jboss.test.BaseTestCase
which in turn subclasses from org.jboss.test.AbstractTestCase.
BaseTestCase provides a getLog() method, something which JBossTestCase used to do. But in
order for logging to be set up correctly, a subclass X of JBossTestCase must ensure that
setUp() is called in BaseTestCase. If X does not override setUp() or tearDown(), it need
take no action, as the method will be inherited; if it does override setUp() or
tearDown(), it needs to call super.setUp() and super.tearDown() in the overriding
methods.
But I believe there are still problems here:
1. JBossTestCase uses logging provided by BaseTestCase, but it does not call setUp() or
tearDown(). Also, test class constructors seem to get called by JUnit before setUp()
methods. Thus, I believe that any use of logging in JBossTestCase (for example, when
handling exceptions in initDelegate()) will not be properly initialised by that time, as
setUp() will not yet have been called.
2. The setUp() and tearDown() methods are called each time a testcase is run. So it
appears that logging will be set up and torn down for every test case, as opposed to once
every test suite. It may be more appropriate to arrange things so that either this setup
was done in a one time setup/teardown wrapper, as in AbstractTestCaseWithSetup, or arrange
for logging setup outside of the methods setUp() and tearDown(). But
AbstractTestCaseWithSetup would probably need some alteration as it is currently tuned to
run with Joram tests. See related:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=91386&am...
3. If setUp() and tearDown() are used as the means for initialising logging, would it help
programmers if those methods were overridden in JBossTestCase to call super.setUp() and
super.tearDown(), to make it more obvious that there was important work being done in
superclasses with these methods?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3986279#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...