Hi,
I've spent some time trying to make our read only test cases
initialize the data directory just once but I think I'm stumbling
into a design limitation of JUnit4.

On trunk the GeoServerAbstractTestClass has a configurable setup
method that calls some extra template methods the subclasses
have to provide:
* getLoggingConfiguration(): to change the logs config while
   building/debugging a test suite, but silence them otherwise
   (by default a very silent log config is used)
* TestData getTestData(), that builds the TestData object
   that sets up the data directory. We have subclasses for
   "mock" testing based on property fiels and geotiffs,
   one for tests that do use a pre-cooked data dir, and
   one that uses pre-cooked data dir + external dbms based
   datastore
* getSpringContextLocations() to have a test run with a specific
   set of applicationContext.xml files instead of the usual one.

The problem is, whatever method is marked as one time setup
using @BeforeClass has to be static, so the above framework
cannot work.

The way Gabriel was referring to for running one time
setup with junit3 uses static fields and methods too...

I'm a little short on ideas, anyone with some smarts on how
to deal with this limitation?

The one solution I found so far is... to avoid using JUnit
and use TestNG instead. TestNG has a different model
for running tests and that allows the usage of non
static methods for @BeforeClass initializations:
http://www.ibm.com/developerworks/java/library/j-cq08296/

More information here:
http://www.scribd.com/doc/331929/Beyong-JUnit-TestNG
http://testng.org/doc/

Glub... any better idea?
Cheers
Andrea



-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to