Skip to content

Catch Throwable in LogcatWriter, for unit tests#476

Open
angusholder wants to merge 1 commit intotouchlab:mainfrom
angusholder:logcatwriter-unit-test-catch
Open

Catch Throwable in LogcatWriter, for unit tests#476
angusholder wants to merge 1 commit intotouchlab:mainfrom
angusholder:logcatwriter-unit-test-catch

Conversation

@angusholder
Copy link
Copy Markdown

To address #475

Is it okay with you to broaden the catch to Throwable, or would you rather I add a second catch block for just UnsatisfiedLinkError?

@samhill303 samhill303 requested a review from faogustavo March 31, 2026 19:43
Copy link
Copy Markdown
Contributor

@faogustavo faogustavo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. I'm approving it and running the tests.

I'd only like to encourage the use of the 'TestLogWriter' in test cases, which is the appropriate writer for tests. But that's a minor detail, the fix is still relevant :)

@angusholder
Copy link
Copy Markdown
Author

Thanks!

TestLogWriter looks useful, although here I wasn't interested in testing the log output - all this code under test uses the default global Logger.Companion, so it was getting platformLogWriter -> LogcatWriter, and crashing.

I don't know of any way to configure the logger globally before the junit4 tests run, short of adding a test rule to every test, so that's why it's running with the default writer. I don't inject my loggers in most code currently, because I'm switching from Timber which doesn't really give you that option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants