On 17/10/2017 8:42 pm, "Christian Gagneraud" <chg...@gmail.com> wrote:
On 17/10/2017 8:35 pm, "Elvis Stansvik" <elvst...@gmail.com> wrote: 2017-10-17 9:29 GMT+02:00 Christian Kandeler <christian.kande...@qt.io>: > On Mon, 16 Oct 2017 18:57:19 +0200 > Elvis Stansvik <elvst...@gmail.com> wrote: > >> I'm working on some tests for my own application, and started thinking >> about unit testing of private parts of shared libraries (think the >> _p.h/_p.cpp parts). Such parts are normally not exported AFAIK (in the >> visibility attribute sense). This becomes a problem if you link the >> unit tests dynamically against the code under test, as the tests won't >> be able to see those symbols. >> >> So it seems to me there is only a few options: >> >> 1. Exporting the private parts after all, >> 2. Adding the sources of the code under test to the unit tests, >> 3. ? > > You might want to take a look at the Q_AUTOTEST_EXPORT macro in Qt and how it is used. Ah, didn't know about that one, thanks. That's certainly possible in the case of Qt, where there's a "developer build" which can make this macro effective. It does mean that you're not testing the library as-shipped though. But I guess short of exporting everything outright, there's no other way. There is another way, and it's used in qbs I believe, that is option 2: Sorry: s/Qbs/QtC/ #include "Foo.h" #include "Foo.cpp" class FooTest: QObject { ... } It requires very low coupling tho. Which is a good practice, but not always easy to achieve, unless you strongly stick to the cpp unit testing idiom. My 2 cents, Chris Elvis > > > Christian > _______________________________________________ > Qt-creator mailing list > Qt-creator@qt-project.org > http://lists.qt-project.org/mailman/listinfo/qt-creator _______________________________________________ Qt-creator mailing list Qt-creator@qt-project.org http://lists.qt-project.org/mailman/listinfo/qt-creator
_______________________________________________ Qt-creator mailing list Qt-creator@qt-project.org http://lists.qt-project.org/mailman/listinfo/qt-creator