Skip to content

Tests with fixtures don't handle should_panic expectation messages #15

@asomers

Description

@asomers

Tests without fixtures work as expected with #[should_panic]. However, tests with fixtures don't. Using an expected message as in #[should_panic(expected = "whatever") doesn't work. The test will always fail, even if the panic message was correct. This diff demonstrates the problem

diff --git a/tests/test_suite.rs b/tests/test_suite.rs
index d0ca37e..5d54bd3 100644
--- a/tests/test_suite.rs
+++ b/tests/test_suite.rs
@@ -30,6 +30,11 @@ test_suite! {
     test simple_test() {
         assert!(true);
     }
+
+    #[should_panic(expected = "xxx")]
+    test panic_test() {
+        panic!("xxx");
+    }
 }
 
 test_suite! {
@@ -44,6 +49,11 @@ test_suite! {
     test inject_fixture(test_fixture) {
         assert_eq!(test_fixture.val, 42);
     }
+
+    #[should_panic(expected = "xxx")]
+    test panic_test(test_fixture) {
+        panic!("xxx");
+    }
 }
 
 test_suite! {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions