Android-Testing-With-Kotlin
Android-Testing-With-Kotlin copied to clipboard
Example migration of Android application from Java to Kotlin - DO NOT MERGE
Migration findings and solved issues:
- Java
protected
(package-private + inheritance) != Koltinprotected
(private + inheritance) - there is no
package-private
scope to hide classes inside of package and expose just a public interface - tests that verifies nulls are replaced with non-nullable Kotlin types
- nullable view has to be guarded with
.?
, because smart cast does't work forvar
-s - builders can be replaced with constructor and named parameters
- Mockito is failing on final classes (Kotlin default), can be fixed by Mock Maker
- Mockito
any()
doesn't work for objects in Kotlin, alternativeany()
from mockito-kotlin can be used -
when
is a keyword in Kotlin, useBDDMockito.given()
instead - Gradle
annotationProcessor
is replaced bykapt
Check Files changed tab to see files diff.