Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Showcase
  4. Testable - QML Unit Test Utilities

Testable - QML Unit Test Utilities

Scheduled Pinned Locked Moved Unsolved Showcase
test
2 Posts 2 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benlau
    Qt Champions 2016
    wrote on 24 Jun 2016, 03:53 last edited by benlau 7 Jan 2016, 16:45
    #1

    Project: benlau/testable: QML Unit Test Utilities

    Testable - Qt / QML Unit Test Utilities

    Qt offers two testing frameworks : QTest for C++ and Qt Quick Test for QML. Testable is an utililiy library to enhance their function.

    The features:

    1. Support to run tests from mutiple QObjects
    2. Support to run QTest (C++) and Quick Tests (QML) in a single project
    3. Run specific test case / test object by command line
    4. Utilities to search QQuickItem from Repeater/Flickable/ListView/GridView
    5. Execute unit test written in Javascript by C++ ( Automator.runTestCase() )

    Classes

    1. TestRunner - Multiple test objects runner
    2. Automator - Automator provides an interface to manipulate UI object loaded by QQmlApplicationEngine
    3. ResourceGenerator - Generate .qrc according to the file tree

    Installation

    qpm install com.github.benlau.testable
    

    Example

    Please refer to the project in examples folder

    Run all tests with function name equal to "test1"

    $ ./testable test1
    ********* Start testing of DummyTests1 *********
    Config: 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))
    PASS   : DummyTests1::initTestCase()
    PASS   : DummyTests1::test1()
    PASS   : DummyTests1::cleanupTestCase()
    Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted
    ********* Finished testing of DummyTests1 *********
    ********* Start testing of DummyTests2 *********
    Config: 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))
    PASS   : DummyTests2::initTestCase()
    PASS   : DummyTests2::test1()
    PASS   : DummyTests2::cleanupTestCase()
    Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted
    ********* Finished testing of DummyTests2 *********
    

    Run all test functions in DummyTests1 test object

    $ ./testable DummyTests1
    ********* Start testing of DummyTests1 *********
    Config: 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))
    PASS   : DummyTests1::initTestCase()
    PASS   : DummyTests1::test1()
    PASS   : DummyTests1::test2()
    PASS   : DummyTests1::cleanupTestCase()
    Totals: 4 passed, 0 failed, 0 skipped, 0 blacklisted
    ********* Finished testing of DummyTests1 *********
    All test cases passed!
    

    Run a test function via qmltest

    ./testable QuickTests::test_dummy1
    ********* Start testing of QuickTests *********
    Config: 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))
    PASS   : QuickTests::QuickTests::initTestCase()
    PASS   : QuickTests::QuickTests::test_dummy1()
    PASS   : QuickTests::QuickTests::cleanupTestCase()
    Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted
    ********* Finished testing of QuickTests *********
    

    Run all tests

    ./testable
    Starting /Users/benlau/src/github/testable/examples/build-testableexample-Desktop_Qt_5_5_0_clang_64bit-Debug/testable...
    ********* Start testing of DummyTests1 *********
    Config: 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))
    PASS   : DummyTests1::initTestCase()
    PASS   : DummyTests1::test1()
    PASS   : DummyTests1::test2()
    PASS   : DummyTests1::cleanupTestCase()
    Totals: 4 passed, 0 failed, 0 skipped, 0 blacklisted
    ********* Finished testing of DummyTests1 *********
    ********* Start testing of DummyTests2 *********
    Config: 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))
    PASS   : DummyTests2::initTestCase()
    PASS   : DummyTests2::test1()
    FAIL!  : DummyTests2::fail() 'false' returned FALSE. ()
       Loc: [../testableexample/dummytests2.cpp(16)]
    PASS   : DummyTests2::cleanupTestCase()
    Totals: 3 passed, 1 failed, 0 skipped, 0 blacklisted
    ********* Finished testing of DummyTests2 *********
    
    1 Reply Last reply
    2
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 Jun 2016, 11:56 last edited by
      #2

      Nice ! Thanks for sharing :)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      1/2

      24 Jun 2016, 03:53

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved