GNOME Bugzilla – Bug 653386
Test framework does not support skipped tests?
Last modified: 2013-08-18 00:52:25 UTC
I can't seem to find any support in GTester for skipped tests. In my case, in harfbuzz, user has to have certain fonts to run certain tests. If the font is not available, I don't want to pass the test, and I don't want to fail...
you can just do something like if (!font_exits) return; in your test function, maybe ?
That would pass the test. Running a test suite, getting "100 out of 100 passed" while in reality none of the tests were run is less than ideal to say the least.
in Clutter's conformance test suite I have this macro: #define TEST_CONFORM_SKIP(CONDITION, NAMESPACE, FUNC) G_STMT_START { \ if (CONDITION) { \ g_test_add ("/skipped" NAMESPACE "/" #FUNC, \ TestConformSimpleFixture, \ shared_state, /* data argument for test */ \ test_conform_simple_fixture_setup, \ test_conform_skip_test, \ test_conform_simple_fixture_teardown); \ } else { TEST_CONFORM_SIMPLE (NAMESPACE, FUNC); } } G_STMT_END http://git.gnome.org/browse/clutter/tree/tests/conform/test-conform-main.c#n63 with test_conform_skip_test() being just an empty function. this guarantees that the final report still mentions the skipped test units, under the /skipped path. it could be good to have the same simple macro in GTest.
Thanks Emmanuele, moving them into /skipped/ is useful.
from an API standpoint, it might be interesting to have "regions" in the test suite; something like: /* creates a "skip" region in the test suite; all the test functions * added inside this region will be executed only if @condition * evaluates to %TRUE; if it evaluates to %FALSE, the tests will not * be executed, and the will be appended under @prefix. */ void g_test_push_skip_region (gboolean condition, const char *prefix); /* creates a "todo" region in the test suite; all test functions * added inside this region will be expected to fail . if they do * not fail, they will be appended under @prefix. in both cases, * they will not stop the execution of the test suite. */ void g_test_push_todo_region (const char *prefix); /* terminates the innermost region */ void g_test_pop_region (void);
I rather we just add g_test_skip().
I would happily accept a patch to add g_test_skip
cool, I'll have a go at it today, then.
I just added g_test_skip and g_test_incomplete