[{"data":1,"prerenderedAt":788},["ShallowReactive",2],{"doc-skipping-passing-failing":3},{"id":4,"title":5,"body":6,"description":94,"extension":780,"meta":781,"navigation":369,"path":782,"seo":783,"slug":784,"source":785,"stem":786,"__hash__":787},"docs\u002Fdocs\u002Fskipping-passing-failing.md","Explicitly skipping, passing, and failing tests at runtime",{"type":7,"value":8,"toc":772},"minimark",[9,50,54,59,70,73,85,95,98,181,196,209,264,274,317,323,400,405,413,573,584,593,601,607,613,617,620,629,639,651,709,716,723,730,768],[10,11,12],"blockquote",{},[13,14,15,19,20,24,25,28,29,32,33,36,37,36,40,43,44,49],"p",{},[16,17,18],"strong",{},"Catch3 compatibility reference:"," This page describes the test-writing API Catch3 shares with Catch2: the macros, such as ",[21,22,23],"code",{},"TEST_CASE"," and ",[21,26,27],{},"REQUIRE",", and the ",[21,30,31],{},"Catch::"," namespace keep Catch2's names. Headers and build names are Catch3's own (",[21,34,35],{},"\u003CProgmasoft\u002FCatch3\u002FTestMacros.hpp>",", ",[21,38,39],{},"find_package(Catch3)",[21,41,42],{},"Catch3::Catch3WithMain","). See ",[45,46,48],"a",{"href":47},"\u002Fdocs\u002Fprogmasoft-catch3\u002F","Catch3 additions"," for Progmasoft APIs.",[51,52,5],"h1",{"id":53},"explicitly-skipping-passing-and-failing-tests-at-runtime",[55,56,58],"h2",{"id":57},"skipping-test-cases-at-runtime","Skipping Test Cases at Runtime",[10,60,61],{},[13,62,63,69],{},[45,64,68],{"href":65,"rel":66},"https:\u002F\u002Fgithub.com\u002Fcatchorg\u002FCatch2\u002Fpull\u002F2360",[67],"nofollow","Introduced"," in Catch2 3.3.0.",[13,71,72],{},"In some situations it may not be possible to meaningfully execute a test case,\nfor example when the system under test is missing certain hardware capabilities.\nIf the required conditions can only be determined at runtime, it often\ndoesn't make sense to consider such a test case as either passed or failed,\nbecause it simply cannot run at all.",[13,74,75,76,80,81,84],{},"To properly express such scenarios, Catch2 provides a way to explicitly\n",[77,78,79],"em",{},"skip"," test cases, using the ",[21,82,83],{},"SKIP"," macro:",[86,87,92],"pre",{"className":88,"code":90,"language":91},[89],"language-text","SKIP( [streamable expression] )\n","text",[21,93,90],{"__ignoreMap":94},"",[13,96,97],{},"Example usage:",[86,99,103],{"className":100,"code":101,"language":102,"meta":94,"style":94},"language-c++ shiki shiki-themes github-dark","TEST_CASE(\"copy files between drives\") {\n    if(getNumberOfHardDrives() \u003C 2) {\n        SKIP(\"at least two hard drives required\");\n    }\n    \u002F\u002F ...\n}\n","c++",[21,104,105,124,148,162,168,175],{"__ignoreMap":94},[106,107,110,113,117,121],"span",{"class":108,"line":109},"line",1,[106,111,23],{"class":112},"svObZ",[106,114,116],{"class":115},"s95oV","(",[106,118,120],{"class":119},"sU2Wk","\"copy files between drives\"",[106,122,123],{"class":115},") {\n",[106,125,127,131,133,136,139,142,146],{"class":108,"line":126},2,[106,128,130],{"class":129},"snl16","    if",[106,132,116],{"class":115},[106,134,135],{"class":112},"getNumberOfHardDrives",[106,137,138],{"class":115},"() ",[106,140,141],{"class":129},"\u003C",[106,143,145],{"class":144},"sDLfK"," 2",[106,147,123],{"class":115},[106,149,151,154,156,159],{"class":108,"line":150},3,[106,152,153],{"class":112},"        SKIP",[106,155,116],{"class":115},[106,157,158],{"class":119},"\"at least two hard drives required\"",[106,160,161],{"class":115},");\n",[106,163,165],{"class":108,"line":164},4,[106,166,167],{"class":115},"    }\n",[106,169,171],{"class":108,"line":170},5,[106,172,174],{"class":173},"sAwPA","    \u002F\u002F ...\n",[106,176,178],{"class":108,"line":177},6,[106,179,180],{"class":115},"}\n",[13,182,183,184,187,188,191,192,195],{},"This test case is then reported as ",[77,185,186],{},"skipped"," instead of ",[77,189,190],{},"passed"," or ",[77,193,194],{},"failed",".",[13,197,198,199,201,202,208],{},"The ",[21,200,83],{}," macro behaves similarly to an explicit ",[45,203,205],{"href":204},"#passing-and-failing-test-cases",[21,206,207],{},"FAIL",",\nin that it is the last expression that will be executed:",[86,210,212],{"className":100,"code":211,"language":102,"meta":94,"style":94},"TEST_CASE(\"my test\") {\n    printf(\"foo\");\n    SKIP();\n    printf(\"bar\"); \u002F\u002F not printed\n}\n",[21,213,214,225,237,245,260],{"__ignoreMap":94},[106,215,216,218,220,223],{"class":108,"line":109},[106,217,23],{"class":112},[106,219,116],{"class":115},[106,221,222],{"class":119},"\"my test\"",[106,224,123],{"class":115},[106,226,227,230,232,235],{"class":108,"line":126},[106,228,229],{"class":112},"    printf",[106,231,116],{"class":115},[106,233,234],{"class":119},"\"foo\"",[106,236,161],{"class":115},[106,238,239,242],{"class":108,"line":150},[106,240,241],{"class":112},"    SKIP",[106,243,244],{"class":115},"();\n",[106,246,247,249,251,254,257],{"class":108,"line":164},[106,248,229],{"class":112},[106,250,116],{"class":115},[106,252,253],{"class":119},"\"bar\"",[106,255,256],{"class":115},");",[106,258,259],{"class":173}," \u002F\u002F not printed\n",[106,261,262],{"class":108,"line":170},[106,263,180],{"class":115},[13,265,266,267,270,271,273],{},"However a failed assertion ",[77,268,269],{},"before"," a ",[21,272,83],{}," still causes the entire\ntest case to fail:",[86,275,277],{"className":100,"code":276,"language":102,"meta":94,"style":94},"TEST_CASE(\"failing test\") {\n    CHECK(1 == 2);\n    SKIP();\n}\n",[21,278,279,290,307,313],{"__ignoreMap":94},[106,280,281,283,285,288],{"class":108,"line":109},[106,282,23],{"class":112},[106,284,116],{"class":115},[106,286,287],{"class":119},"\"failing test\"",[106,289,123],{"class":115},[106,291,292,295,297,300,303,305],{"class":108,"line":126},[106,293,294],{"class":112},"    CHECK",[106,296,116],{"class":115},[106,298,299],{"class":144},"1",[106,301,302],{"class":129}," ==",[106,304,145],{"class":144},[106,306,161],{"class":115},[106,308,309,311],{"class":108,"line":150},[106,310,241],{"class":112},[106,312,244],{"class":115},[106,314,315],{"class":108,"line":164},[106,316,180],{"class":115},[13,318,319,320,322],{},"Same applies for a ",[21,321,83],{}," nested inside an assertion:",[86,324,328],{"className":325,"code":326,"language":327,"meta":94,"style":94},"language-cpp shiki shiki-themes github-dark","static bool do_skip() {\n    SKIP();\n    return true;\n}\n\nTEST_CASE(\"Another failing test\") {\n    CHECK(do_skip());\n}\n","cpp",[21,329,330,344,350,361,365,371,382,395],{"__ignoreMap":94},[106,331,332,335,338,341],{"class":108,"line":109},[106,333,334],{"class":129},"static",[106,336,337],{"class":129}," bool",[106,339,340],{"class":112}," do_skip",[106,342,343],{"class":115},"() {\n",[106,345,346,348],{"class":108,"line":126},[106,347,241],{"class":112},[106,349,244],{"class":115},[106,351,352,355,358],{"class":108,"line":150},[106,353,354],{"class":129},"    return",[106,356,357],{"class":144}," true",[106,359,360],{"class":115},";\n",[106,362,363],{"class":108,"line":164},[106,364,180],{"class":115},[106,366,367],{"class":108,"line":170},[106,368,370],{"emptyLinePlaceholder":369},true,"\n",[106,372,373,375,377,380],{"class":108,"line":177},[106,374,23],{"class":112},[106,376,116],{"class":115},[106,378,379],{"class":119},"\"Another failing test\"",[106,381,123],{"class":115},[106,383,385,387,389,392],{"class":108,"line":384},7,[106,386,294],{"class":112},[106,388,116],{"class":115},[106,390,391],{"class":112},"do_skip",[106,393,394],{"class":115},"());\n",[106,396,398],{"class":108,"line":397},8,[106,399,180],{"class":115},[401,402,404],"h3",{"id":403},"interaction-with-sections-and-generators","Interaction with Sections and Generators",[13,406,407,408,412],{},"Sections, nested sections as well as specific outputs from ",[45,409,411],{"href":410},"\u002Fdocs\u002Fgenerators\u002F","generators","\ncan all be individually skipped, with the rest executing as usual:",[86,414,416],{"className":100,"code":415,"language":102,"meta":94,"style":94},"TEST_CASE(\"complex test case\") {\n  int value = GENERATE(2, 4, 6);\n  SECTION(\"a\") {\n    SECTION(\"a1\") { CHECK(value \u003C 8); }\n    SECTION(\"a2\") {\n      if (value == 4) {\n        SKIP();\n      }\n      CHECK(value % 2 == 0);\n    }\n  }\n}\n",[21,417,418,429,460,472,499,510,526,532,537,557,562,568],{"__ignoreMap":94},[106,419,420,422,424,427],{"class":108,"line":109},[106,421,23],{"class":112},[106,423,116],{"class":115},[106,425,426],{"class":119},"\"complex test case\"",[106,428,123],{"class":115},[106,430,431,434,437,440,443,445,448,450,453,455,458],{"class":108,"line":126},[106,432,433],{"class":129},"  int",[106,435,436],{"class":115}," value ",[106,438,439],{"class":129},"=",[106,441,442],{"class":112}," GENERATE",[106,444,116],{"class":115},[106,446,447],{"class":144},"2",[106,449,36],{"class":115},[106,451,452],{"class":144},"4",[106,454,36],{"class":115},[106,456,457],{"class":144},"6",[106,459,161],{"class":115},[106,461,462,465,467,470],{"class":108,"line":150},[106,463,464],{"class":112},"  SECTION",[106,466,116],{"class":115},[106,468,469],{"class":119},"\"a\"",[106,471,123],{"class":115},[106,473,474,477,479,482,485,488,491,493,496],{"class":108,"line":164},[106,475,476],{"class":112},"    SECTION",[106,478,116],{"class":115},[106,480,481],{"class":119},"\"a1\"",[106,483,484],{"class":115},") { ",[106,486,487],{"class":112},"CHECK",[106,489,490],{"class":115},"(value ",[106,492,141],{"class":129},[106,494,495],{"class":144}," 8",[106,497,498],{"class":115},"); }\n",[106,500,501,503,505,508],{"class":108,"line":170},[106,502,476],{"class":112},[106,504,116],{"class":115},[106,506,507],{"class":119},"\"a2\"",[106,509,123],{"class":115},[106,511,512,515,518,521,524],{"class":108,"line":177},[106,513,514],{"class":129},"      if",[106,516,517],{"class":115}," (value ",[106,519,520],{"class":129},"==",[106,522,523],{"class":144}," 4",[106,525,123],{"class":115},[106,527,528,530],{"class":108,"line":384},[106,529,153],{"class":112},[106,531,244],{"class":115},[106,533,534],{"class":108,"line":397},[106,535,536],{"class":115},"      }\n",[106,538,540,543,545,548,550,552,555],{"class":108,"line":539},9,[106,541,542],{"class":112},"      CHECK",[106,544,490],{"class":115},[106,546,547],{"class":129},"%",[106,549,145],{"class":144},[106,551,302],{"class":129},[106,553,554],{"class":144}," 0",[106,556,161],{"class":115},[106,558,560],{"class":108,"line":559},10,[106,561,167],{"class":115},[106,563,565],{"class":108,"line":564},11,[106,566,567],{"class":115},"  }\n",[106,569,571],{"class":108,"line":570},12,[106,572,180],{"class":115},[13,574,575,576,579,580,583],{},"This test case will report 5 passing assertions; one for each of the three\nvalues in section ",[21,577,578],{},"a1",", and then two in section ",[21,581,582],{},"a2",", from values 2 and 6.",[13,585,586,587,589,590,592],{},"Note that as soon as one section is skipped, the entire test case will\nbe reported as ",[77,588,186],{}," (unless there is a failing assertion, in which\ncase the test is handled as ",[77,591,194],{}," instead).",[13,594,595,596,600],{},"Note that if all test cases in a run are skipped, Catch2 returns a non-zero\nexit code, same as it does if no test cases have run. This behaviour can\nbe overridden using the ",[45,597,599],{"href":598},"\u002Fdocs\u002Fcommand-line\u002F#how-tests-behave","--allow-no-tests","\nflag.",[401,602,604,606],{"id":603},"skip-inside-generators",[21,605,83],{}," inside generators",[13,608,609,610,612],{},"You can also use the ",[21,611,83],{}," macro inside generator's constructor to handle\ncases where the generator is empty, but you do not want to fail the test\ncase.",[55,614,616],{"id":615},"passing-and-failing-test-cases","Passing and failing test cases",[13,618,619],{},"Test cases can also be explicitly passed or failed, without the use of\nassertions, and with a specific message. This can be useful to handle\ncomplex preconditions\u002Fpostconditions and give useful error messages\nwhen they fail.",[621,622,623],"ul",{},[624,625,626],"li",{},[21,627,628],{},"SUCCEED( [streamable expression] )",[13,630,631,634,635,638],{},[21,632,633],{},"SUCCEED"," is morally equivalent with ",[21,636,637],{},"INFO( [streamable expression] ); REQUIRE( true );",".\nNote that it does not stop further test execution, so it cannot be used\nto guard failing assertions from being executed.",[13,640,641],{},[77,642,643,644,646,647,195],{},"In practice, ",[21,645,633],{}," is usually used as a test placeholder, to avoid\n",[45,648,650],{"href":649},"\u002Fdocs\u002Fcommand-line\u002F#warnings","failing a test case due to missing assertions",[86,652,654],{"className":325,"code":653,"language":327,"meta":94,"style":94},"TEST_CASE( \"SUCCEED showcase\" ) {\n    int I = 1;\n    SUCCEED( \"I is \" \u003C\u003C I );\n    \u002F\u002F ... execution continues here ...\n}\n",[21,655,656,669,684,700,705],{"__ignoreMap":94},[106,657,658,660,663,666],{"class":108,"line":109},[106,659,23],{"class":112},[106,661,662],{"class":115},"( ",[106,664,665],{"class":119},"\"SUCCEED showcase\"",[106,667,668],{"class":115}," ) {\n",[106,670,671,674,677,679,682],{"class":108,"line":126},[106,672,673],{"class":129},"    int",[106,675,676],{"class":115}," I ",[106,678,439],{"class":129},[106,680,681],{"class":144}," 1",[106,683,360],{"class":115},[106,685,686,689,691,694,697],{"class":108,"line":150},[106,687,688],{"class":112},"    SUCCEED",[106,690,662],{"class":115},[106,692,693],{"class":119},"\"I is \"",[106,695,696],{"class":129}," \u003C\u003C",[106,698,699],{"class":115}," I );\n",[106,701,702],{"class":108,"line":164},[106,703,704],{"class":173},"    \u002F\u002F ... execution continues here ...\n",[106,706,707],{"class":108,"line":170},[106,708,180],{"class":115},[621,710,711],{},[624,712,713],{},[21,714,715],{},"FAIL( [streamable expression] )",[13,717,718,634,720,195],{},[21,719,207],{},[21,721,722],{},"INFO( [streamable expression] ); REQUIRE( false );",[13,724,725],{},[77,726,643,727,729],{},[21,728,207],{}," is usually used to stop executing test that is currently\nknown to be broken, but has to be fixed later.",[86,731,733],{"className":325,"code":732,"language":327,"meta":94,"style":94},"TEST_CASE( \"FAIL showcase\" ) {\n    FAIL( \"This test case causes segfault, which breaks CI.\" );\n    \u002F\u002F ... this will not be executed ...\n}\n",[21,734,735,746,759,764],{"__ignoreMap":94},[106,736,737,739,741,744],{"class":108,"line":109},[106,738,23],{"class":112},[106,740,662],{"class":115},[106,742,743],{"class":119},"\"FAIL showcase\"",[106,745,668],{"class":115},[106,747,748,751,753,756],{"class":108,"line":126},[106,749,750],{"class":112},"    FAIL",[106,752,662],{"class":115},[106,754,755],{"class":119},"\"This test case causes segfault, which breaks CI.\"",[106,757,758],{"class":115}," );\n",[106,760,761],{"class":108,"line":150},[106,762,763],{"class":173},"    \u002F\u002F ... this will not be executed ...\n",[106,765,766],{"class":108,"line":164},[106,767,180],{"class":115},[769,770,771],"style",{},"html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":94,"searchDepth":126,"depth":126,"links":773},[774,779],{"id":57,"depth":126,"text":58,"children":775},[776,777],{"id":403,"depth":150,"text":404},{"id":603,"depth":150,"text":778},"SKIP inside generators",{"id":615,"depth":126,"text":616},"md",{},"\u002Fdocs\u002Fskipping-passing-failing",{"title":5,"description":94},"skipping-passing-failing","docs\u002Fskipping-passing-failing.md","docs\u002Fskipping-passing-failing","8fh2ujXqr9zQqg49hmg6kpgn2MMdamtAfJz5xg788bQ",1794961595397]