For unit tests, googletest has always been used. To use it, you just need to download the source code, compile it, and reference it in the test project. Googletest provides many macros to make it easy to organize test cases. Catch2 is simpler to use than Googletest, and the source code is a header file. You only need to reference Catch2. HPP to your project. For testing tools, I think Catch’s TEST_CASE+SECTION is simpler.
1, the googletest
GoogleTest framework development process almost covers the core knowledge of C++, is the novice training C++ development ability of the best project!
Github.com/google/goog…
Github.com/nholthaus/g…
2, Catch2
Github.com/catchorg/Ca…
3, GoogleTest and Catch2
Catch2 has the following advantages:
- Easy to use: just download Catch. HPP and include it in your project
- Don’t rely on external libraries: as long as you can compile C++11, the C++ standard library is fine
- Test cases can be divided into sections: each setcion is an independent unit of execution
- BDD style test mode is provided: you can use the Given-when-then section to do BDD tests
- Just use a core Assertion macro for comparison. Use standard C++ operators for comparison, but you can decompose the expression, recording the values to the left and right of the expression equal sign
- You can name your tests with any form of string without worrying about whether the name is valid
Blog.csdn.net/wanywhn/art…
Blog.csdn.net/weixin_4298…
4, Qt Test
Doc. Qt. IO/qt – 5 / qttest…
Doc. Qt. IO/qt – 5 / qsigna…
5, Qt Test learning tutorial
Qt program unit test learning record: on
Beondxin.blog.csdn.net/article/det…
Qt program unit test learning record: in
Beondxin.blog.csdn.net/article/det…
Qt program unit test learning record: next
Beondxin.blog.csdn.net/article/det…