test-case icon indicating copy to clipboard operation
test-case copied to clipboard

Add with-assert-override

Open luke-biel opened this issue 2 years ago • 3 comments

Closes https://github.com/frondeus/test-case/issues/109 Closes https://github.com/frondeus/test-case/issues/84

luke-biel avatar Dec 14 '22 19:12 luke-biel

Yeah, it's clunky, however there's no better way without providing custom test harness. So far we can consider crate level, module level and test level configurations. Crate level require something that can be guaranteed in static context, and this is best solution I could think of. Module level would require to have written custom macro with module harness, and this is way to big of a task to do it now. For test level I've already shown few workarounds with using, with or simply doing assertion comparison by yourself.

As for assert being present - as I mentioned, we need something generic over different possible assertion crates. It's optional to override assert, as shown in tests.

luke-biel avatar Dec 31 '22 13:12 luke-biel

crate level would certainly be most user-friendly, with a possible module-level override option (not my use case, but I imagine this being useful).

vriesk avatar Jan 02 '23 20:01 vriesk

I'm gonna fix tests in this and push it then.

I'd really avoid feature flags, as they tend to break when workspaces are at play, plus it would anyway introduce dependency on pretty-assertions, one that shouldn't break easily, but I had enough bad experience with insta and broken transitive deps to avoid depending on other crates at all cost. I don't really see a better option without using nightly or forcing a custom test harness. Maybe in the future I can replace this once something new shows up in rust. For time being unfortunately it has to be lib.rs level macro.

luke-biel avatar Jan 03 '23 09:01 luke-biel