I am strougling to set up c++ unit testing with googletest for Xcode 4.6. The instructions that come with the download of googletest were written in 2008 and don't correspond to the current Xcode interface. I think I got googletest to compile (which wasn't trivial,) but now I am having issues following this tutorial to get a unit test to work. How do I implement unit testing with googletest in Xcode 4.6?
When you have already got the gtest framework to compile its actually not that hard anymore.
Write your testcases using the macros as described here: https://github.com/google/googletest/blob/master/docs/primer.md#simple-tests
And then to run all your tests:
#include "gtest/gtest.h"
int main(int argc, const char * argv[])
{
testing::InitGoogleTest(&argc, (char**)argv);
return RUN_ALL_TESTS();
}
I've created a seperate build-target for Unit tests where this is the actual main.cpp This works for me using the current Xcode version (4.6.3)