I don't test with gin. I bootstrap the app with gin, but I test the presenters purely in JUnit using a combo of EasyMock and my own mock classes. It keeps it simple, easy and fast.
On Aug 24, 7:34 pm, Nathan <[email protected]> wrote: > Hey everyone, I have a question. I'm writing some JUnit tests for my > GWT client-side application. I'm using Dependency Injection (GIN), > and I'm having an issue. Here's what's happening: > > testSomething() { > // This automatically injects the MockDisplay, MockCommandService, > and EventBus... > MyPresenter myPresenter = myGinjector.getMyPresenter(); > > // Do some stuff. > ... > > // Now, at this point, I can easily get the MockCommandService, > 'cause it's a singleton: > MockCommandService = myGinjector.getCommandService(); > assertStuff("Make sure the right service commands were > sent!", ...); > > // However, what if I want to test that it hooks into its Display > properly: > myPresenter.getDisplay().getNameField().getValue(); > } > > My problem is that I don't want my Presenters to have a .getDisplay() > function. It would never be used by anything except testing, and > providing public accessors just for my JUnit tests seems completely > wrong. I also don't want to move all my JUnit tests into the package > with my actual classes, I find that that leads to having way too many > classes in your packages... -- I also find it leads to cheating the > APIs and bad test design... :/ > > Any ideas how to get around this? Or do I just have to suffer with > tons of classes with ".getSomethingIDontWantYouToHave()" functions, > just to allow testing with DI? > > Oh, I guess I left that out -- before I was using GIN, this was easy: > > testSomething() { > MockPresenterDisplay display = new MockPresenterDisplay(); > MyPresenter myPresenter = new MyPresenter(display); > > // Do some stuff. > ... > > // However, what if I want to test that it hooks into its Display > properly: > display.getNameField().getValue(); // so clean, so pretty! > } > > Any suggestions? > > Thanks in advance, > > -nathan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" 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-web-toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
