This gist shows how resources aren't getting included in XCTest bundles
To reproduce:
- Use a Mac that has Xcode installed
- Clone this gist
- Build and test with cmake:
cmake -H. -Bbuild && (cd build; make && ctest --output-on-failure)
- Observe test failure
The output I'm getting looks like this:
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/mcg/src/testing/bundle-resources/build
[ 50%] Built target host_app
[100%] Built target xctest
Test project /Users/mcg/src/testing/bundle-resources/build
Start 1: xctest
1/1 Test #1: xctest ...........................***Failed 0.17 sec
Test Suite 'All tests' started at 2019-12-05 10:52:20.900
Test Suite 'xctest.xctest' started at 2019-12-05 10:52:20.901
Test Suite 'FSTExampleTests' started at 2019-12-05 10:52:20.901
Test Case '-[FSTExampleTests testBundleLoading]' started.
/Users/mcg/src/testing/bundle-resources/test.mm:17: error: -[FSTExampleTests testBundleLoading] : ((error) == nil) failed: "Error Domain=NSCocoaErrorDomain Code=260 "The folder “Resources” doesn’t exist." UserInfo={NSFilePath=/Users/mcg/src/testing/bundle-resources/build/xctest.xctest/Contents/Resources, NSUserStringVariant=(
Folder
), NSUnderlyingError=0x7ff099c17e80 {Error Domain=NSOSStatusErrorDomain Code=-43 "fnfErr: File not found"}}"
/Users/mcg/src/testing/bundle-resources/test.mm:18: error: -[FSTExampleTests testBundleLoading] : (([files count]) equal to (1)) failed: ("0") is not equal to ("1")
Test Case '-[FSTExampleTests testBundleLoading]' failed (0.096 seconds).
Test Suite 'FSTExampleTests' failed at 2019-12-05 10:52:20.996.
Executed 1 test, with 2 failures (0 unexpected) in 0.096 (0.096) seconds
Test Suite 'xctest.xctest' failed at 2019-12-05 10:52:20.997.
Executed 1 test, with 2 failures (0 unexpected) in 0.096 (0.096) seconds
Test Suite 'All tests' failed at 2019-12-05 10:52:20.997.
Executed 1 test, with 2 failures (0 unexpected) in 0.096 (0.096) seconds
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 0.17 sec
The following tests FAILED:
1 - xctest (Failed)
Errors while running CTest
No resources are created:
$ find build/xctest.xctest -type f
build/xctest.xctest/Contents/MacOS/xctest
build/xctest.xctest/Contents/Info.plist
I would have expected to also be present
build/xctest.xctest/Contents/Resources/test.json