Closed dalewking closed 1 year ago
The root of the problem (and with #35) is that this code does not honor isAssertOnMainThreadEnabled
Thanks for raising. When running vanilla JUnit tests, accessing Android classes throws "java.lang.RuntimeException: Method isLoggable in android.util.Log not mocked". This error is caught here and further checks are disabled. For some reason Paparazzi throws UnsatisfiedLinkError
which is an Error
and is not currently caught. We should catch Throwable
instead.
The method you are referring to (isMainThread
) should not honor isAssertOnMainThreadEnabled
, because that flag only affects main thread asserts, not checks. This check should go away eventually when the support of the old K/N memory model will be removed. Currently, we should perform this check only on K/N and only under the old memory model.
I will fix that.
Actually you are correct. It's better to not check for the main thread if asserts are disabled.
I am trying to add Paparazzi snapshot testing. When the paparazzi plugin is applied I get failures when it tries to create a LoggingStore. I do not get the failure when Paparazzi plugin is not applied and isAssertOnMainThreadEnabled = false does not fix it either.
It seems to be that a failure trying to log should not cause an exception so adding a try catch might be a good idea
Note also a previous issue I reported regarding the check for main thread #35