Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test Setting up Google Test

Setting up Google Test

Top  Previous  Next

The GoogleTest lib files:

 

Isolator++ installs pre-compiled versions of the Google Test Framework (x86 and x64), as a runtime dynamically linked library, using the VS 2010 runtime libraries. You can also link with other versions of the dll, or compile it yourself.

 

Setting up the application to run Google Test tests.

 

1.Add the GoogleTest Include folder to the C/C++->General->Include Directories: "C:\Program Files (x86)\Typemock\Isolator++\gtest\Include"
2.Add the relevant GoogleTest library in the Linker->Input->Additional Dependencies: gtest.lib.
3.Copy IsolatorCore.dll from C:\Program Files (x86)\Typemock\Isolator++\bin (32 or 64 bit version) to the output folder of the test executable

 

Write the _tmain function to run the tests. 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++ 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.

With Google Test, results look like this:

gTestResults

 

 

In the result window, you