On Friday 21 December 2007 11:09:21 am Andrea Aime wrote:
Hi,
it's well known that running the tests in geoserver
takes time due to the repeated mock data dir creation
and application context setup.
The idea I'm proposing goes along the lines of making
this process smarter.
It has been said that if a test is read only, that is,
it does not change the data in the data dir, there is
no need to wipe out and re-create the data dir
for each test run, and it would be better to use
a "once for test class" setup and teardown.
Gabriel mentioned it, but I can't find it in junit.
Guess you were speaking about some extension or
custom made solution?
I got it from the "Pragmatic Unit Testing" book.
If we were using Junit4 it would be even easier as we can annotate any method
with @BeforeClass and @AfterClass.
But for Junit 3.x the thing goes like this:
public class MyClassTest extends TestCase {
private static ResourceToSetUpOnlyOnce resource;
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(MyClassTest class);
TestSetup wrapper = new TestSetup(suite) {
protected void setUp() throws Exception {
oneTimeSetUp();
}
protected void tearDown() {
oneTimeTearDown();
}
};
return wrapper;
}
private static void oneTimeSetUp() throws Exception {
resource = new ResourceToSetUpOnlyOnce();
....
}
private static void oneTimeTearDown() {
//clean up resources
}
protected void setUp() throws Exception {
super.setUp();
// facilitates running a single test at a time (eclipse lets you do
this
// and it's very useful)
if (resource == null) {
oneTimeSetUp();
}
}
protected void tearDown() throws Exception {
}
}
Anyways, let's say we have that. We could mark
tests as read only, and have them do the above.
But I was thinking there is no need to go and mark
each test as such if we add a transaction listener
to the spring context, that listener should be
enough to know any data was modified (we check if
any transaction was successfully carried out).
will it depend on the datastore under test throwing out edit events correctly?
so far your idea seems clever to me.
Gabriel
This would allow for a base class that's smart
enough to figure our if rebuildilng the mock
data dir is needed or not.
Opinions?
Cheers
Andrea
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel
!DSPAM:4045,476b90e5193653668746562!