Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support @Provides methods for specifying instances to @All injected tests #71

Open
mmadson opened this issue Nov 16, 2016 · 0 comments
Open

Comments

@mmadson
Copy link

mmadson commented Nov 16, 2016

Instead of

public static Module extends TestModule {
  protected void configureTest() {
    bindMany(SomeInterface.class, Impl1.class, Impl2.class);
  }
}
...
@Test
someTest(@All SomeInterface interface) {
 ...
}

I would like to be able to do:

public static Module extends TestModule {
  protected void configureTest() {
    install(new SharedModule());
  }

  @Provides
  @Instance
  SomeInterface  provideImpl1() {   
    return new Impl1();
  }

  @Provides
  @Instance
  SomeInterface provideImpl2(final SomeTypeFromSharedModule info) {
    return new Impl2(info.get());
  }
}
...
@Test
someTest(@All SomeInterface interface) {
 ...
}

As you can see, the latter approach allows me to construct test instances using info from other injected types, whereas the current approach doesn't allow me access to other types that may have been installed.

Also, it would be great to specify the test name for the junit runner, perhaps on the @Instance annotation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant