-
-
Notifications
You must be signed in to change notification settings - Fork 620
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
Optional (auto-generated) test case names #802
Comments
Unfortunately #define DOCTEST_TO_STRING0(x) #x
#define DOCTEST_TO_STRING(x) DOCTEST_TO_STRING0(x)
#ifdef __COUNTER__
#define DOCTEST_UNIQUE_NAME() DOCTEST_TO_STRING(__COUNTER__)
#else
#define DOCTEST_UNIQUE_NAME() DOCTEST_TO_STRING(__LINE__)
#endif /* __COUNTER__ */
#define UNIQUE_NAME DOCTEST_UNIQUE_NAME ...with its usage being along the lines of... SCENARIO(UNIQUE_NAME()) { /* Hacking... */ }
SCENARIO(UNIQUE_NAME() * doctest::may_fail) /* Hacking, but it might be a bit flaky for now... */ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Lowering the barrier to writing test cases even further (especially for the initial stages of (or small) projects, which is exactly where writing tests is often "postponed", even though simple, quick early smoke testing could save a lot of wasted effort) conflicts with the need for coming up with nice, unique, descriptive case names (especially when they are already thematically grouped in some test runner file), which could be a hindrance.
It would be nice to start with no name, and then add one later, as things (like terminology) take shape (and if the test case actually turns out to be kept at all, which is often not what happens).
E.g. for compilers, which support
__COUNTER__
(i.e. all?), this is what I've done:(Failure reports still include line numbers, so identifying nameless cases is not really a problem, especially if you have IDE support for locating the offending lines. And if you land there, you might then actually add a name, if you feel like. The point is you are not forced to.)
(BTW, that "conformant checking" placeholder in the code is not for
__COUNTER__
-- that's still not standardized, unfortunately, but for__VA_OPT__
, which is standardized, but the default (i.e. legacy) MSVC preprocessor merrily ignores even with-std:c++infinity
. (-Zc:preprocessor
enables their conformant version, in case anyone was wondering.))The text was updated successfully, but these errors were encountered: