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

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -