ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: Ant, JUnit and SQL
Date Mon, 14 Jul 2003 11:04:15 GMT
> 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.

Same is done inside Ant´s own testing classes. E.g. the testcases for
selectors extend BaseSelectorTest or the testcases for tasks extends
BuildFileTest. The BFT does the project initialization and parsing
of a give xml file in the setUp().

That´s the usual way.

And providing a common baseclass is a good suggestion. You can provide
methods there, too.

> 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.

More exactly: extend the JUnitTestRunner class (but you don´t really 
want that ...) :-)

> 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?).

Not completely true. The JUnit classes can access other files as all classes
can: you have to know their location (by searching in the test classpath,
paths or given via system property).


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message