You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Nathan Maves <Na...@Sun.COM> on 2005/01/13 17:17:27 UTC

script runner with junit

Team,

Kind of an OT question but here goes.

Consider the example of a student.  I have a Dao that handles the 
select/insert/update/delete ( and many others) of a Student.  I my 
junit test case I want to use the ibatis script runner to test these 
methods.  At first thought I figured that I would put the 
initialization code in the setup() method and the cleanup in the 
tearDown().  Problem here it that these method get called for every 
test.  So I end up setting up and cleaning the database for every test.

Is there a better way to do this?  Any examples?

Nathan


Re: script runner with junit

Posted by Kris Jenkins <kr...@yahoo.co.uk>.
Nathan,

I've never actually done it, so I can't help you directly.  :-(
However, dbunit does have built-in support for Oracle [bc]lob (see their 
FAQ), and so does ibatis as of 2.0.9 (see the release notes?).
The actual wiring is left as an exercise... ;-)

HTH,
Kris

> Kris,
>
> This looks right up my alley!  Now comes the hard part....  How would 
> you incorporate LOB into the picture?
>
> Nathan
>
> On Jan 13, 2005, at 9:21 AM, Kris Jenkins wrote:
>
>> Nathan Maves wrote:
>>
>>> Team,
>>>
>>> Kind of an OT question but here goes.
>>>
>>> Consider the example of a student.  I have a Dao that handles the 
>>> select/insert/update/delete ( and many others) of a Student.  I my 
>>> junit test case I want to use the ibatis script runner to test these 
>>> methods.  At first thought I figured that I would put the 
>>> initialization code in the setup() method and the cleanup in the 
>>> tearDown().  Problem here it that these method get called for every 
>>> test.  So I end up setting up and cleaning the database for every test.
>>>
>>> Is there a better way to do this?  Any examples?
>>>
>>> Nathan
>>
>>
>> Have you considered dbunit?  I've found it pretty easy to work with 
>> (providing you've got a test database you can happily trash!)
>>
>> Here are a couple of good links:
>>
>> http://dbunit.sourceforge.net/
>> http://www.onjava.com/pub/a/onjava/2004/01/21/dbunit.html
>>
>> Kris
>>
>>
>> -- 
>> Kris Jenkins
>> Email:  kris@jenkster.com
>> Blog:   http://cafe.jenkster.com/
>> Wiki:   http://wiki.jenkster.com/
>>
>>
>>
>> -- 
>> No virus found in this outgoing message.
>> Checked by AVG Anti-Virus.
>> Version: 7.0.300 / Virus Database: 265.6.11 - Release Date: 12/01/2005
>>
>
>
>


-- 
Kris Jenkins
Email:  kris@jenkster.com
Blog:   http://cafe.jenkster.com/
Wiki:   http://wiki.jenkster.com/



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.11 - Release Date: 12/01/2005


Re: script runner with junit

Posted by Nathan Maves <Na...@Sun.COM>.
Kris,

This looks right up my alley!  Now comes the hard part....  How would 
you incorporate LOB into the picture?

Nathan

On Jan 13, 2005, at 9:21 AM, Kris Jenkins wrote:

> Nathan Maves wrote:
>
>> Team,
>>
>> Kind of an OT question but here goes.
>>
>> Consider the example of a student.  I have a Dao that handles the 
>> select/insert/update/delete ( and many others) of a Student.  I my 
>> junit test case I want to use the ibatis script runner to test these 
>> methods.  At first thought I figured that I would put the 
>> initialization code in the setup() method and the cleanup in the 
>> tearDown().  Problem here it that these method get called for every 
>> test.  So I end up setting up and cleaning the database for every 
>> test.
>>
>> Is there a better way to do this?  Any examples?
>>
>> Nathan
>
> Have you considered dbunit?  I've found it pretty easy to work with 
> (providing you've got a test database you can happily trash!)
>
> Here are a couple of good links:
>
> http://dbunit.sourceforge.net/
> http://www.onjava.com/pub/a/onjava/2004/01/21/dbunit.html
>
> Kris
>
>
> -- 
> Kris Jenkins
> Email:  kris@jenkster.com
> Blog:   http://cafe.jenkster.com/
> Wiki:   http://wiki.jenkster.com/
>
>
>
> -- 
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 265.6.11 - Release Date: 12/01/2005
>


Re: script runner with junit

Posted by Kris Jenkins <kr...@yahoo.co.uk>.
Nathan Maves wrote:

> Team,
>
> Kind of an OT question but here goes.
>
> Consider the example of a student.  I have a Dao that handles the 
> select/insert/update/delete ( and many others) of a Student.  I my 
> junit test case I want to use the ibatis script runner to test these 
> methods.  At first thought I figured that I would put the 
> initialization code in the setup() method and the cleanup in the 
> tearDown().  Problem here it that these method get called for every 
> test.  So I end up setting up and cleaning the database for every test.
>
> Is there a better way to do this?  Any examples?
>
> Nathan

Have you considered dbunit?  I've found it pretty easy to work with 
(providing you've got a test database you can happily trash!)

Here are a couple of good links:

http://dbunit.sourceforge.net/
http://www.onjava.com/pub/a/onjava/2004/01/21/dbunit.html

Kris


-- 
Kris Jenkins
Email:  kris@jenkster.com
Blog:   http://cafe.jenkster.com/
Wiki:   http://wiki.jenkster.com/



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.11 - Release Date: 12/01/2005