arkivanov/MVIKotlin

Null Pointer exceptions in log when running unit tests

dalewking opened this issue · 1 comments

We run unit tests in KMM on our stores which are using coroutines and when the test runs we see exceptions like this in the log:

java.lang.NullPointerException
	at com.arkivanov.mvikotlin.utils.internal.MainThreadAssert.getMainThreadId(MainThreadAssert.kt:9)
	at com.arkivanov.mvikotlin.utils.internal.MainThreadAssertKt.isMainThread(MainThreadAssert.kt:24)
	at com.arkivanov.mvikotlin.rx.internal.BaseSubject$1.invoke(BaseSubject.kt:13)
	at com.arkivanov.mvikotlin.rx.internal.BaseSubject$1.invoke(BaseSubject.kt:13)
	at com.arkivanov.mvikotlin.rx.internal.BaseSubject.subscribe(BaseSubject.kt:23)
	at com.arkivanov.mvikotlin.main.store.DefaultStore.labels(DefaultStore.kt:74)
	at com.arkivanov.mvikotlin.logging.store.LoggingStore.labels(LoggingStore.kt)

This does not actually cause the tests to fail, but is annoying seeing this noise in the logs. It fails because we are not actually running on an Android device so there is no main looper. You have the isAssertOnMainThreadEnabled variable to disable maint thread assertions but it doesn't disable this check in BaseSubject.

Thanks! This is just an error message in logs, should by only printed once. I will think if I can improve something here.