值得研究的测试框架
Qt Test
Qt Test is a framework for unit testing Qt based applications and libraries. Qt Test provides all the functionality commonly found in unit testing frameworks as well as extensions for testing graphical user interfaces.
Quick Test
This is another code you can use to diagnose and fix problems on your phone. Through the Quick Test menu, you can test your device’s audio and vibration components. Additionally, you can check your audio and microphone functionality.
Google Test
Google Test (also known as gtest) is a unit testing library for the C++ programming language, released under the BSD 3-clause license[2] and based on the xUnit architecture.[3] Google Test is able to be compiled for a variety of POSIX and Microsoft Windows platforms, allowing unit-testing of C sources as well as C++ with minimal source modification.
Boost Test
Boost test is a unit test framework, It is more neat approach to test individual pieces of codes. The Boost.Test library provides both an easy to use and flexible set of interfaces for writing test programs, organizing tests into simple test cases and test suites, and controlling their runtime execution.
CPPUnit
ppUnit is a unit testing framework module for the C++ programming language. It allows unit-testing of C sources as well as C++ with minimal source modification. It was started around 2000 by Michael Feathers as a C++ port of JUnit for Windows and ported to Unix by Jerome Lacoste.[2] The library is released under the GNU Lesser General Public License.
Catch Test
There are other C++ testing libraries like Google Test, CppUnit, Cute etc. But they are huge and need a lot of dependencies to get started with.
Catch2 a header only framework, just download the catch2.hpp file, do an #include and you are good to go. This simplicity and flexibility is a huge bonus for small and medium scale projects. And its open source
Our Test Project
Let us try and write unit tests for this humble Binary Search Project.
├── build
├── CMakeLists.txt
├── include
│ └── binary_search.hpp
├── src
│ ├── binary_search.cpp
│ └── main.cpp
└── tests
├── catch.hpp
└── test.cpp
4 directories, 6 files
只需header only,引入头文件就可以使用测试框架了,它不香吗?