[cmake-developers] [PATCH 0/2] XCTest support

Gregor Jasny gjasny at googlemail.com
Tue Dec 9 06:02:23 EST 2014


Hi Brad,

> I'm not very familiar with Xcode-specific things like xctest binaries.
> Please briefly explain their purpose, how they work, and how developers
> might use them.  How should they be treated on non-Apple platforms?

XCTest is Apples latest idea of how to write Unit Tests for App Bundles
and Frameworks. Xcode itself provides nice integration within the IDE
to run and examine tests. There are also some 3rd party drivers for
Google Test available.

See: https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/testing_with_xcode/

XCTest bundles are regular CFBundles with a special product type and
suffix. They contain just the Unit Test code and get loaded directly
into the target under test (the test host).

On non-Apple platforms and Xcode < 5.0 those XCTest bundles are pretty
useless.

>> add_library(CocoaExampleTest MODULE ...)

> Why is it a MODULE?

Because they need to be a Bundle. And you need to build a MODULE library
to get that.

>>   BUNDLE_EXTENSION xctest
>>   BUNDLE TRUE

> These two could be implied by XCTEST as needed.

Done.

>>   XCTEST TRUE
>>   XCTEST_HOST CocoaExample

> Please explain what each of these does.

XCTEST is just the property to mark a MODULE library as an XCTest Bundle.

XCTEST_HOST is the target name of the App Bundle or Framework this test
is intended for. I made the observation that if you omit the TEST_HOST
and BUNDLE_LOADER properties in the Xcode project file, then Xcode is
not very fault tolerant and crashes. That's why I enforce them or
error out.

Note: It is currently not possible to run the tests without opening Xcode
once to (auto) generate the Schema files. Otherwise calling
"xcodebuild test -scheme CocoaExample" will not recognise the scheme. 

Thanks,
Gregor

Gregor Jasny (2):
  Add handling for XCTest bundles
  Add XCTest Example

 Help/manual/cmake-properties.7.rst                 |   2 +
 Help/prop_tgt/XCTEST.rst                           |   9 +
 Help/prop_tgt/XCTEST_HOST.rst                      |   5 +
 Source/cmGlobalXCodeGenerator.cxx                  |  62 +-
 Source/cmTarget.cxx                                |  19 +-
 Source/cmTarget.h                                  |   3 +
 Tests/CocoaExample/CMakeLists.txt                  |  25 +
 Tests/CocoaExample/CocoaExample/AppDelegate.h      |   7 +
 Tests/CocoaExample/CocoaExample/AppDelegate.m      |  18 +
 Tests/CocoaExample/CocoaExample/Info.plist.in      |  32 +
 Tests/CocoaExample/CocoaExample/MainMenu.xib       | 680 +++++++++++++++++++++
 Tests/CocoaExample/CocoaExample/main.m             |   5 +
 .../CocoaExampleTests/CocoaExampleTests.m          |  13 +
 13 files changed, 875 insertions(+), 5 deletions(-)
 create mode 100644 Help/prop_tgt/XCTEST.rst
 create mode 100644 Help/prop_tgt/XCTEST_HOST.rst
 create mode 100644 Tests/CocoaExample/CMakeLists.txt
 create mode 100644 Tests/CocoaExample/CocoaExample/AppDelegate.h
 create mode 100644 Tests/CocoaExample/CocoaExample/AppDelegate.m
 create mode 100644 Tests/CocoaExample/CocoaExample/Info.plist.in
 create mode 100644 Tests/CocoaExample/CocoaExample/MainMenu.xib
 create mode 100644 Tests/CocoaExample/CocoaExample/main.m
 create mode 100644 Tests/CocoaExample/CocoaExampleTests/CocoaExampleTests.m

-- 
1.9.3 (Apple Git-50)



More information about the cmake-developers mailing list