Skip to content

Instantly share code, notes, and snippets.

@JoseAlcerreca
Last active September 2, 2019 15:59
Show Gist options
  • Save JoseAlcerreca/387714aa9e04ac840b235cbaba6746bd to your computer and use it in GitHub Desktop.
Save JoseAlcerreca/387714aa9e04ac840b235cbaba6746bd to your computer and use it in GitHub Desktop.
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
@Test
fun isLiveDataEmitting_observeForever() {
viewModel.setNewValue("foo")
// This works but can be improved.
viewModel.liveData2.observeForever { }
// Passes because it's not a result of a Transformation:
assertEquals(viewModel.liveData1.value, "foo")
// Passes because now it's being observed:
assertEquals(viewModel.liveData2.value, "FOO")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment