Search code examples
c++eclipseunit-testinggoogletestcunit

Setting Up Google Test to Run through C/C++ Test Runner Plug-In in Eclipse on Ubuntu 12.04


Here's what I've tried:

In project properties I have included libgtest_main.a and libgtest.a under the libaries tab.

In run configurations under the C++ Unit tab, I have set C/C++ testing to Google Tests Runner.

In run configs, under the main tab, the C/C++ application is set as the binary file that was created during the build of my project.

I have created a test folder as part of my project and written my tests in there.

This is my code:

#include "../src/agent.h"
#include "../src/agent.cpp"
#include "gtest/gtest.h"

TEST(AgentTest, voidConstructorWorksProperly) {
Agent testAgent = Agent();
ASSERT_EQ(0, testAgent.getBrain());
}


int main(int argc, char **argv) {
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();

}

I'm getting a syntax error on on the TEST function and a "could not be resolved" on the InitGoogleTest and RUN_ALL_TESTS.

Hope someone can help - I've been at this for hours and it seems like something simple I've missed.


Solution

  • I had a similar problem and solved it running this script

           ./scripts/fuse_gtest_files.py . /yourprojectdir/
    

    it is present in where you installed the google test framework (i.e. /tmp/gtest-1.5.0)

    I dont know if it is the best solution but it worked for me.