Skip to content

Instantly share code, notes, and snippets.

@jfresen
Last active October 2, 2024 15:50
Show Gist options
  • Select an option

  • Save jfresen/44f3838fbd00e3c4342c7be4c9a4e6f7 to your computer and use it in GitHub Desktop.

Select an option

Save jfresen/44f3838fbd00e3c4342c7be4c9a4e6f7 to your computer and use it in GitHub Desktop.
Logs all state changes so you can find out what causes a self-invalidating loop in your app in case you keep running into timeouts in your tests
private var I = 0 // disable logcat duplication filtering
private var unregisterApplyObserver: ObserverHandle? = null
@Before
fun setup() {
unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot ->
Log.i("TEST_TAG", "[${I++}] applying snapshot")
for (obj in mutatedObjects) {
Log.d("TEST_TAG", "[${I++}] state $obj modified")
}
}
}
@After
fun tearDown() {
unregisterApplyObserver?.dispose()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment