In CPPUnit, there's no built-in way to mark tests as "skipped" directly, as it doesn’t have native support for test skipping.
@Shahul Hameed statement is correct!
What you can try to do one way is that dynamically adding tests based on conditions.
class CustomTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(CustomTest);
CPPUNIT_TEST(test1);
CPPUNIT_TEST(test2);
CPPUNIT_TEST_SUITE_END();
public:
void test1() {
CPPUNIT_ASSERT(true);
}
void test2() {
CPPUNIT_ASSERT(true);
}
};
int main(int argc, char* argv[]) {
CppUnit::TextUi::TestRunner runner;
bool skipTests = false;
if (argc > 1 && std::string(argv[1]) == "--skip") {
skipTests = true;
}
if (!skipTests) {
runner.addTest(MyTest::suite());
} else {
std::cout << "Tests were skipped due to command line argument.\n";
}
runner.run();
return 0;
}