Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 474
user2751691 Avatar asked Jan 02 '26 04:01

user2751691


1 Answers

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!

like image 171
anche Avatar answered Jan 03 '26 18:01

anche



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!