google-developer-training / android-basics-kotlin-cupcake-app

Apache License 2.0
103 stars 163 forks source link

Test ViewModels and LiveData #81

Closed hebamahdy closed 10 months ago

hebamahdy commented 1 year ago

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#0

In which task and step of the codelab can this issue be found?

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 Describe the problem

you should set date before test the price

@Test fun price_twelve_cupcakes() { val viewModel = OrderViewModel() viewModel.price.observeForever {} viewModel.setQuantity(12) viewModel.date.observeForever{} viewModel.setDate( viewModel.getPickupOptions()[0]) assertEquals("$27.00", viewModel.price.value) } Steps to reproduce?

  1. Go to...
  2. Click on...
  3. See error...

Versions Android Studio version: API version of the emulator:

Additional information Include screenshots if they would be useful in clarifying the problem.