Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Running Qt Quick and CPP tests at the same time

Running Qt Quick and CPP tests at the same time

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 461 Views 1 Watching
  • 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.
  • A Offline
    A Offline
    AkshayFP
    wrote on last edited by
    #1

    I am trying to run Qt Quick and C++ test at the same time, but I keep getting tst_settings.moc not found.

    Folder structure looks like this (screenshot):

    Screenshot 2022-01-27 113117.png

    *.pro contains:

    CONFIG += warn_on qmltestcase
    
    TEMPLATE = app
    
    DISTFILES += \
        tst_idontknow.qml
    
    SOURCES += \
        main.cpp \
        tst_Settings.cpp
    
    INCLUDEPATH += ../<path to external folder>
    

    main.cpp conatins:

    #include <QtQuickTest/quicktest.h>
    
    QUICK_TEST_MAIN(example)
    

    tst_Settings.cpp contains:

    #include <QObject>
    #include <QtQuickTest>
    #include "App/UserInterface/Settings.h"
    #include "App/UserInterface/ErdBridge.h"
    
    class TestSettings: public QObject
    {
        Q_OBJECT
    public:
        TestSettings();
        ~TestSettings();
    
        void test_getTimeFormat24hour();
    private:
        ErdBridge *erdBridget;
        Settings *settings;
    
    };
    
    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(example, TestSettings)
    
    #include "tst_settings.moc"
    

    tst_idontknow.qml has a generated code, which will always pass. When I run the code I get the following error:

    ..\Test_cook-ui-modular-qt\tst_Settings.cpp:39:10: fatal error: tst_settings.moc: No such file or directory
       39 | #include "tst_settings.moc"
          |          ^~~~~~~~~~~~~~~~~~
    compilation terminated.
    mingw32-make[1]: *** [Makefile.Debug:1030: debug/tst_Settings.o] Error 1
    mingw32-make[1]: *** Waiting for unfinished jobs....
    mingw32-make[1]: Leaving directory 'C:/Users/gollaha/Code/cook-ui-modular-qt/build-Test_cook-ui-modular-qt-Desktop_Qt_6_2_2_MinGW_64_bit-Debug'
    mingw32-make: *** [Makefile:45: debug] Error 2
    11:29:06: The process "C:\Qt\Tools\mingw900_64\bin\mingw32-make.exe" exited with code 2.
    Error while building/deploying project Test_cook-ui-modular-qt (kit: Desktop Qt 6.2.2 MinGW 64-bit)
    When executing step "Make"
    

    Not sure why I am getting this error. Any help would be appreciated.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      Upper case vs lower case spelling of test_settings.cpp vs test_Settings.cpp?
      Did you run qmake a couple of times as well? I always have to run qmake a few times to get it to produce the moc file.

      C++ is a perfectly valid school of magic.

      A 1 Reply Last reply
      2
      • fcarneyF fcarney

        Upper case vs lower case spelling of test_settings.cpp vs test_Settings.cpp?
        Did you run qmake a couple of times as well? I always have to run qmake a few times to get it to produce the moc file.

        A Offline
        A Offline
        AkshayFP
        wrote on last edited by
        #3

        @fcarney Ya looks like the uppercase. 🤦‍♂️

        Thanks for your help.

        1 Reply Last reply
        0

        • Login

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