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 test No such file or directory when the tested class needs other classes (recursively)

Qt test No such file or directory when the tested class needs other classes (recursively)

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.2k 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.
  • G Offline
    G Offline
    Grpt
    wrote on last edited by Grpt
    #1

    Hello,

    I am trying to implement unit testing on a project.
    So my project has two subdirs, one with software's functionalities code and another one dedicated for unit tests.
    I create a file for each class I want to test, if this class does not need any other class, I'm able test it. But if the class I'm testing needs another class, this error occurs saying that the class needed by the tested class is missing (this is recursive, if the class missing needs another class it will also be missing):
    Structure/layer.h: No such file or directory
    Screenshot_5.png

    Detailed example :
    Material class, we can see that it does not require other classes (other than Qt/C++ classes). Here i don't get any errors.

    #ifndef MATERIAL_H
    #define MATERIAL_H
    #include <iostream>
    
    #include <QObject>
    #include <QtCore/qmath.h>
    #include <math.h>
    

    Structure class, it is the opposite, and I get multiple errors

    #ifndef STRUCTURE_H
    #define STRUCTURE_H
    
    #include <QObject>
    #include <QLibrary>
    #include <iostream>
    #include <array>
    #include <Structure/layer.h>
    #include <BaseDeDonnees/materialdb.h>
    

    a2838d03-657d-460b-8d85-75e494cbdbf1-image.png

    Here is the *.pro of my unitTest project.
    I tried to add layer.h without success

    QT += testlib
    QT += gui
    CONFIG += qt testcase
    
    TEMPLATE = app
    
    SOURCES += \
        main.cpp \
        test_material.cpp \
        test_structure.cpp \
        ../cpp/Structure/material.cpp \
        ../cpp/Structure/structure.cpp \
        ../cpp/Structure/layer.cpp \
    #    test_session.cpp \
    #    test_charge.cpp \
    #    ../cpp/SessionProjet/session.cpp \
    #    ../cpp/Charges/charge.cpp \
    
    HEADERS += \
        test_material.h \
        test_structure.h \
        ../cpp/Structure/material.h \
        ../cpp/Structure/structure.h \
        ../cpp/Structure/layer.h \
    #    test_session.h \
    #    test_charge.h \
    #    ../cpp/SessionProjet/session.h \
    #    ../cpp/Charges/charge.h \
    
    
    INCLUDEPATH += \
        $$PWD \
    
    KroMignonK 1 Reply Last reply
    0
    • G Grpt

      Hello,

      I am trying to implement unit testing on a project.
      So my project has two subdirs, one with software's functionalities code and another one dedicated for unit tests.
      I create a file for each class I want to test, if this class does not need any other class, I'm able test it. But if the class I'm testing needs another class, this error occurs saying that the class needed by the tested class is missing (this is recursive, if the class missing needs another class it will also be missing):
      Structure/layer.h: No such file or directory
      Screenshot_5.png

      Detailed example :
      Material class, we can see that it does not require other classes (other than Qt/C++ classes). Here i don't get any errors.

      #ifndef MATERIAL_H
      #define MATERIAL_H
      #include <iostream>
      
      #include <QObject>
      #include <QtCore/qmath.h>
      #include <math.h>
      

      Structure class, it is the opposite, and I get multiple errors

      #ifndef STRUCTURE_H
      #define STRUCTURE_H
      
      #include <QObject>
      #include <QLibrary>
      #include <iostream>
      #include <array>
      #include <Structure/layer.h>
      #include <BaseDeDonnees/materialdb.h>
      

      a2838d03-657d-460b-8d85-75e494cbdbf1-image.png

      Here is the *.pro of my unitTest project.
      I tried to add layer.h without success

      QT += testlib
      QT += gui
      CONFIG += qt testcase
      
      TEMPLATE = app
      
      SOURCES += \
          main.cpp \
          test_material.cpp \
          test_structure.cpp \
          ../cpp/Structure/material.cpp \
          ../cpp/Structure/structure.cpp \
          ../cpp/Structure/layer.cpp \
      #    test_session.cpp \
      #    test_charge.cpp \
      #    ../cpp/SessionProjet/session.cpp \
      #    ../cpp/Charges/charge.cpp \
      
      HEADERS += \
          test_material.h \
          test_structure.h \
          ../cpp/Structure/material.h \
          ../cpp/Structure/structure.h \
          ../cpp/Structure/layer.h \
      #    test_session.h \
      #    test_charge.h \
      #    ../cpp/SessionProjet/session.h \
      #    ../cpp/Charges/charge.h \
      
      
      INCLUDEPATH += \
          $$PWD \
      
      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by KroMignon
      #2

      @Grpt Please avoid using screenshot, it is a pain for other to reply. It is better when you copy/past text.

      Now to your issue: you cannot insert comments between line breaks.
      Remove those lines or move them to the end of the SOURCES and HEADERS definition.

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      G 1 Reply Last reply
      2
      • KroMignonK KroMignon

        @Grpt Please avoid using screenshot, it is a pain for other to reply. It is better when you copy/past text.

        Now to your issue: you cannot insert comments between line breaks.
        Remove those lines or move them to the end of the SOURCES and HEADERS definition.

        G Offline
        G Offline
        Grpt
        wrote on last edited by
        #3

        @KroMignon Thanks for your answer, I've edited my topic.
        I tried to execute without the unnecessary lines but it was still not working.

        I tried to add "../cpp/" to INCLUDEPATH then clean, execute qmake and recompile

        INCLUDEPATH += \
            $$PWD \
            ../cpp/ \
        

        Now the files are found but i get a new error "No rule to make target '../cpp/Structure/materialdb.cpp', needed by 'debug/materialdb.o'. Stop."
        I've searched on google but I can't find a solution that works for me
        I am using Qt 5.13.2 MinGW 64-bit

        Here is the edited *.pro

        QT += testlib
        QT += gui
        CONFIG += qt testcase
        
        TEMPLATE = app
        
        SOURCES += \
            main.cpp \
            test_material.cpp \
            test_structure.cpp \
            ../cpp/Structure/material.cpp \
            ../cpp/Structure/structure.cpp \
            ../cpp/Structure/layer.cpp \
            ../cpp/Structure/materialdb.cpp \
            ../cpp/Structure/avstdroad.cpp
        
        
        
        HEADERS += \
            test_material.h \
            test_structure.h \
            ../cpp/Structure/material.h \
            ../cpp/Structure/structure.h \
            ../cpp/Structure/layer.h \
            ../cpp/Structure/materialdb.h \
            ../cpp/Structure/avstdroad.h
        
        
        INCLUDEPATH += \
            $$PWD \
            ../cpp/
        
        1 Reply Last reply
        0
        • G Offline
          G Offline
          Grpt
          wrote on last edited by
          #4

          Solved,
          The last issue was due to misspelled path.

          To solve "Qt test No such file or directory when the tested class needs other classes (recursively)" see last reply.

          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