Download and install gtest:
wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz
Isolator++ Professional also installs the Google Test Framework (x64) static library and header files.
Setting up the makefile to run Google Test tests.
The installed gtest files are located in /usr/share/typemock/Examples/Common/gtest_files.
GTEST_FILES_DIR = /usr/share/typemock/Examples/Common/gtest_files # Using the installed gtest
1. | Add the GoogleTest Include directory. |
GTEST_INCDIR = $(GTEST_FILES_DIR)
INC_FLAGS += -I$(GTEST_INCDIR)
2. | Add the relevant GoogleTest library. |
GTEST_LIBDIR = $(GTEST_FILES_DIR)/lib64
LIBS += -L $(GTEST_LIBDIR) -lgtest -lgtest_main
Write the _tmain function to run the tests (as in ). With Google Test it looks like this:
#include <gtest\gtest.h>
int _tmain(int argc, _TCHAR* argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Write tests using your test framework, in a separate cpp file.
You can write your first test with Isolator++ Professional in a separate class, deriving from the Test class:
#include <gtest\gtest.h>
#include "Isolator.h"
#include "CodeYouWantToTest.h"
class MyTestSuite : public ::testing::Test
{
};
TEST_F(MyTestSuite, TheTestName)
{
FAKE_STATICS<ClassWithStaticCalls>();
WHEN_CALLED(ClassWithStaticCalls::StaticIntCall()).Return(1);
ASSERT_EQ(1, ClassWithStaticCalls::StaticIntCall());
ISOLATOR_CLEANUP();
}
Compile and run the console application to run the tests.

In the terminal you'll see which tests passed and which didn't.
|