Test successful but the application crashes
-
My tests are passing but I get a
crash occurred
error. I have no idea why. Following is the error:QML debugging is enabled. Only use this in a safe environment. ********* Start testing of TestSettings ********* Config: Using QtTest library 6.2.2, Qt 6.2.2 (x86_64-little_endian-llp64 shared (dynamic) release build; by GCC 11.2.0), windows 10 PASS : TestSettings::initTestCase() PASS : TestSettings::test_getTimeFormat24hour() PASS : TestSettings::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 1ms ********* Finished testing of TestSettings ********* A crash occurred in C:\Users\gollaha\Code\cook-ui-modular-qt\build-Test_cook-ui-modular-qt-Desktop_Qt_6_2_2_MinGW_64_bit-Debug\debug\Test_cook-ui-modular-qt.exe. Function time: 0ms Total time: 1ms Exception address: 0x00007ff7876829dd Exception code : 0xc0000005 Stack: # 1: ZN24QAbstractItemModelTesterC1EP18QAbstractItemModelP7QObject() - 0x00007ffa585a69f0 # 2: UnhandledExceptionFilter() - 0x00007ffa9a9eb610 # 3: memset() - 0x00007ffa9d093e00 # 4: _C_specific_handler() - 0x00007ffa9d07c6d0 # 5: _chkstk() - 0x00007ffa9d091fb0 # 6: RtlRaiseException() - 0x00007ffa9d041020 # 7: KiUserExceptionDispatcher() - 0x00007ffa9d090bd0 # 8: Unable to obtain symbol # 9: Unable to obtain symbol # 10: Unable to obtain symbol # 11: Unable to obtain symbol # 12: BaseThreadInitThunk() - 0x00007ffa9b5e7020 # 13: RtlUserThreadStart() - 0x00007ffa9d042630
*.pro file contains:
QT += testlib QT += gui QT += qmltest CONFIG += qt warn_on qmltestcase depend_includepath testcase TEMPLATE = app DISTFILES += \ tst_idontknow.qml SOURCES += \ # main.cpp \ tst_Settings.cpp \ ../cook-ui-modular-qt/App/UserInterface/backend.cpp \ ../cook-ui-modular-qt/App/UserInterface/Clock.cpp \ ../cook-ui-modular-qt/App/UserInterface/ConnectedSocketClient.cpp \ ../cook-ui-modular-qt/App/UserInterface/DrawerItems.cpp \ ../cook-ui-modular-qt/App/UserInterface/ErdBridge.cpp \ ../cook-ui-modular-qt/App/UserInterface/Settings.cpp \ HEADERS += ../cook-ui-modular-qt/App/UserInterface/backend.h \ ../cook-ui-modular-qt/App/UserInterface/Clock.h \ ../cook-ui-modular-qt/App/UserInterface/ConnectedSocketClient.h \ ../cook-ui-modular-qt/App/UserInterface/DrawerItems.h \ ../cook-ui-modular-qt/App/UserInterface/ErdBridge.h \ ../cook-ui-modular-qt/App/UserInterface/Settings.h RESOURCES += ../cook-ui-modular-qt/App/UserInterface/qml.qrc RESOURCES += ../cook-ui-modular-qt/App/UserInterface/fonts.qrc INCLUDEPATH += ../cook-ui-modular-qt/App/UserInterface INCLUDEPATH += ../cook-ui-modular-qt/App/ConnectedSocket
tst_Settings.cpp
contains:#include <QObject> //#include <QtQuickTest> #include <QTest> #include <QDebug> #include "Settings.h" #include "ErdBridge.h" class TestSettings: public QObject { Q_OBJECT public: TestSettings(); ~TestSettings(); private: ErdBridge *erdBridget; Settings *settings; private slots: void test_getTimeFormat24hour(); }; TestSettings::TestSettings() { settings = new Settings(erdBridget, nullptr); } TestSettings::~TestSettings() { delete settings; delete erdBridget; } void TestSettings::test_getTimeFormat24hour() { QCOMPARE(settings->getTimeFormat24hour(), false); } //QUICK_TEST_MAIN_WITH_SETUP(mytest, TestSettings) QTEST_MAIN(TestSettings) #include "tst_Settings.moc"
-
As always - start your app with a debugger and see where it crashes, fix it. From what I see
erdBridget
is not initialized sodelete
will crash