bitwizeshift / oxtest

🚧 A WIP rust unit-testing library
https://bitwizeshift.github.io/neotest
Apache License 2.0
0 stars 0 forks source link

Support `should_panic` in main tests #15

Open bitwizeshift opened 1 year ago

bitwizeshift commented 1 year ago

Adding support for returning TestResult objects in #6 introduced an unexpected bug: the #[should_panic] attribute no longer functions correctly. #[should_panic] apparently only works in functions returning (), which raises questions as to the future direction of testing in this library:

  1. Should an assertion library be made that returns Error objects as #7 suggests? Doing this would mean that #[should_panic] tests cannot actually work with these assertions

  2. A custom assert_panic!(...) macro can be added that is implemented in terms of std::panic::handle_unwind -- however this is documented to only work for panics that perform unwinding. It's unclear if this is also the behavior of #[should_panic], or whether #[should_panic] can actually catch cases that abort.

A decision needs to be made in order to progress here. It's possible that supporting attributes in subtests in #14 might be sufficient for handling this, in that subtests can return () whereas other tests return Error.