Skip to content

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

@mmadson

Description

@mmadson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions