Comparison of C++ unit test frameworks [closed]

A new player is Google Test (also known as Google C++ Testing Framework) which is pretty nice though. #include <gtest/gtest.h> TEST(MyTestSuitName, MyTestCaseName) { int actual = 1; EXPECT_GT(actual, 0); EXPECT_EQ(1, actual) << “Should be equal to one”; } Main features: Portable Fatal and non-fatal assertions Easy assertions informative messages: ASSERT_EQ(5, Foo(i)) << ” where i … Read more

How to start working with GTest and CMake

The solution involved putting the gtest source directory as a subdirectory of your project. I’ve included the working CMakeLists.txt below if it is helpful to anyone. cmake_minimum_required(VERSION 2.6) project(basic_test) ################################ # GTest ################################ ADD_SUBDIRECTORY (gtest-1.6.0) enable_testing() include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) ################################ # Unit Tests ################################ # Add test cpp file add_executable( runUnitTests testgtest.cpp ) # Link test … Read more

How to set up Google C++ Testing Framework (gtest) with Visual Studio 2005

(These instructions get the testing framework working for the Debug configuration. It should be pretty trivial to apply the same process to the Release configuration.) Get Google C++ Testing Framework Download the latest gtest framework Unzip to C:\gtest Build the Framework Libraries Open C:\gtest\msvc\gtest.sln in Visual Studio Set Configuration to “Debug” Build Solution Create and … Read more

CMake + GoogleTest

This is an unusual case; most projects specify install rules. CMake’s ExternalProject_Add module is maybe the best tool for this job. This allows you to download, configure and build gtest from within your project, and then link to the gtest libraries. I’ve tested the following CMakeLists.txt on Windows with Visual Studio 10 and 11, and … Read more