I'm working on a plugin for some drafting software. The plugin takes the form of a dynamically loaded mach-o bundle.

The software vendor provides a template plugin in the form of an XCode project.

The whole thing is written in C++, but XCode doesn't seem to support C++ in it's testing bundle targets.

Tests could be written in Objective-C that include the C++ code, but that's not a great solution.

Another option would be to create another executable target that runs it's own bunch of tests.

What have others done in this situation?

What's the best way to write unit tests in XCode when using C++?

  • 1
    Why is putting your tests into an Objective-C++ file "not a great solution"? You don't need to put any Objective-C or Objective-C++ into your code, just the test harness. – user1118321 Feb 11 '19 at 5:47
  • IMHO this question boils down to "which other C++ testing frameworks exist for Mac". That looks to me like a 3rd party resource request in disguise. Unfortunately, 3rd party resource requests are off-topic on this site. If you really don't like to use Objective-C++ for your tests (though I don't know why, you gave no reasons), just google for "C++ unit testing framework", you will probably find some tool. – Doc Brown Feb 11 '19 at 6:47
  • Writing a test harness in objective-c or objective-c++ at the time seemed like unnecessary overhead. I’ve not written any objective-c before. I’m not interested in any 3rd party resources, which is why I never mentioned anything about other testing frameworks – oorst Feb 11 '19 at 11:31
  • @oorst: even if you did not mention any 3rd party resources, that does not mean it would not be the most sensible way of approaching your issue. So what did your google search tell you, did you find something useful? – Doc Brown Feb 12 '19 at 8:55
  • @DocBrown: It would appear that writing the tests in Objective-C++ would really be no different to writing them in plain C++. I'm just inexperienced with XCode and Objective-C and panicked when I couldn't see a clear way to use XCode's built in testing targets. Apple has some really good videos on using XCode by the way. – oorst Feb 12 '19 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.