{"id":13339540,"url":"https://github.com/e-j/qt-multiple-tests","last_synced_at":"2025-03-11T14:31:45.568Z","repository":{"id":31472287,"uuid":"35036344","full_name":"e-j/qt-multiple-tests","owner":"e-j","description":"Simple extension for the Qt Test library that allow running multiple tests cases in one application","archived":false,"fork":false,"pushed_at":"2018-05-30T21:40:52.000Z","size":57,"stargazers_count":11,"open_issues_count":3,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-07-30T20:58:24.318Z","etag":null,"topics":["c-plus-plus","qt4","qt5","qtest","qtestlib","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/e-j.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-04T13:28:56.000Z","updated_at":"2022-08-14T08:59:35.000Z","dependencies_parsed_at":"2022-09-17T12:01:54.999Z","dependency_job_id":null,"html_url":"https://github.com/e-j/qt-multiple-tests","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-j%2Fqt-multiple-tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-j%2Fqt-multiple-tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-j%2Fqt-multiple-tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-j%2Fqt-multiple-tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/e-j","download_url":"https://codeload.github.com/e-j/qt-multiple-tests/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221232948,"owners_count":16781662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","qt4","qt5","qtest","qtestlib","unit-testing"],"created_at":"2024-07-29T19:20:21.664Z","updated_at":"2024-10-23T20:30:31.329Z","avatar_url":"https://github.com/e-j.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Qt Multiple tests [![Build Status](https://travis-ci.org/e-j/qt-multiple-tests.svg?branch=master)](https://travis-ci.org/e-j/qt-multiple-tests)\n\n## Purpose\n\nThe [Qt Test library](http://doc.qt.io/qt-5/qtest-overview.html), as based on a lightweight philosophy, don't provide any facilities for run multiple tests cases in a single application. But that's can be a very useful feature for medium size applications.\n\n**Qt Multiple tests** provide an easy solution : include an additionnal header and you are able to create several tests cases in your test suite. A single binary will allow to run one or all test cases. Reporting and re-run test is simplified. Parsing unit tests results will be simplified for external tools (IDE, continuous integration)\n\n**Qt Multiple tests** is a rework on a original example provided by Rob Caldecott in his two of his posts : [Running Multiple Unit Tests ](http://qtcreator.blogspot.fr/2009/10/running-multiple-unit-tests.html) and [Sample Multiple Unit Test Project ](http://qtcreator.blogspot.fr/2010/04/sample-multiple-unit-test-project.html).\n\n## Features\n\n* Simplicity of use : just include the header [`MultiTests.hh`](MultiTests.hh) to your project\n* Choose to run all or a selection of the test case : option `-case \u003ccasename\u003e`\n* List all tests functions from a case (or all cases) : option `-functions`\n* Summary of tests results in verbose output\n* Support some Qt Test runner options. For example you can have XML report\n* Qt4 / Qt5 compatibility\n* For Qt4 : Provide the exception thrown test (as exists in Qt5)\n\n## Requirements\n* A Qt application in QTest mode\n    - For Qt4 : `CONFIG += qtestlib`\n    - For Qt5 : `QT += testlib widgets`\n\n\n## How to use it\n\n1. Add the [`MultiTests.hh`](MultiTests.hh) file to your project\n2. Create a test case. Register it using **`TEST_DECLARE`**\n\n```cpp\n#ifndef TESTDUMMY_HH_\n#define TESTDUMMY_HH_\n\n#include \"MultiTests.hh\"\n\nclass Dummy_test : public QObject\n{\n    Q_OBJECT\n\nprivate slots:\n    // Test functions\n    void obviousTest(void){\n       QCOMPARE(1,1);\n    }\n};\n\nTEST_DECLARE(Dummy_test);\n\n#endif /* TESTDUMMY_HH_ */\n```\n\n3. When you want to compile the unit tests, just run the **`MULTI_TESTS_MAIN`** instead of your `main` function :\n\n```cpp\n#ifdef UNITTEST_MODE\n    #include \"MultiTests.hh\"\n    MULTI_TESTS_MAIN\n    // Else run normal main function\n#endif\n```\n4. Compile the application and run it : the test case is executed\n5. Repeat the step 2 for add more tests cases\n\n\nExample of execution :\n\n```\n********* Start testing of Dummy_test *********\nConfig: Using QTest library 4.8.6, Qt 4.8.6\nPASS   : Dummy_test::initTestCase()\nPASS   : Dummy_test::obviousTest()\nPASS   : Dummy_test::cleanupTestCase()\n********* Finished testing of Dummy_test *********\n********* Start testing of StylesHandler_test *********\nConfig: Using QTest library 4.8.6, Qt 4.8.6\nPASS   : StylesHandler_test::initTestCase()\nFAIL!  : StylesHandler_test::totalFailure() Compared values are not the same\n   Actual (m_data-\u003econtent()): In7sh4oaZj6G0gf\n   Expected (QString(\"153\")): 153\n   Loc: [tests/StylesHandler_test.cpp(67)]\nPASS   : StylesHandler_test::styleExist()\nPASS   : StylesHandler_test::cleanupTestCase()\nTotals: 4 passed, 0 failed, 0 skipped\n********* Finished testing of StylesHandler_test *********\n********* Start testing of VarTypes_test *********\nConfig: Using QTest library 4.8.6, Qt 4.8.6\nPASS   : VarTypes_test::initTestCase()\nPASS   : VarTypes_test::varUnknowUndefined()\nPASS   : VarTypes_test::varSearchValue()\nPASS   : VarTypes_test::cleanupTestCase()\nTotals: 10 passed, 0 failed, 0 skipped\n********* Finished testing of VarTypes_test *********\n========================================\n========================================\n======= ERRORS during tests !!!   =======\n1 error in 1 case(s), over a total of 3 tests cases\nCase(s) that failed :  StylesHandler_test\nExecuted in 0 seconds (49 ms)\n```\n\n## License\n\nThis project is under LGPLv3.\nSee the [LICENSE](LICENSE.md) file for license rights and limitations\n\n\n## Next steps\n\nThis helpful project is still a work in progress and can be improved in many ways.\nMissing features and to do work are listed into the issues section.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-j%2Fqt-multiple-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fe-j%2Fqt-multiple-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-j%2Fqt-multiple-tests/lists"}