0

I'm confused on how I'm supposed to use the QtTest FrameWork inside a Library project (Windows). I have created a library project and added some tests, but I had a lot of issues trying to run the tests. The key to solve my problem was to set:

TEMPLATE = app

However, I'm making a lib... also app makes an exe, not a dll. I really hope that it's not intent to have to change the project file manually to 'app' when testing and changing to 'lib' for actual building the library. This seems unproductive.

So, what's up with QtTests inside library projects?

Thanks

Zavulon
  • 121
  • 8
  • Any test framework is not for use inside a library! You should create application which uses testing framework and library under test to write a tests. There shouldn't be any dependency between library and testing framework. So basically your question title is invalid. – Marek R Oct 28 '20 at 11:57
  • Ok, but how am I expected to test library internals that are not made public? I assume unit testing is about testing units, small pieces of code. Some small pieces aren't intended to be made public but kept inside the library. – Zavulon Oct 28 '20 at 12:01
  • @Zavulon, your strategy should be testing private stuff using the public interface. – vahancho Oct 28 '20 at 12:10
  • 1
    You should test desired functionality not implementation detail, so accessing private parts of library is very bad testing practice. If your test accesses private details it makes hard to refactor the code (since test requires some specific detail in implementation). This is common problem/temptation when tests are written after production code. – Marek R Oct 28 '20 at 14:09

0 Answers0