Add support for @Setup methods like:
@Inject
HelloService helloService;
HelloData myTestDouble;
@Setup
void setup(BeanScopeBuilder builder) {
myTestDouble = mock(HelloData.class);
when(myTestDouble.helloData()).thenReturn("MockedViaSetupMethod");
builder.bean(HelloData.class, myTestDouble);
}
@Test
void hello_1() {
assertEquals("hello+MockedViaSetupMethod", helloService.hello());
}
Change such that when @Inject field has a value then it's expected to be a provided test double and the instance value is registered and used for wiring.
@Inject HelloService helloService; // Get this OUT of the DI BeanScope
@Inject HelloData myTestDouble = () -> "ImActuallyATestDouble"; // Put this INTO the DI BeanScope
@Test
void hello_1() {
assertEquals("hello+ImActuallyATestDouble", helloService.hello());
assertEquals("ImActuallyATestDouble", myTestDouble.helloData());
}