Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

big-andy-coates
Copy link
Owner

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;
Copy link
Owner Author

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)

Comment on lines 126 to 127
// Todo: unit test to ensure all values covered
enum Strictness {
Copy link
Owner Author

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.

Comment on lines +51 to +53
if (annotation.strictness() != Mock.Strictness.NOT_SET) {
mockSettings.strictness(annotation.strictness().outer());
}
Copy link
Owner Author

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;
Copy link
Owner Author

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;
Copy link
Owner Author

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)
Copy link
Owner Author

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...

@big-andy-coates big-andy-coates deleted the 2656_failing_test branch November 28, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant