Hi, I've made a comparison between the approaches one can take to have a one time setup/teardown in order to avoid going thru the initialization of geoserver over and over and over during tests (at least for read only ones).
The extra requirement is that the one time setup has to allow calling non static methods, since in GeoServetTestSupport we have 3 template methods that subclasses can alter in order to drive how the setup is done. This project: http://www.nabble.com/file/p16609696/onetimesetup.zip onetimesetup.zip shows how one time setup/teardown can be achieved using the three testing frameworks. The first results is that junit4 and junit3 tests can coexist in the same project, but testng not. Once you add testng to the classpath, surefire will use only that one to run the tests, and a class cast exception occurrs trying to run the junit3 tests (probably due to the suite() method, not sure). Anyways, besides this, here is a rough summary. JUnit3 --------------------------------------------------- The base class, OneTimeSetupJunit3, sets the scene for one time setup. Class extending it can specify the following methods: public void oneTimeSetUp() public void oneTimeTearDown() protected void setUpInternal() protected void tearDownInternal() If only those are specified, the order of execution *for each test method* is: oneTimeSetup setUpInternal tearDownInternal oneTimeTearDown (that is, the one time methods, if present, behave like normal setup/teardown would). If the following method is added: public static Test suite() { return new OneTimeTestSetup(new OneTimeJunit3Test()); } then the one time setup and tear down methods are run only before running all tests, and after running them (so they become true one time setup/teardown). All fine? No. When you add that suite() method, Eclipse will run all the tests even if you ask it to run just once. So if you need to debug just one method, that suite() method has to be commented out, and uncommented before committing. How inconvinient. Junit4 ----------------------------------------------------- The base class, OneTimeSetupJunit4, tries to allow for the same approach as the OneTimeSetupJunit4. Unfortunately I could not manage to allow for an ovveridable OneTimeTearDown. Yet, for our specific case, it's not really needed, since all template methods we need to call are in the setup phase, so we could get away marking the only one OneTimeTearDown method we need as @AfterClass TestNG ---------------------------------------------------- Look ma, no base class. The annotations here are placed on standard non static methods, so no machinery is really needed. To run the TestNG tests in Eclipse a plugin is needed, that you can download from here: http://testng.org/doc/download.html My take ---------------------------------------------------- Hum, the junit3 approach is a little annyoing but works, and does not require us to learn anything new. The TestNG one is the one that looks better thought, no need to fight against the framework. So, what shall we do? Blue pill, junit3, red pill, juni4, green pill, TestNG. What are you going to swallow? Please vote Cheers Andrea -- View this message in context: http://www.nabble.com/JUnit3%2C-JUnit4-and-TestNG-comparison-%28for-one-time-setup%29JUnit3%2C-JUnit4-and-TestNG-comparison-%28for-one-time-setup%29-tp16609696p16609696.html Sent from the GeoServer - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------- 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
