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

What is the best way of testing private methods with GoogleTest? [closed]

There are at least two more options. I’ll list out some other options you should consider by explaining a certain situation. Option 4: Consider refactoring your code so that the part you want to test is public in another class. Typically when you’re tempted to test a class’s private method, it’s a sign of bad … Read more

Test a specific exception type is thrown AND the exception has the right properties

A colleague came up with the solution by just re-throwing the exception. The knack: no need of extra FAIL() statements, just the two EXPECT… calls that test the bits you actually want: the exception as such and its value. TEST(Exception, HasCertainMessage ) { // this tests _that_ the expected exception is thrown EXPECT_THROW({ try { … 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

Is Google Test OK for testing C code?

It is pretty common to test C code using a C++ testing frameworks, even the leading book on the subject follows this approach. I have used googletest extensively in the past to unit test C code and can recommend it. I have written a blog post about it that might be useful: http://meekrosoft.wordpress.com/2009/11/09/unit-testing-c-code-with-the-googletest-framework/

How to set up googleTest as a shared library on Linux

Before you start make sure your have read and understood this note from Google! This tutorial makes using gtest easy, but may introduce nasty bugs. 1. Get the googletest framework wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz Or get it by hand. I won’t maintain this little How-to, so if you stumbled upon it and the links are outdated, feel … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)