My 2 cents. I used Guice testing frameworks (GuiceyFruit for me) for integration tests or end to end tests and mocks otherwise. I have used GuiceyFruit's inner static TestModule to configure my DriverManager based DataSource while using JNDI DataSource for my real application. I think GuiceBerry allows you to use @GuiceBerryEnv annotation for the same.
The only downside of using this framework is that you have to separate your integration tests from mock tests by putting them in separate classes. I had one/two integration tests that required a real data source. The rest of the test methods used mocks. If you use Guice frameworks, then those frameowrks inject bean(s) from the modules you specify in setUp method before every test method. To use mocks I had to add a package private setter method to replace the injected DataSource by a mock data source. On Wed, Jan 27, 2010 at 3:04 PM, tul32 <[email protected]> wrote: > > > On 27 Jan., 23:44, Bob Lee <[email protected]> wrote: > > I would just construct MyGuiceApp directly, passing it mocks. You > > don't need Guice in your unit tests. > > > > Bob > > Ok thanks for the tip! This was also the approach that could be picked > up from this post: > > > http://groups.google.com/group/google-guice/browse_thread/thread/21e9185604ca2a45/dd8f9490931700bc?lnk=gst&q=testing#dd8f9490931700bc > > But if my unit-test are supposed to be guice free what is the purpose > of guiceberry: > > http://code.google.com/p/guiceberry/ > > Or am I confusing this with something else? > > > > > -- > 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]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- 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.
