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. Unit Testings Q_DECL_HIDDEN classes of a custom Qt Library with Google Test
QtWS25 Last Chance

Unit Testings Q_DECL_HIDDEN classes of a custom Qt Library with Google Test

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 350 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.
  • P Offline
    P Offline
    pjorourke05
    wrote on last edited by
    #1

    I am using Google unit test framework to test by custom Qt library. I am also using the pimpl pattern to ensure ABI compatibility. Doing this I Q_DECL_HIDDEN some of my classes that are not apart of my API but used in the library. To my understanding this will not export a symbol for those classes.

    Now I have another project that does my unit testing. As part of it's CMake process a link the library so that I can test against it. I also use the install location of the header files. So my question is what happens when I dont export the header or even create a symbol? I shouldnt be able to unit test those classes.

    Here are the two ideas we have so far of how to get around this.

    1. Mark the build with compiler conditionals to export those symbols when building for a unit test.. this would cause us to have to build twice once for unit test.. second for production
    2. just add the header and cpp files to the unit test project manually.. this will work but seems kind of hacky.

    Are they any better practices when dealing with non exported classed and unit testing.

    jsulmJ 1 Reply Last reply
    0
    • P pjorourke05

      I am using Google unit test framework to test by custom Qt library. I am also using the pimpl pattern to ensure ABI compatibility. Doing this I Q_DECL_HIDDEN some of my classes that are not apart of my API but used in the library. To my understanding this will not export a symbol for those classes.

      Now I have another project that does my unit testing. As part of it's CMake process a link the library so that I can test against it. I also use the install location of the header files. So my question is what happens when I dont export the header or even create a symbol? I shouldnt be able to unit test those classes.

      Here are the two ideas we have so far of how to get around this.

      1. Mark the build with compiler conditionals to export those symbols when building for a unit test.. this would cause us to have to build twice once for unit test.. second for production
      2. just add the header and cpp files to the unit test project manually.. this will work but seems kind of hacky.

      Are they any better practices when dealing with non exported classed and unit testing.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @pjorourke05 If you are implementing unit tests then there is no need to link your library to the test project. Instead include the source code of your lib you want to test in your test project.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      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