Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for failure messages on assertions #285

Open
Warwolt opened this issue Feb 6, 2022 · 0 comments
Open

Support for failure messages on assertions #285

Warwolt opened this issue Feb 6, 2022 · 0 comments

Comments

@Warwolt
Copy link

Warwolt commented Feb 6, 2022

I've used RapidCheck in a small project and enjoyed it so far, but I've found myself in cases where I want to run property assertions inside of a kind of parameterized test, but as far as I can tell RapidCheck seems to kind of assume there will only be one assertion per test case based on its reporting.

I made a wrapper macro that allows me to print a message on failed assertions, but the problem is that they repeat whenever RapidCheck shrinks the input and re-tests the properties, so you get the same message a bunch of times.

#define RC_ASSERT_MSG(condition, message) \
try { \
    RC_ASSERT(condition);\
}\
catch (const rc::detail::CaseResult& result) {\
    std::cout << message << std::endl; throw result;\
}

Would it be possible to add support to add an optional failure message directly to RapidCheck, so that it gets reported only when the entire test case has failed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant