❓ 🔴 🧪 Compose Testing : How do I test if the exception is thrown or not? See more details in the SO thread
z
Zach Klippenstein (he/him) [MOD]
09/14/2021, 5:41 AM
I’m not sure if there’s a non-hacky way to do this, but stepping back: why do you need to test that an exception is thrown from a click handler? If your click action performs some action that can fail, just write a test for that failure case without involving the view layer.
t
theapache64
09/14/2021, 5:44 AM
@Zach Klippenstein (he/him) [MOD] this is a simplified version of a complex scenario. basically, whatever error we throw, doesn’t get caught in the instrumentation test
z
Zach Klippenstein (he/him) [MOD]
09/14/2021, 5:52 AM
That seems like an odd thing to test to me. Typically a UI test will check for error handling by checking for some sort of error message or other special state displayed in the UI, not looking for individual exceptions.
t
theapache64
09/14/2021, 6:56 AM
Sounds fare 🤔 I think I need to remove this exception test from UI test.
theapache64
09/14/2021, 6:57 AM
I’m not sure if there’s a non-hacky way to do this
the`ExpectedException` way works, but the
none()
method of it is deprecated. The recommended method is to use