user2751691
user2751691

Reputation: 411

How to run local c++ unit tests using google test in Xcode 6.1.1

I am new to google test and xcode. Please provide any help.

I download the google test, and I use xcode to open the googletest.xcodeproj in googletest. I build the project successfully.

I want to test against my project. I have some unit tests written in myProject/test/unittest.cc The unit tests contain functions that test against myproject/src/some.cc

I did some search, I do not have shell tool as an option in my xcode version. How should I set up the project in xcode? When I try New project, and import the myProject, it opened a new window with the myProject, but when I try to add the target dependencies, I could not see gtest.framework.

May I get information on how to set up the google test for the myProject in xCode please? Thank you.

Upvotes: 3

Views: 2713

Answers (1)

anche
anche

Reputation: 66

I am using Xcode version 6.3 (6D570).

I used this guide http://bitrage.de/wp/google-test-with-xcode-6-and-c11/ and it worked fine for me.

I had a couple of issues:

  1. I did not get a nice "archive" icon for the compiled gtest.framework as in the guide (step 7). My icon looked like a blank page.
  2. I tried to unit test the code declared in a header file but implemented in a cpp file. To do that I had to:
    • remove the main() method from the cpp file being unit tested, and
    • add the cpp file in question to the "Tests" target (see step 10 in the guide) "Build Phases"->"Compile Sources".

Good luck!

Upvotes: 2

Related Questions