New issue
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
Add example failing test for issue #2656 #1
Conversation
Example failing test for mockito#2656
* For examples how to use 'Mock' annotation and parameters see {@link Mock}. | ||
* | ||
* @since 4.6.0 | ||
*/ | ||
Strictness strictness() default Strictness.STRICT_STUBS; | ||
Strictness strictness() default Strictness.NOT_SET; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method now returns local Strictness
enum with a NOT_SET
default.
(This is a breaking change for any code written using the strictness
value of the annotation though)
src/main/java/org/mockito/Mock.java
Outdated
// Todo: unit test to ensure all values covered | ||
enum Strictness { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add a test to ensure the two enums are kept in sync.
if (annotation.strictness() != Mock.Strictness.NOT_SET) { | ||
mockSettings.strictness(annotation.strictness().outer()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we can not set strictness on the settings...
@@ -45,7 +45,7 @@ | |||
private boolean useConstructor; | |||
private Object outerClassInstance; | |||
private Object[] constructorArgs; | |||
protected Strictness strictness = Strictness.STRICT_STUBS; | |||
protected Strictness strictness = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we change the default to null...
if (strictness == null) { | ||
throw strictnessDoesNotAcceptNullParameter(); | ||
} | ||
this.strictness = strictness; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved as we shouldn't be mutating state on a bad input...
@@ -20,7 +20,7 @@ public class StrictnessMockAnnotationTest { | |||
|
|||
public @Rule MockitoRule rule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS); | |||
|
|||
@Mock(strictness = Strictness.LENIENT) | |||
@Mock(strictness = Mock.Strictness.LENIENT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of the breaking change...
Example failing test for mockito#2656