Thursday, June 3, 2010

Mockpico beta

Mockpico is an interesting tool. It leverages Mockito and PicoContainer to allow easy instantiation of Spring Controllers for unit testing. Often controllers have many dependencies injected into it via constructors, setters, fields. Sometimes these would be annotated with @Autowired, sometimes not (old fashioned XML composition). When in unit tests, you don't really want to have to specify every injectee as the particular request mapping you want to test might not use them all. With Constructor Injection you kinda have to specify them all of course, though 'null' might be an OK thing to specify.

Anyway, Mockpico makes it easier :- (scroll down for colorful diagram)

It is pushed out as beta-1d as you can see here;quick~mockpico. A Maven/gpg learning curve conspired to make this work on its fourth attempt (a thru d).