DanMatlin
DanMatlin

Reputation: 1252

Write C++ unit tests using XCTest

I have an application in C++ and I use Xcode 7.

I want to start writing unit test cases for my application. Problem is XCTest doesn't support C++ unit tests. I will have to write wrappers around each of my test classes and that would cause a lot of overhead. Is there any sane way to write C++ unit tests using XCTest?

Or do I have to integrate GoogleTest with Xcode to write test cases in C++?

Upvotes: 4

Views: 3121

Answers (2)

JWWalker
JWWalker

Reputation: 22717

You can create an Objective-C++ test file (extension .mm) that tests your C++ classes with XCTest.

Upvotes: 2

Bartosz Przybylski
Bartosz Przybylski

Reputation: 1656

Currently Xcode doesn't support C++ (in terms of testing) nor GoogleTest. But there are already written wrappers which hook up into gtest and Xcode testing system, and exploits the two to provide nice UI for testing, while not forcing anything too crazy in when it comes to wrappers.

I am using this:

https://github.com/mattstevens/xcode-googletest

It is a little outdated but it gets the job done.

Upvotes: 3

Related Questions