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. Qt testlib
Forum Updated to NodeBB v4.3 + New Features

Qt testlib

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 3.2k Views 3 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.
  • ODБOïO Offline
    ODБOïO Offline
    ODБOï
    wrote on last edited by
    #1

    Hi,
    I'm trying to write a test for a simple project following this tutorial : http://doc.qt.io/qt-5/qttestlib-tutorial1-example.html

    this i my .pro , so i'm testing simplebackend and the tester class is test_simeplebackend in folder Tests

    QT += quick testlib
    CONFIG += c++11
    QT += opcua
    QT += network
    
    DEFINES += QT_DEPRECATED_WARNINGS
    
    SOURCES += main.cpp \
        simplebackend.cpp \
        Tests/test_simeplebackend.cpp
    
    RESOURCES += qml.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    HEADERS += \
        simplebackend.h \
        Tests/test_simeplebackend.h
    

    This is the output i have when i do :

    /myTestDirectory$ qmake -project "QT += testlib"
    /myTestDirectory$ qmake
    /myTestDirectory$ mingw32-make
    

    Output :

    c:\Users\lev\Documents\QIHM\Tests>mingw32-make
    mingw32-make -f Makefile.Release
    mingw32-make[1]: Entering directory 'C:/Users/lev/Documents/QIHM/Tests'
    mingw32-make[1]: *** No rule to make target 'release/test_simeplebackend.moc', needed by 'release/test_simeplebackend.o'.  Stop.
    mingw32-make[1]: Leaving directory 'C:/Users/lev/Documents/QIHM/Tests'
    Makefile:36: recipe for target 'release' failed
    mingw32-make: *** [release] Error 2
    

    I can't figure out what i'm doing wrong.
    test_simeplebackend.moc should be automatically generated right ?

    Thanks

    1 Reply Last reply
    0
    • ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      this is the .pro that is automatically generated in Tests directory

      QT += testlib
      TEMPLATE = app
      TARGET = Tests
      INCLUDEPATH += .
      
      DEFINES += QT_DEPRECATED_WARNINGS
      
      HEADERS += test_simeplebackend.h ../simplebackend.h
      SOURCES += test_simeplebackend.cpp ../simplebackend.cpp
      
      
      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        I would recommend to switch to the subdirs template and properly separate the projects.

        This will allow to have a cleaner and easier to maintain structure.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        ODБOïO 1 Reply Last reply
        2
        • SGaistS SGaist

          Hi,

          I would recommend to switch to the subdirs template and properly separate the projects.

          This will allow to have a cleaner and easier to maintain structure.

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          hi @SGaist
          Thx fo the advise, however i don't know how to do that.

          Where to put the Tests folder ? I thought it was normal to put it inside the project i wanted to test

          1 Reply Last reply
          0
          • ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by
            #5

            i will do this : http://xilexio.org/?p=125

            Pablo J. RoginaP 1 Reply Last reply
            0
            • ODБOïO ODБOï

              i will do this : http://xilexio.org/?p=125

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @LeLev you may want to take a look at, for instance, Qt MQTT module and how things are arranged there.

              examples
              qtmqtt.pro
              src
              sync.profile
              tests
                  |-README.txt
                  |-auto
                  |-benchmarks
                  |-common
                  |-tests.pro
              

              and tests.pro is like this:

              TEMPLATE = subdirs
              SUBDIRS += auto
              contains(QT_CONFIG, release): SUBDIRS += benchmarks
              

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              ODБOïO 1 Reply Last reply
              3
              • Pablo J. RoginaP Pablo J. Rogina

                @LeLev you may want to take a look at, for instance, Qt MQTT module and how things are arranged there.

                examples
                qtmqtt.pro
                src
                sync.profile
                tests
                    |-README.txt
                    |-auto
                    |-benchmarks
                    |-common
                    |-tests.pro
                

                and tests.pro is like this:

                TEMPLATE = subdirs
                SUBDIRS += auto
                contains(QT_CONFIG, release): SUBDIRS += benchmarks
                
                ODБOïO Offline
                ODБOïO Offline
                ODБOï
                wrote on last edited by
                #7

                @Pablo-J.-Rogina thx for the suggestion, i will definitely take a look at this exemple.

                The link i pasted http://xilexio.org/?p=125 is also (for me) very interesting, i organised my app following the concepts described there.

                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