You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add new static Answer to Answers: Answers.RETURNS_DEFAULT_VALUE that calls method's getDefaultValue
This would be useful for annotation mocking, especially with MockitoExtension@Mock(answer = Answers.RETURNS_DEFAULT_VALUE)
Background:
In OSGi Annotations are used as "Component Property Type":
public @interface MyConfig { String timeout() default "1s";}
...
@Activate
public void activate(MyConfig config) {timeout = config.timeout();}
verifying the method activate and configuration property default values is problematic.
Current workaround: mock(MyConfig.class, invocation -> invocation.getMethod().getDefaultValue());
The text was updated successfully, but these errors were encountered:
Note that some configuration are impossible to mock via Mockito
(same as any question on stackoverflow.com)
Mockito v3.6.0
Add new static
Answer
toAnswers
:Answers.RETURNS_DEFAULT_VALUE
that calls method'sgetDefaultValue
This would be useful for annotation mocking, especially with
MockitoExtension
@Mock(answer = Answers.RETURNS_DEFAULT_VALUE)
Background:
In OSGi Annotations are used as "Component Property Type":
verifying the method
activate
and configuration property default values is problematic.Current workaround:
mock(MyConfig.class, invocation -> invocation.getMethod().getDefaultValue());
The text was updated successfully, but these errors were encountered: