Automated testing recomendations
-
Hi,
I would like to add automated testing onto my build process. But I am not sure whether I should use Google test, Qt test or boost?
What are the benefits and drawbacks of them?
Also with the tests, do I need to create a new test project? How would I be able to add automated testing to an existing codebase that uses CMake? -
Hi,
The Qt Test is designed to test Qt application/libraries and is included. The other two add two new dependencies and you will have to handle the event loop part yourself.
You can take a look at the Qt 6 sources to see how you can manage tests.
Note that it is better to implement unit tests per unit of your library/application. One big contains all tests class will not allow you to have fine grained information about what is working and what not.
-
@jkwok678 said in Automated testing recomendations:
How would I be able to add automated testing to an existing codebase that uses CMake?
CTest can handle this easily
You can take a look at the Qt 6 sources to see how you can manage tests.
While it's is a solid advice, that repo is very advanced.
Have a look first at this example repo for the initial starting point, you can refine it later on -
@SGaist Do you mean that I should create maybe a new test project for every class?
@VRonin Is CTest an alternative to Qt Test and the other testing frameworks?Also in terms of ease of use and functionality, which one do you think would be best?
I have only used JUnit with Java before, are there any testing frameworks that are fairly similar? -
@jkwok678 said in Automated testing recomendations:
Do you mean that I should create maybe a new test project for every class?
Yes, QtTest works better that way. Usually a project would just consist of a .cpp file and a CMakeLists.txt
Is CTest an alternative to Qt Test and the other testing frameworks?
No, CTest is the framework to integrate tests (GoogleTest, QtTest, etc.) into CMake projects.
Also in terms of ease of use and functionality, which one do you think would be best?
For Qt projects I only used QtTest so I'm not in a position to offer an opinion
-
CTest is the test runner.
Yes that's the starting point.
Then you can have separated functional tests where you validate the high level functionalities and finally integration tests where you ensure that the final application is working as expected.