Getting started

Download the recent installer and run it. There are a few folders under the Typemock:

  • Bin: contains the Isolator.lib header file. You’ll need this to link to your test project.
  • Include: contains the Isolator.h header file. You’ll need this to compile your test project.
  • Examples: A solution containing examples of Isolator++ features
  • GTest: Google testing framework. You’ll need this to run the examples.

 Isolator++ tests runs inside an executable. To start, create a new C++ Console Application.

  

Make sure the project is compiled to a console application:

 

Open the project properties. Add the Isolator++ include folder to the include directories.

Add the Isolator.lib to the linker input list

  

Set up additional includes and libraries, for the test frameworks and the code under test. For GTest, which is deployed with Isolator++, use:

  • Add the GTest Include folder: "C:Program FilesTypemockIsolatorgtestInclude"
  • Add the GTest library: "gtestd.lib"

Write the _tmain function to run the tests. With GTest it looks like this:

#include "stdafx.h"
#include    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. In GTest, TEST_F identifies a test, the first argument is the name of the test, and the second is the scenario. For example:

/ Changing return value
TEST_F(IsolatorTests, ChangeReturnedIntValue)
{
WHEN_CALLED(fakeConcrete->GetInt()).Return(5);
      ASSERT_EQ(5, fakeConcrete->GetInt());
}

 

 

Compile and run the console application to run the tests. With GTest, results look like this:

In the result window, you’ll see which tests passed, and which didn’t.

That’s it! You’ve just run your first tests. It’s time to learn more on Isolator++ features.