google-developer-training / basic-android-kotlin-compose-training-tip-calculator

Apache License 2.0
61 stars 97 forks source link

Write automated tests: Android Basics with Compose #197

Open KHadham opened 7 months ago

KHadham commented 7 months ago

cannot run the test based on the provided code on codelabs

import com.example.traintipcalculator.calculateTip
import org.junit.Assert.assertEquals
import org.junit.Test
import java.text.NumberFormat

class TipCalculatorTests {
    @Test
    fun calculateTip_20PercentNoRoundup() {
        val amount = 10.00
        val tipPercent = 20.00
        val expectedTip = NumberFormat.getCurrencyInstance().format(2)
        val actualTip = calculateTip(amount = amount, tipPercent = tipPercent, false)
        assertEquals(expectedTip, actualTip)
    }
}

error Method getCurrencyInstance in android.icu.text.NumberFormat not mocked. See http://g.co/androidstudio/not-mocked for details. java.lang.RuntimeException: Method getCurrencyInstance in android.icu.text.NumberFormat not mocked. See http://g.co/androidstudio/not-mocked for details.