-
Notifications
You must be signed in to change notification settings - Fork 205
Update MockSettings usage #560
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
base: main
Are you sure you want to change the base?
Conversation
TimvdLippe
left a comment
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 am fine with cleaning things up, but isn't the lenient change a breaking change? I am surprised none of our tests started failing. Maybe we lack test coverage for it?
|
Removal of Let me add some test coverage for the new |
|
We can also keep the lenient boolean, mark it as deprecated and then convert it to the correct strictness value. And if somebody supplies both, the strictness value takes precedence. |
|
Unfortunately Kotlin's I'm not keen on introducing another |
|
I am confused, since I thought that we wouldn't need a inline fun <reified T : Any> mock(
extraInterfaces: Array<out KClass<out Any>>? = null,
name: String? = null,
spiedInstance: Any? = null,
defaultAnswer: Answer<Any>? = null,
serializable: Boolean = false,
serializableMode: SerializableMode? = null,
verboseLogging: Boolean = false,
invocationListeners: Array<InvocationListener>? = null,
stubOnly: Boolean = false,
useConstructor: UseConstructor? = null,
outerInstance: Any? = null,
lenient: Boolean = false
strictness: Strictness? = null,
): T {As I understand it, this is backwards compatible as well, since we only add a new parameter and we keep the existing ones. Sure, we can't mark the one parameter as deprecated, but we can denote that in the method description. And we can add that to a migration guide when we a publish a new major version. |
|
I see - yes that would work. I was thinking of marking the |
|
I agree with your approach, Tim. Additionally, we can log a deprecation warning with Mockito logger when we detect Last bit, make the default value of the new inline fun <reified T : Any> mock(
extraInterfaces: Array<out KClass<out Any>>? = null,
name: String? = null,
spiedInstance: Any? = null,
defaultAnswer: Answer<Any>? = null,
serializable: Boolean = false,
serializableMode: SerializableMode? = null,
verboseLogging: Boolean = false,
invocationListeners: Array<InvocationListener>? = null,
stubOnly: Boolean = false,
useConstructor: UseConstructor? = null,
outerInstance: Any? = null,
lenient: Boolean = false,
strictness: Strictness? = if (lenient) Strictness.LENIENT else null
): T {This way, the implementation of the function can already rely on the value of the new |
@IncubatingfromuseConstructorandouterInstanceparams. mockito-core removed@Incubatingfrom these methods onMockSettingsin the 4.0.0 release: mockito/mockito@7032574Removelenientparam since it is deprecated inMockitoSettingsin mockito-core in favor ofstrictnesslenientparam since it is deprecated inMockitoSettingsin mockito-corestrictnessparamdefaultAnswersetting formockStaticAPI