java - Guice field injection and TestNG -
when developing testng tests guice, la this:
@guice(modules=mytestmodule.class) public class mytestclass { }
it's easy use field injection declare dependencies of test class. now, suppose have this:
@guice(modules=mytestmodule.class) public class mytestclass { @inject private foo foo; @test public void mytest() { injector injector = guice.createinjector(new someothermodule()); } }
because of field injection, if someothermodule
doesn't provide binding foo
, mytest()
fail due creationexception
, because not have ability create mytestclass
, if not intend test create mytestclass
injector.
is there way express intention, without changing constructor injection of foo
? is, there way somehow make not error create injector, make error when trying provision mytestclass
, without changing how mytestclass
written?
Comments
Post a Comment