Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is it possible to write Qt Auto Test results to a file directly?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to write Qt Auto Test results to a file directly?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtestqtcreatorqt6ubuntuunit test
1 Posts 1 Posters 358 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.
  • K Offline
    K Offline
    Kevin470
    wrote on 25 Oct 2022, 11:34 last edited by Kevin470
    #1

    I have two 2 Qt Test classes/cases for my Project.
    I run Qt Test and Qt Creator tests both the classes and provides the result in the tab "Test Results", where I can then right-click on the Test case and save it to a file manually. And it seems that I can save only one Test Case at a time.
    Is it possible to make a "report" or save the results directly to a file as it runs?

    And is it possible to change the sequence of the test cases? The IDE runs either one of the two test cases and it is not the same every time. For example, I have two .cpp files, test_case1.cpp and test_case2.cpp. The IDE selects either one of them as the first and the second and runs it first. Can I change how the sequence is selected? Thank you.
    Below is a sample of how my test project structure is.

    My Test Case CMakeLists.txt:

    enable_testing()
    
    function(SETUP_TESTS)
           foreach(_testname ${ARGN})
               add_executable(${_testname} test_${_testname}.cpp )
               add_test(NAME ${_testname} COMMAND ${_testname})
               target_link_libraries(${_testname} Qt${QT_MAJOR_VERISION}::Test ProjSources)
           endforeach()
    endfunction()
    
    SETUP_TESTS(
       case1
       case2
    )
    

    test_case1.cpp

    #include <QTest>
    
    class Test_case1: public QObject
    {
        Q_OBJECT
    private slots:
        void toUpper();
    };
    
    void Test_case1::toUpper()
    {
        QString str = "Hello";
        QCOMPARE(str.toUpper(), QString("HELLO"));
    }
    
    QTEST_MAIN(Test_case1)
    #include "test_case1.moc"
    

    test_case2.cpp

    #include <QTest>
    
    class Test_case2: public QObject
    {
        Q_OBJECT
    private slots:
        void toLower();
    };
    
    void Test_case2::toLower()
    {
        QString str = "Hello";
        QCOMPARE(str.toLower(), QString("hello"));
    }
    
    QTEST_MAIN(Test_case2)
    #include "test_case2.moc"
    
    1 Reply Last reply
    0

    1/1

    25 Oct 2022, 11:34

    • Login

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