[Qt-creator] Unit testing private parts of shared libraries
Elvis Stansvik
elvstone at gmail.com
Tue Oct 17 09:35:17 CEST 2017
2017-10-17 9:29 GMT+02:00 Christian Kandeler <christian.kandeler at qt.io>:
> On Mon, 16 Oct 2017 18:57:19 +0200
> Elvis Stansvik <elvstone at 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.
Elvis
>
>
> Christian
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
More information about the Qt-creator
mailing list