I have a prototype spring bean that has some injected dependencies and also have some constructor arguments.
public BeanA {
@Inject private BeanB beanB;
private String arg;
public BeanA(String arg) {
this.arg = arg;
}
public void methodToTest() {
// ...
// ...
// ...
}
}
I want to unit test this class, mocking my injected BeanB
.
Usually, I'd use @InjectMocks
to start my mocks inside BeanA
.
How can I achieve this? So far, I don't want to inject BeanB
in the constructor as it would mix business arguments and dependencies.