ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Glanville, Jay" <Jay.Glanvi...@NaturalConvergence.com>
Subject RE: Ant, JUnit and SQL
Date Mon, 14 Jul 2003 10:53:45 GMT
> Hi,
> 
> I have a requirement to run db scripts prior and after each 
> testcase. Whats
> the best way to do this? I use a wildcard to find the testcases:
> 
> <batchtest>
>       <fileset dir="${dir.src}">
>           <include name="**/*Test.java"/>
>           <exclude name="**/AllTests.java"/>
> 	</fileset>
> </batchtest>
> 
> So what I would like to do is something like this:
> 
> 1. for testcase, xxxTest, found by the above target,
> 2. run xxxsetup.sql
> 3. run xxxTest
> 4. run xxxteardown.sql
> 5. continue for each testcase
> 
> I can use a naming convention for the sql scripts if that 
> helps. I know I
> can put the call in the testcase itself but Ant has good functionality
> builtin for calling sql already and don't want to put jdbc 
> code into my
> testcases as well.

Hello Rakesh.

My first question to you is why don't you want to have any JDBC code in your
test cases?  Why this requirement?  

The reason I'm asking is because I recently build a set of test cases in
which I needed to reset the database contents after each test case, very
similar to your situation.

I accomplished this by creating a Database class that encapsulated all
activities I'd need to do to the database (reload data from a file store,
backup to file store, etc).  Then, I made an abstract test case in which the
setup and teardown methods performed the database work.  All subsiquest test
case classes used this abstract test case as their super class.

I don't believe that Ant has any functionality to allow you to run code
before and after all discovered test cases.  In order to do this, you'd need
to modify the JUnit task.

Another reason why performing the work in the test cases is better then in
Ant is because ant only finds the class, where as the setup and teardown is
actually done before and after each test METHOD (that is what you want to
do, isn't it?).

I know that this isn't the answer you're looking for, but it was the best
way I found to address this situation.

JDG
--
Jay Dickon Glanville

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message