There are a few options:

1) There may be a way to use setUp() and tearDown() so that they are
not run before and after every test.  (I'm sure Vincent can answer that
more thoroughly.)  Maybe you can use a flag to indicate whether the
connection already exists and therefore reuse it.

2) You could try the database connection pool (DBCP) that is currently
in the commons-sandbox
(http://jakarta.apache.org/cvsweb/index.cgi/jakarta-commons-sandbox/dbcp/).
 The DBCP is designed so that it takes very little to modify your
existing code to leverage its functionality.  The calls to the DBCP are
almost identical to the calls that create fresh, free-standing
connection.  So from the perspective of the test suite, a new
connection is created with every test.  But from the pool's
perspective, an initial connection is created, then gets reused with
each test.  

3) If you are performing true unit tests, you may need to refactor your
codebase so that the unit of functionality being tested does not
require database connectivity.  This would allow you to run the unit
tests very quickly.

4) If you are performing end-to-end tests, I would term these
functional tests.  Usually functional tests are broad in scope and thus
it is acceptable for them to take longer.  That the test is inefficient
with its database connections is then irrelevant because they are run
less frequently and are given plenty of time to complete.

Hope that helps,
Chuck

--- "Howk, Michael" <[EMAIL PROTECTED]> wrote:
> I couldn't find a "user" list for Cactus, so I'm sending my message
> here.
> Sorry for any inconvenience.
> 
> Is there a way to open a JDBC connection to the database once in my
> ServletTestCase so all of my Tests can use it? I'd like to open it
> before
> running any of my testXXX() tests and close it after the last one
> runs.
> There's probably a really easy way to do this, but I've been beating
> my head
> against the wall for a while to no avail. Any ideas?


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

Reply via email to