Unable to use @Bind with @Inject in BoundFieldModule (multiple injectors).
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
I'm trying to set up a test for a tool written with Guice.
The test environment has an injector which provides mock versions of the backends and injects the into the test class. The tool I'm testing has its own injector in which I want to bind these mocks. I tried writing some code like:
```java
public final class ToolTest {
@Rule public final TestRule injectRule = environment.injectInto(this);
@Inject @Bind BackendClient client;
private Tool tool;
@Before public void setUp() {
tool = Tool.withModule(BoundFieldModule.of(this));
}
}
```
But it doesn't work because BoundFieldModule has an explicit check to prevent @Bind being used with @Inject, presumably under the assumption that the user has one injector. Can a flag be added to allow this use for multiple injectors, please?
Contributor guide
Assessment
This issue has not been assessed yet.