Excellent, thank you very much! This unit-testing thing is turning
out to be more fun than I thought it would be ;)
Gili
Robbie Vanbrabant wrote:
>
>
> On Mon, Oct 27, 2008 at 12:57 AM, Gili <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>
> Robbie,
>
> Is it considered "good practice" to stub out database classes when
> you're unit testing network code?
>
>
> Certainly.
>
>
> Or am I better off using something
> like DbUnit to test against a real database?
>
>
> I think DBUnit is incredibly useful for DAO tests. You can use an
> in-memory database.
>
>
> I have been reluctant to
> use DbUnit because of my XML-phobia :) I don't like the headache of
> having to set up the test data in some XML format.
>
>
> Don't fear XML, storing test data is a perfectly reasonable use case
> for it.
>
>
> I much prefer stubbing out the database using normal Java code
> (it's easy enough to
> do) but then I'm afraid I'm not testing something vital. Is there an
> easier way to do all of this?
>
>
> Using a mocking framework will definitely help (EasyMock, Mockito).
> What you want to stub depends on what you're testing. If you're
> testing the data access layer, you should not stub out data access.
> You want to see the queries run and test their results; which is where
> DBUnit comes in.
>
> Robbie
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---