5. Testing your app in Kotlin

Birat Rai
2 min readDec 20, 2017

Kotlin series has been developed keeping in mind, you are already familiar at least at beginner’s level.

This is the Fifth milestone towards our Kotlin series. Go to the fourth milestone if you haven’t done so.

The testing pyramid.

In this series, we will simply follow the coding challenges developed for the Android Developer Fundamentals Course, Unit 1 — Lesson3.

Here we will create a simple calculator app

UI for a simple calculator app.

Here we will be creating initial functional UX as per the UI shown.

Steps to add unit test?

  • Create test class CalculatorTest.kt
  • The test class is pretty much the same as Java Unit test.
@Test
fun addTwoNumbers() {
.........
}
  • Try to use AssertThat over Assert
assertThat(resultAdd, `is`(equalTo(3.0)))

The sixth milestone in this series.

6. RecyclerView Kotlin

References:

  1. Using Kotlin for Android development ~ Kotlin.org
  2. Resources to Learn Kotlin ~ developer.android
  3. Video of Lectures ~ youtube.com
  4. Best Practices for Testing ~ developer.android
  5. Junit4 Testing ~ junit4.org
  6. Mockito ~ Mockito.org
  7. Android Testing Codelab ~ codelab.developers
  8. Benefits of using assertThat over Assert ~ blog

--

--