Important: Please read the Qt Code of Conduct -

How to combine all tests in one XML report

  • Hello all,

    I am working on a test projet which contains many test classes. This is the main function of the project :

    int main(int argc, char** argv) {
        int status = 0;
        Test_AbstractCanMessage test_abstractcanmessage;
        status |= QTest::qExec(&test_abstractcanmessage, argc, argv);
        Test_RequestCanMessage test_requestcanmessage;
        status |= QTest::qExec(&test_requestcanmessage, argc, argv);
        return status;

    And the app output :

    ********* Start testing of Test_AbstractCanMessage *********
    Config: Using QtTest library 5.11.3, Qt 5.11.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.3.1 20160406 (Red Hat 5.3.1-6))
    QML debugging is enabled. Only use this in a safe environment.
    PASS   : Test_AbstractCanMessage::initTestCase()
    PASS   : Test_AbstractCanMessage::test_constructor_empty()
    PASS   : Test_AbstractCanMessage::test_constructor_from_raw()
    PASS   : Test_AbstractCanMessage::test_constructor_from_string(empty string)
    PASS   : Test_AbstractCanMessage::test_constructor_from_string(zero filling 1)
    PASS   : Test_AbstractCanMessage::test_constructor_from_string(zero filling 2)
    PASS   : Test_AbstractCanMessage::test_constructor_from_string(zero filling 3)
    PASS   : Test_AbstractCanMessage::test_constructor_from_string(ascii conversion)
    PASS   : Test_AbstractCanMessage::test_constructor_from_unsigned_int(zero)
    PASS   : Test_AbstractCanMessage::test_constructor_from_unsigned_int(maximum)
    PASS   : Test_AbstractCanMessage::test_constructor_from_unsigned_int(random)
    PASS   : Test_AbstractCanMessage::test_constructor_from_unsigned_int(one)
    PASS   : Test_AbstractCanMessage::test_is_valid_serialized_can_frame(Valid minimal value)
    PASS   : Test_AbstractCanMessage::test_is_valid_serialized_can_frame(Valid maximal value)
    PASS   : Test_AbstractCanMessage::test_is_valid_serialized_can_frame(Valid random frame)
    PASS   : Test_AbstractCanMessage::test_is_valid_serialized_can_frame(Size too short)
    PASS   : Test_AbstractCanMessage::test_is_valid_serialized_can_frame(Size too high)
    PASS   : Test_AbstractCanMessage::test_is_valid_serialized_can_frame(Invalid CAN ID)
    PASS   : Test_AbstractCanMessage::test_from_serialized_can_frame(Empty frame)
    PASS   : Test_AbstractCanMessage::test_from_serialized_can_frame(Size too low)
    PASS   : Test_AbstractCanMessage::test_from_serialized_can_frame(Size too high)
    PASS   : Test_AbstractCanMessage::test_from_serialized_can_frame(Invalid CAN ID)
    PASS   : Test_AbstractCanMessage::test_from_serialized_can_frame(Random valid)
    PASS   : Test_AbstractCanMessage::test_serialize(Empty frame)
    PASS   : Test_AbstractCanMessage::test_serialize(Invalid can id)
    PASS   : Test_AbstractCanMessage::test_serialize(Size too low)
    PASS   : Test_AbstractCanMessage::test_serialize(Size too high)
    PASS   : Test_AbstractCanMessage::test_serialize(Random valid)
    PASS   : Test_AbstractCanMessage::test_serialize(Can ID size low)
    PASS   : Test_AbstractCanMessage::test_is_valid(Empty frame)
    PASS   : Test_AbstractCanMessage::test_is_valid(Invalid can id)
    PASS   : Test_AbstractCanMessage::test_is_valid(Size too low)
    PASS   : Test_AbstractCanMessage::test_is_valid(Size too high)
    PASS   : Test_AbstractCanMessage::test_is_valid(Random valid)
    PASS   : Test_AbstractCanMessage::test_is_valid(Can ID size low)
    PASS   : Test_AbstractCanMessage::test_set_can_id()
    PASS   : Test_AbstractCanMessage::test_get_can_id()
    PASS   : Test_AbstractCanMessage::cleanupTestCase()
    Totals: 38 passed, 0 failed, 0 skipped, 0 blacklisted, 2ms
    ********* Finished testing of Test_AbstractCanMessage *********
    ********* Start testing of Test_RequestCanMessage *********
    Config: Using QtTest library 5.11.3, Qt 5.11.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.3.1 20160406 (Red Hat 5.3.1-6))
    PASS   : Test_RequestCanMessage::initTestCase()
    PASS   : Test_RequestCanMessage::test_constructor_empty()
    PASS   : Test_RequestCanMessage::cleanupTestCase()
    Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 0ms
    ********* Finished testing of Test_RequestCanMessage *********

    When I generate a xunit report with ./test_project -o report.xml,xunitxml, only the last Test Suite appears in the report.

    My question : Is there an easy way to combine all test suites of a test project in a single report ?

    Thrank you


  • After some tests and research, I finally decided to use GoogleTest instead of QtTest ... The report generated with GoogleTest contains all the tests within the project.

  • The Qt test framework is designed to have 1 class per project without concatenations, the feature you want is not present just because you are forcing the framework to do something it shouldn't do

  • I am aware that it should work this way.

    I need to generate one or more XML reports of my test cases.

    So let's imagine that I have a subdir project with several test cases inside. After construction, how can I generate an XML report for each sub-project at a time?

    Thank you

Log in to reply