mockito / mockito-kotlin

Using Mockito with Kotlin
MIT License
3.1k stars 200 forks source link

Deprecate or replace nullableArgumentCaptor #404

Open StefMa opened 3 years ago

StefMa commented 3 years ago

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?

https://github.com/mockito/mockito-kotlin/blob/b8f480fd5594d037a085da2d857bdd5597a56bdf/mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2/ArgumentCaptor.kt#L35-L37

https://github.com/mockito/mockito-kotlin/blob/b8f480fd5594d037a085da2d857bdd5597a56bdf/mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2/ArgumentCaptor.kt#L142-L144