0

This is my (very simplified) directory tree :

C:.
|   common.h
|   QMelt.pro
|   
+---src
|   +---app
|   |       main.cpp
|   |       melt.cpp
|   |       melt.h
|   |             
|   +---io
|   |       alsfilestreambase.h
|   |       alsfilesystem.cpp
|   |       alsfilesystem.h
|           
\---test
    +---io
        |   io_test.pro
        |   io_test.pro.user
        |   
        \---src
                alsfilesystemtest.cpp
                alsfilesystemtest.h

What I'm trying to achieve is to configure io_test.pro - which is an unit test project (using QTest) - to be able to test the io namespace.

Here is my current io_test.pro :

QT       += testlib

QT       -= gui

TARGET = tst_io
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

#Test sources
SOURCES += src/alsfilesystemtest.cpp

HEADERS += src/alsfilesystemtest.h

#Testing sources
SOURCES += ../../src/io/alsfilesystem.cpp 

HEADERS += ../../src/io/alsfilesystem.h

DEFINES += SRCDIR=\\\"$$PWD/src\\\"
INCLUDEPATH += $$PWD/../..

My problem is that I have linker errors at build time. These errors are on method using QMelt project (the project I want to test) dependecy, included by alsfilesystem.

So my question is what modifications should I bring to io_test.pro in order to use the .obj built by QMelt.pro ?

Bastien
  • 994
  • 11
  • 25
  • 1
    I'm sure there's more than one way to do this, but what I do in my unit tests is just include all the source files required to build each test inside of the unit test project itself. From your io_test.pro file it seems you've started going in this direction as well (in the "#Testing sources" section.) Why not just add the rest of the required source files there? – MrEricSir Jul 16 '15 at 18:04
  • I thought it would be better to use the .obj built by the main project, in order to not overloading the test project for no reason. But yeah, include all the sources is a possibility. – Bastien Jul 17 '15 at 12:53

0 Answers0