henriquenovais
henriquenovais

Reputation: 19

Can Android tests be developed in Java for a Kotlin application? How about Kotlin tests in a Java application?

I am very new to test development inside an Android environment and I am trying to figure out if I can use frameworks such as Mockito for test development in Kotlin and this question came to mind.

Upvotes: 1

Views: 176

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006564

Can Android tests be developed in Java for a Kotlin application?

Yes, though you will need to deal with Java-Kotlin interop concerns.

How about Kotlin tests in a Java application?

That depends on what you mean by "a Java application":

  • If you mean an app that is not configured for Kotlin support via Gradle, then you cannot write Kotlin anywhere in that app, whether in tests or anywhere else

  • If you mean an app that is configured for Kotlin support but just happens to only have Java code, then yes, you can write tests in Kotlin (with similar interop concerns)

I am trying to figure out if I can use frameworks such as Mockito for test development in Kotlin

Yes, though frequently there is already a Kotlin wrapper for those things. In the case of Mockito, mockito-kotlin works nicely.

Upvotes: 1

Related Questions