Apache Onami-Test provides a nice integration with JSR330 dependency injection for Java. By using javax.inject.Inject OnamiRunner will provide to inject the dependency inside your test case.
Here is a little example:
@RunWith( OnamiRunner.class ) public class InjectJSR330ModuleClassTestCase extends AbstractModule { public void configure() { bind( Integer.class ).annotatedWith( Names.named( "numeber.version" ) ).toInstance( 10 ); } @javax.inject.Inject @javax.inject.Named( "numeber.version" ) private Integer version; ... }