We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Means we can use the mockito annotations @Mock, @Spy, @Captor along with @Inject for "component testing".
@Mock
@Spy
@Captor
@Inject
For example:
@ExtendWith(InjectExtension.class) // Use InjectExtension (JUnit 5) !!! class WithExtnNamedMocksTest { @Mock @Blue SomeStore blueStore; @Mock @Named("green") SomeStore greenStore; @Inject StoreManagerWithSetterQualifier storeManager; @Test void when_plainCaptor() { when(blueStore.store()).thenReturn("BlueStoreStub"); when(greenStore.store()).thenReturn("GreenStoreStub"); assertThat(storeManager.blueStore()).isEqualTo("BlueStoreStub"); assertThat(storeManager.greenStore()).isEqualTo("GreenStoreStub"); } }
Is effectively the same as:
@Test void test() { try (BeanScope beanScope = BeanScope.newBuilder() .withMock(SomeStore.class, "Blue") .withMock(SomeStore.class, "green") .build()) { final SomeStore greenStore = beanScope.get(SomeStore.class, "green"); final SomeStore blueStore = beanScope.get(SomeStore.class, "blue"); when(blueStore.store()).thenReturn("BlueStoreStub"); when(greenStore.store()).thenReturn("GreenStoreStub"); final StoreManagerWithSetterQualifier storeManager = beanScope.get(StoreManagerWithSetterQualifier.class); assertThat(storeManager.blueStore()).isEqualTo("BlueStoreStub"); assertThat(storeManager.greenStore()).isEqualTo("GreenStoreStub"); } }
The text was updated successfully, but these errors were encountered:
#115 Add JUnit 5 @ExtendWith(InjectExtension.class)
321bbc8
Additionally: #114 Add to Builder API support for withMock() and withSpy() taking name qualifier
rbygrave
No branches or pull requests
Means we can use the mockito annotations
@Mock
,@Spy
,@Captor
along with@Inject
for "component testing".For example:
Is effectively the same as:
The text was updated successfully, but these errors were encountered: