-
-
Notifications
You must be signed in to change notification settings - Fork 641
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
Skip subcase #304
Comments
You could do that using the Let me know if this helps :) |
Very helpful! I'll probably set up something like this to have consistency and brevity for all three:
(Something like that could make a good default filter. From a user perspective, it would make test code a tad cleaner than Thanks for the tip! |
I have similar needs, but I would like to skip subcase conditionally based on the result of previous subcase(s). More specifically, I have a static variable in a WHEN section that contains 2 THEN sections. When first THEN passes at the last statement is sets data to the static variable. The following THEN section should only run if that variable is set. The first idea that came to my mind was like THEN("name" * doctest::skip(!!staticVar)) but decorators only work with TEST_CASE but not with subcases. In my case I test serialization/deserialization pair of method. So if serialization fails then there is no sence to test deserialization. Also I uses output made by serialization as input for deserialization. I understand it is not easy to pass data from one subcase to another so static variable is ok for me as a workaround. Sure I can add simple check of static variable inside the second THEN and just return if it is not set, but I would like that the subcases isn't run instead to not polute/lie in output about success of the second THEN subcase. |
I've try to do SUBCASE("My test" * doctest::skip(true)) thinking it will work but it doesn't, could be great if it could work. |
Description
This is a question and possible feature request.
Is it possible to skip subcases?
From the docs, it appears that only TEST_SUIT and TEST_CASE can be skipped. https://github.com/onqtam/doctest/blob/master/doc/markdown/testcases.md#decorators
The use case for this is the ability to skip the smallest unit of test, as opposed to needing to skip a TEST_CASE which may contain multiple SUBCASE's.
Extra information
The text was updated successfully, but these errors were encountered: