You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Laurent Petit <lp...@sqli.com> on 2004/12/02 16:56:34 UTC

Re: hsql DB startup

Jake Ewerdt wrote:

>On Thursday 06 January 2005 02:28 am, Janos Mucsi wrote:
>  
>
>>This is not a strictly Maven question.
>>
>>Hi Jake
>>This sounds very interesting. I have two questions:
>>1. Is testing against an in-process database a better
>>idea than using mock-objects to fake Connection,
>>ResultSet, etc? (I need to test some hand-coded JDBC
>>DAOs which I will redevelop later with Hibernate, but
>>I can not throw them away just yet.)
>>    
>>
>
>For unit testing, I think it is best to use mock objects to mock the layer below the code you're testing.  Mocking JDBC objects like Connection and ResultSet can be a lot of work, but it is well worth it because you can force exceptional behavior that is very difficult or impossible to reliably create in a testing environment with a real database.
>
>For functional tests that are testing functionality with the database, then I use a real database.
>
>  
>
Hello,

Since this seems indeed theoratically correct to me, I think that if you 
plan to test a lot of DAOs producing SQL, you will endlessly need to 
adapt your tests to the correct SQL produced by the DAO, since you have 
no way to enforce hibernate, for example, to produce SQL selects 
following your coding conventions ...

Using dbUnit and testing against some HSQL database instance for unit 
testing the DAOs makes more sense to me.

But it definitely does not imply that you don't have to mock 
connections, especially if you want to test the treatment of some basic 
SQLExceptions by your DAO.

My 0.02 euros,

-- 
Laurent


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org