LukeMathWalker / wiremock-rs

HTTP mocking to test Rust applications.
Apache License 2.0
620 stars 70 forks source link

Avoid causing an abort in a failing test #14

Closed LukeMathWalker closed 4 years ago

LukeMathWalker commented 4 years ago

Our current setup checks all assertions against defined Mocks when a MockServer instance is being dropped. If a test is panicking for unrelated reason (e.g. a test assertion failed) it is possible (and sometimes quite likely) that assertions won't be satisfied either, hence when Drop is called on the MockServer while unwinding the stack another panic takes place and the whole process is aborted.

This is undesirable for several reasons:

We should leverage panicking and avoid panicking if the current thread is panicking, limiting ourselves to printing/logging the failure.