Closed
Description
openedon Jul 21, 2016
Overview
Is it planned for JUnit 5 to discover composed @ExtendWith
annotations on fields?
As far as I can see (from Milestone 1) they are only discovered in case they are used on types or methods.
For projects like Mockito it would be useful to also discover extension by analyzing field annotations.
Example:
// The following explicit declaration would become unnecessary.
// @ExtendWith(MockitoExtension.class)
public class MyServiceTest {
@Mock
FooService fooService;
@InjectMocks
MyService cut;
@Test
void testSomething() {
....
}
}
In case @Mock
and @InjectMocks
were to be changed to composed annotations declaring @ExtendWith(MockitoExtension.class)
, they could simply be used without having to declare the extension for each test class.
Related Issues
- Support programmatic extension registration via fields #497
- Introduce mechanism for programmatic extension management #506
- Support declarative extension registration on fields and parameters #864
Deliverables
- Support registration of extensions on fields with the desired extension classes supplied via
@ExtendWith(...)
.- This is analogous to the current support for declaring
@ExtendWith
on classes and methods.
- This is analogous to the current support for declaring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment