{"id":21548871,"url":"https://github.com/benlau/testable","last_synced_at":"2026-03-03T05:40:43.262Z","repository":{"id":66963694,"uuid":"48814653","full_name":"benlau/testable","owner":"benlau","description":"QT/QML Test Runner and Utilities","archived":false,"fork":false,"pushed_at":"2024-08-02T10:27:17.000Z","size":187,"stargazers_count":64,"open_issues_count":3,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-02-07T06:46:22.120Z","etag":null,"topics":["qml","tests"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benlau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-30T18:44:26.000Z","updated_at":"2025-04-01T11:24:47.000Z","dependencies_parsed_at":"2024-01-14T11:17:32.771Z","dependency_job_id":"1d1f020e-8d8b-4b00-b375-0ffe8299b134","html_url":"https://github.com/benlau/testable","commit_stats":{"total_commits":124,"total_committers":1,"mean_commits":124.0,"dds":0.0,"last_synced_commit":"061909979e8609528bbfd15ec0aedc7227b47770"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/benlau/testable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benlau%2Ftestable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benlau%2Ftestable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benlau%2Ftestable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benlau%2Ftestable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benlau","download_url":"https://codeload.github.com/benlau/testable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benlau%2Ftestable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30033503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T05:09:26.876Z","status":"ssl_error","status_checked_at":"2026-03-03T05:09:23.944Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["qml","tests"],"created_at":"2024-11-24T06:19:57.694Z","updated_at":"2026-03-03T05:40:43.246Z","avatar_url":"https://github.com/benlau.png","language":"C++","funding_links":[],"categories":["Testing"],"sub_categories":[],"readme":"Testable - Qt/QML Unit Test Utilities\n=======================\n[![Build Status](https://travis-ci.org/benlau/testable.svg?branch=master)](https://travis-ci.org/benlau/testable)\n\nTestable is an utility library to enhance the function of the two testing frameworks offered by Qt: [QTest](http://doc.qt.io/qt-5/qtest.html) for C++ and [Qt Quick Test](http://doc.qt.io/qt-5/qtquick-qtquicktest.html) for QML. \n\nFeatures:\n\n1. Support to run tests from mutiple QObjects\n1. Support to run QTest (C++) and Quick Tests (QML) in a same project\n1. Run specific test case / test object by command line and autotests plugin\n1. Setup custom property and image provider for Qt Quick Test by using engine hook function\n1. Utilities to search QQuickItem from Repeater/Flickable/ListView/GridView\n\nClasses\n\n1. TestRunner - Multiple test objects runner\n2. Automator - Automator provides an interface to manipulate UI object loaded by QQmlApplicationEngine\n \nInstallation\n===========\n\n    qpm install com.github.benlau.testable\n\nExample\n=======\n\n```\n#include \u003cTestRunner\u003e\n\nint main(int argc, char *argv[])\n{\n    QGuiApplication app(argc,argv);\n\n    TestRunner runner;\n\n    runner.add\u003cDummyTests1\u003e(); // Run tests in DummyTest1 QObject\n    runner.add\u003cDummyTests2\u003e(); // Run tests in DummyTest2 QObject\n    // Run Qt Quick Test in SRCDIR. It will scan all qml file begin with tst_\n    runner.add(QString(SRCDIR));\n\n    runner.addImportPath(\"qrc:///\");\n    runner.setEngineHook([](QQmlEngine* engine) {\n      engine-\u003erootContext-\u003esetContextProperty(\"MyCustomProperty\", new QObject());\n    });\n\n    bool error = runner.exec(app.arguments());\n\n    if (!error) {\n        qWarning() \u003c\u003c \"All test cases passed!\";\n    }\n\n    return error;\n}\n```\n\nExampls are available at [examples](https://github.com/benlau/testable/tree/master/examples/testableexample) folder.\n\nCommand Line Demonstration\n---------------------------\n\nRun all tests with function name equal to \"test1\"\n\n```\n$ ./testable test1\n********* Start testing of DummyTests1 *********\nConfig: Using QtTest library 5.5.0, Qt 5.5.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 6.0 (clang-600.0.56) (Apple))\nPASS   : DummyTests1::initTestCase()\nPASS   : DummyTests1::test1()\nPASS   : DummyTests1::cleanupTestCase()\nTotals: 3 passed, 0 failed, 0 skipped, 0 blacklisted\n********* Finished testing of DummyTests1 *********\n********* Start testing of DummyTests2 *********\nConfig: Using QtTest library 5.5.0, Qt 5.5.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 6.0 (clang-600.0.56) (Apple))\nPASS   : DummyTests2::initTestCase()\nPASS   : DummyTests2::test1()\nPASS   : DummyTests2::cleanupTestCase()\nTotals: 3 passed, 0 failed, 0 skipped, 0 blacklisted\n********* Finished testing of DummyTests2 *********\n```\n\nRun all test functions in DummyTests1 test object\n\n```\n$ ./testable DummyTests1\n********* Start testing of DummyTests1 *********\nConfig: Using QtTest library 5.5.0, Qt 5.5.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 6.0 (clang-600.0.56) (Apple))\nPASS   : DummyTests1::initTestCase()\nPASS   : DummyTests1::test1()\nPASS   : DummyTests1::test2()\nPASS   : DummyTests1::cleanupTestCase()\nTotals: 4 passed, 0 failed, 0 skipped, 0 blacklisted\n********* Finished testing of DummyTests1 *********\nAll test cases passed!\n```\n\nRun a test function via qmltest\n\n```\n./testable QuickTests::test_dummy1\n********* Start testing of QuickTests *********\nConfig: Using QtTest library 5.5.0, Qt 5.5.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 6.0 (clang-600.0.56) (Apple))\nPASS   : QuickTests::QuickTests::initTestCase()\nPASS   : QuickTests::QuickTests::test_dummy1()\nPASS   : QuickTests::QuickTests::cleanupTestCase()\nTotals: 3 passed, 0 failed, 0 skipped, 0 blacklisted\n********* Finished testing of QuickTests *********\n```\n\nRun all tests\n\n```\n./testable\n\nStarting /Users/benlau/src/github/testable/examples/build-testableexample-Desktop_Qt_5_5_0_clang_64bit-Debug/testable...\n********* Start testing of DummyTests1 *********\nConfig: Using QtTest library 5.5.1, Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 6.0 (clang-600.0.56) (Apple))\nPASS   : DummyTests1::initTestCase()\nPASS   : DummyTests1::test1()\nPASS   : DummyTests1::test2()\nPASS   : DummyTests1::cleanupTestCase()\nTotals: 4 passed, 0 failed, 0 skipped, 0 blacklisted\n********* Finished testing of DummyTests1 *********\n********* Start testing of DummyTests2 *********\nConfig: Using QtTest library 5.5.1, Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 6.0 (clang-600.0.56) (Apple))\nPASS   : DummyTests2::initTestCase()\nPASS   : DummyTests2::test1()\nFAIL!  : DummyTests2::fail() 'false' returned FALSE. ()\n   Loc: [../testableexample/dummytests2.cpp(16)]\nPASS   : DummyTests2::cleanupTestCase()\nTotals: 3 passed, 1 failed, 0 skipped, 0 blacklisted\n********* Finished testing of DummyTests2 *********\n********* Start testing of QuickTests *********\nConfig: Using QtTest library 5.5.1, Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 6.0 (clang-600.0.56) (Apple))\nPASS   : QuickTests::TestableTests::initTestCase()\nPASS   : QuickTests::TestableTests::test_TestRunner()\nPASS   : QuickTests::TestableTests::cleanupTestCase()\nPASS   : QuickTests::QuickTests::initTestCase()\nPASS   : QuickTests::QuickTests::test_dummy1()\nPASS   : QuickTests::QuickTests::test_dummy2()\nPASS   : QuickTests::QuickTests::cleanupTestCase()\nTotals: 7 passed, 0 failed, 0 skipped, 0 blacklisted\n********* Finished testing of QuickTests *********\n```\n\nAutotests Plugin\n================\n\nQt Creator could not detect the tests written by Testable automatically. And therefore it will show nothing in the \"Tests\" panel and you can't trigger test via [Autotests](http://doc.qt.io/qtcreator/creator-autotest.html)\n plugin.\n\nTo make it work, you have to declare the test object explicitly .\n\n```\nDummyTests1::DummyTests1(QObject *parent) : QObject(parent)\n{\n    auto ref = [=]() {\n        QTest::qExec(this, 0, 0); // Autotest detect available test cases of a QObject by looking for \"QTest::qExec\" in source code\n    };\n    Q_UNUSED(ref);\n}\n```\n\nThe code does actually nothing but it is required for Autotest's parser to recognize the tests.\n\nAutotests does not allow to declare more than a test within a source file. So you have to add this piece of code per source file.\n\nFor Qt Quick Tests, you need to declare QUICK_TEST_SOURCE_DIR in pro file:\n\n\nproject.pro file\n\n```\nDEFINES += QUICK_TEST_SOURCE_DIR=\\\\\\\"$$PWD\\\\\\\"\n```\n\nThen place QUICK_TEST_MAIN in your main.cpp explicitly.\n\n```\n#include \u003cQtQuickTest/quicktest.h\u003e\n\nnamespace AutoTestRegister {\n    QUICK_TEST_MAIN(QuickTests)\n}\n\nint main(int argc, char *argv[]) {\n```\n\n![Autotests Screenshot](https://raw.githubusercontent.com/benlau/testable/master/docs/screenshot1.png)\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenlau%2Ftestable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenlau%2Ftestable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenlau%2Ftestable/lists"}