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

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -