Adrien BĂ©raud | efe2737 | 2023-05-27 18:56:29 -0400 | [diff] [blame] | 1 | #include <iostream> |
| 2 | |
| 3 | #include <cppunit/extensions/TestFactoryRegistry.h> |
| 4 | #include <cppunit/ui/text/TestRunner.h> |
| 5 | #include <cppunit/CompilerOutputter.h> |
| 6 | |
| 7 | // This version of the test runner is similar to RING_TEST_RUNNER but |
| 8 | // can take multiple unit tests. |
| 9 | // It's practical to run a test for diffrent configs, for instance when |
| 10 | // running the same test for both Jami and SIP accounts. |
| 11 | |
| 12 | // The test will abort if a test fails. |
| 13 | #define JAMI_TEST_RUNNER(...) \ |
| 14 | int main() \ |
| 15 | { \ |
| 16 | std::vector<std::string> suite_names {__VA_ARGS__}; \ |
| 17 | for (const std::string& name : suite_names) { \ |
| 18 | CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry( \ |
| 19 | name); \ |
| 20 | CppUnit::Test* suite = registry.makeTest(); \ |
| 21 | if (suite->countTestCases() == 0) { \ |
| 22 | std::cout << "No test cases specified for suite \"" << name << "\"\n"; \ |
| 23 | continue; \ |
| 24 | } \ |
| 25 | CppUnit::TextUi::TestRunner runner; \ |
| 26 | runner.addTest(suite); \ |
| 27 | if (not runner.run()) \ |
| 28 | return 1; \ |
| 29 | } \ |
| 30 | return 0; \ |
| 31 | } |