Allow setting `unhandled_panic` behavior as option on `tokio::test`
xortive opened this issue · comments
Is your feature request related to a problem? Please describe.
I have several unit tests that run some handler code that is under test in a tokio::spawn
ed task, and sends/receives bytes to/from that handler code from the main task. My AsyncRead + AsyncWrite mock will panic if it sees unexpected bytes, and if this happens in the background task the test will hang. I'd prefer the test to shut down in this scenario, and so I'm using the unhandled_panic
option introduced by #4516.
Describe the solution you'd like
#[tokio::test(unhandled_panic = ShutdownRuntime)
Describe alternatives you've considered
Currently I manually set up a tokio runtime for my tests that require this behavior.
I’m fine adding this feature.