GoogleTest Installation for Eclipse/C++ Instructions


These instructions review how to install the GoogleTest unit testing framework library folder (googletestlib) in Eclipse/C++. Then they explain how to create a project that uses the library. At various times during the quarter you will be supplied with unit tests to run on the code you are writing. We often grade programs using these unit tests may be asked to replace various .hpp or .cpp files and recompile the library.


Googletestlib Installation (Quick!)

  1. Download and unzip the googletestlib.zip file; the result is a googletestlib folder.

  2. Locate the workspace folder (typically C:\Users\yourname\workspace) and put the googletestlib folder you downloaded and unzipped into this workspace folder. This folder contains .a files (groups of .o files) that allow us to perform unit tests easily on the code that we develop.


Creating a Project that Uses the Googletestlib

  1. Download and unzip the test_googletest.zip file; the result is a googletest folder.

  2. Put the googletest folder you downloaded and unzipped into the workspace folder (mentioned above).

  3. Create a project from this folder. Normally you will perform the steps needed to ensure this program uses the courselib correctly, but this simple test does not require these steps, so they are not included in this document.

  4. Right-click the test_googletest icon in the Project Explorer tab.
    Select Properties which appears at the bottom as follows.

  5. In the Properties for test_googletest popup window

  6. Disclose the test_googletest icon in the Project Explorer.
    Disclose the src icon in the Project Explorer, which appears as follows.

    Examine the counter files (both .hpp and .cpp), which describe a trivial class. The test_counter.cpp is the code that is run by GoogleTest.

  7. Double-click the test_counter.cpp icon. The test_counter.cpp editor tab appears as follows (ignore the errors).

  8. Either click the Hammer icon or right-click in the test_googletest icon in the Project Explorer tabl and select Build Project. The Console window should show the following.

  9. Either click the Run icon or right-click in the test_counter.cpp editor tab and select select Run As | 1 Local C/C++ Application illustrated below.

    The program should begin running and the Console window should show the following.

    The output shows passed and failed tests. Examine the counter files (both .hpp and .cpp), which describe a trivial class, and the test_counter.cpp which contains the code that is run by GoogleTest to see why the first test passed and the second one failed.