6

Is there any way to measure test coverage for Kotlin code? Jacoco gives wrong results because can not determine autogenerated code. Is there any other solution?

tse
  • 5,769
  • 6
  • 38
  • 58
  • Use the new [kotlinx.kover](https://github.com/Kotlin/kotlinx-kover) Gradle plugin. `id("org.jetbrains.kotlinx.kover") version "0.4.1"` Once applied, the plugin can be used out of the box without additional configuration. – Mahozad Nov 06 '21 at 13:55
  • Does this answer your question? [Kotlin Test Coverage](https://stackoverflow.com/questions/48220460/kotlin-test-coverage) – Mahozad Nov 06 '21 at 13:57

2 Answers2

0

If you are using IntelliJ IDEA,this link will be helpful for you: https://www.jetbrains.com/help/idea/configuring-code-coverage-measurement.html

else you can check 'Sonarqube', it is good tools for your purpose and it is easy to use and have a good community.

  • Hey Vahid. Welcome to StackOverflow, and thanks for your answer. Can you please summarize the instructions from the link in your own words? – f.khantsis Mar 30 '20 at 09:00
-2

Android Studio has came a long way improving it’s capability in unit testing (thought still long way to go I think). Beginning as early as Android Studio 1.2 (if not mistaken), we could also see coverage testing. This could be as simple as a menu click away by right click on the Test Section of your code package, and then select Run ‘Test in…’ with Coverage as shown below. I think this article help you: https://medium.com/@elye.project/making-android-studio-test-coverage-works-with-kotlin-and-robolectric-a2ab12cdd551