Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing (non-Qt) C++ code in Qt Creator?

I have a C++ project that doesn't use Qt. I am using Qt Creator as my IDE because it is very convenient.

I was reading about unit testing in Qt Creator here, and I think that Qt Test seems quite good. Is there a way to use Qt Test with my non-Qt C++ project?

Note that I have Qt libraries installed in my PC which I am using to program. But I don't want that the compiled program I release depends on the Qt libraries.

Also, a feature that I liked when I was using Visual Studio is that the tests are run automatically everytime I build my project. Can I do the same with Qt Creator?

By the way, if you can suggest another unit testing framework that I can use easily in Qt Creator, that's also fine.

like image 498
becko Avatar asked Jun 29 '15 13:06

becko


1 Answers

You can also unit test (non-Qt) C++ code in Qt Creator with GTest:

https://github.com/google/googletest/

using this great QtCreator plugin:

https://github.com/OneMoreGres/qtc-gtest

I switched from QTest to GTest (for testing Qt applications) for several reasons e.g. haven a nice graphical output and the ability to use a mocking framework (GMock).

like image 172
avb Avatar answered Sep 28 '22 05:09

avb