Is it possible to write Qt Auto Test results to a file directly?
-
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"