[Qt-creator] Unit testing private parts of shared libraries

Christian Kandeler christian.kandeler at qt.io
Tue Oct 17 09:29:21 CEST 2017


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.


Christian



More information about the Qt-creator mailing list