In which task and step of the codelab can this issue be found?
Step 6
Describe the problem
@Test
fun price_twelve_cupcakes() {
val viewModel = OrderViewModel()
viewModel.price.observeForever {}
viewModel.setQuantity(12)
assertEquals("$27.00", viewModel.price.value)
}
expected:<$27.00> but was:
Expected :$27.00
Actual :null
viewModel.price.value always returns null value. However, this textview still displays correct price.
TextView
android:id="@+id/total"
style="@style/Widget.Cupcake.TextView.FinalPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="@dimen/side_margin"
android:text="@{@string/subtotal_price(viewModel.price)}"
tools:text="Total $5.00"
Steps to reproduce?
Go to...
Click on...
See error...
VersionsAndroid Studio version: Android Studio Chipmunk | 2021.2.1 Patch 2
API version of the emulator: None
Additional informationInclude screenshots if they would be useful in clarifying the problem.
URL of codelab https://developer.android.com/codelabs/android-basics-kotlin-test-viewmodel-and-livedata?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-kotlin-unit-3-pathway-4%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fandroid-basics-kotlin-test-viewmodel-and-livedata#5
In which task and step of the codelab can this issue be found? Step 6
Describe the problem @Test fun price_twelve_cupcakes() { val viewModel = OrderViewModel() viewModel.price.observeForever {} viewModel.setQuantity(12) assertEquals("$27.00", viewModel.price.value) }
expected:<$27.00> but was:
Expected :$27.00
Actual :null
viewModel.price.value always returns null value. However, this textview still displays correct price. TextView android:id="@+id/total" style="@style/Widget.Cupcake.TextView.FinalPrice" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="end" android:layout_marginTop="@dimen/side_margin" android:text="@{@string/subtotal_price(viewModel.price)}" tools:text="Total $5.00" Steps to reproduce?
Versions Android Studio version: Android Studio Chipmunk | 2021.2.1 Patch 2 API version of the emulator: None
Additional information Include screenshots if they would be useful in clarifying the problem.