Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Testing Framework and Qt

Tags:

qt

googletest

I want to start using the Google C++ Testing Framework, but I don't understand how it use with Qt?

What should I do to start? How to link GTF to my project and use it? If possible, I'd like a detailed guide.

like image 977
Nikita Bondar Avatar asked Dec 14 '25 06:12

Nikita Bondar


1 Answers

There is nothing special about testing Qt in particular, just familiarize yourself with google testing and Qt, then write your test cases. You'd test Qt code like you'd test anything else.

Good places to start:

  • A quick introduction to the Google C++ Testing Framework courtesy of IBM
  • Getting Started with Qt

The one thing to keep in mind is that a significant part of Qt is event driven, which requires a running event loop.

Additional resources:

  • Running Autotests in Creator - setting up google test
  • the Qt Creator Google Test plugin

Edit:

To elaborate on Gluttton's comment, as evidently, other users share the sentiment:

The clarification about the design particularities of Qt should imply two things:

1 - in many cases, individual tests will require an above trivial setup, that is still standard Qt and C++, set up event loops and connections and whatnot - nothing special whatsoever.

2 - in some cases, there is only so much that unit testing can do. Some functionality requires larger and more complicated runtime setups, that are impractical or even impossible in the context of unit testing, thus falling outside of the scope of the google testing framework.

like image 141
dtech Avatar answered Dec 16 '25 03:12

dtech



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!