Expected behavior for in-language tests

Hey guys, another day, another post.

With our beloved Rust SDK, I would be able to use expected panic behavior for my tests, i.e.

#[should_panic(expected = "MyExpectedError")

Now that I’m forced to use in-language tests, I couldn’t find something like that. Generally speaking, my issue with `#[test(should_revert)] is that I don’t really know what reverts, so it could be an unexpected bug. Is there anything like should_panic(expected = …) already and if not, will it come soon?

Thanks.

Best,
Maurice

Funny addition to the above: If I do use #[should_panic(expected = "MyExpectation")] my test would just ALWAYS successfully pass, regardless of whether it panics or not. There is neither an error nor a warning that this flag doesn’t do anything and if anybody would use this because it’s in the Rust SDK, this could seriously fuck up some tests.

1 Like

Hey there,

Thanks for the question. We have an open issue to track the exact thing you described here. I will get in touch internally to see if the blockers of the issue resolved.

1 Like

Thank you Kaya, sorry for my miss on this GH issue. Looking forward to the resolution :slight_smile:

Why are you being forced, though? :laughing:

There are scenarios where in-language testing gets the job done faster and scenarios where you’d need the SDK and a general-purpose language to test something properly.

Don’t get me wrong, I really like and appreciate the feature. I was just rolling with the sway-applications tests structure for contracts and then I tried to write library tests with a comparable structure and I couldn’t get it working. So I was “forced” to choose it, still going relatively smoothly for now :slight_smile:

2 Likes

Ah, that makes sense. Also super valuable that you’re testing this feature; the more stress tests the better so we can improve on it! :smile:

2 Likes