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

Deprecate or replace nullableArgumentCaptor #404

Open
StefMa opened this issue Jan 21, 2021 · 0 comments
Open

Deprecate or replace nullableArgumentCaptor #404

StefMa opened this issue Jan 21, 2021 · 0 comments

Comments

@StefMa
Copy link

StefMa commented Jan 21, 2021

I just realized that I can't use argumentCaptor<Type?>.
I have to use the nullableArgumentCaptor for that.

After looking into the implementation I really don't get why there is an explicite argumentCaptor for nullable types.

I think most Kotlin developers would simply use argumentCaptor<Type?> and would expect that it works.

I would suggest that mockito-kotlin simply removes the nullableArgumentCatpor and return a nullable-type in the current argumentCatptor function.
What do you think?

inline fun <reified T : Any> argumentCaptor(): KArgumentCaptor<T> {
return KArgumentCaptor(ArgumentCaptor.forClass(T::class.java), T::class)
}

inline fun <reified T : Any> nullableArgumentCaptor(): KArgumentCaptor<T?> {
return KArgumentCaptor(ArgumentCaptor.forClass(T::class.java), T::class)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant