iosunit-testinggithub-actionsfastlane

How to prevent UITests suite from executing with Fastlane?


Why does fastlane seemingly run the UITests target as well despite the fastfile specifying the unit test target only?

only_testing: 'CICDDemoTests',

This is what I see in the logs and the workflow seems to spend a considerable amount of time here:

[05:37:36]: ▸ Running Tests: [CICDDemoUITests] Touching CICDDemoUITests.xctest
[05:57:22]: ▸   CICDDemoUITests-Runner (9096) encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying Error: Test crashed with signal kill before starting test execution.))

I see the same behaviour when running bundle exec fastlane scan locally on my Mac with similar logs. The Github actions workflow logs gist is as follows:

[05:37:30]: ▸ [CICDDemo] Processing empty-CICDDemo.plist
[05:37:31]: ▸ Signing CICDDemo.app (in target 'CICDDemo' from project 'CICDDemo')
[05:37:31]: ▸ Running Tests: [CICDDemo] Touching CICDDemo.app
[05:37:31]: ▸ Build Succeeded
[05:37:31]: ▸ [CICDDemo] Processing empty-CICDDemo.plist
[05:37:36]: ▸ [CICDDemoTests] Processing empty-CICDDemoTests.plist
[05:37:36]: ▸ Signing CICDDemoTests.xctest (in target 'CICDDemoTests' from project 'CICDDemo')
[05:37:36]: ▸ Running Tests: [CICDDemoTests] Touching CICDDemoTests.xctest
[05:37:36]: ▸ Signing CICDDemo.app (in target 'CICDDemo' from project 'CICDDemo')
[05:37:36]: ▸ [CICDDemoUITests] Processing empty-CICDDemoUITests.plist
[05:37:36]: ▸ [CICDDemoUITests] Copying Info.plist
[05:37:36]: ▸ Signing CICDDemoUITests.xctest (in target 'CICDDemoUITests' from project 'CICDDemo')
[05:37:36]: ▸ Signing CICDDemoUITests-Runner.app (in target 'CICDDemoUITests' from project 'CICDDemo')
[05:37:36]: ▸ Running Tests: [CICDDemoUITests] Touching CICDDemoUITests.xctest
[05:57:22]: ▸ Testing failed:
[05:57:22]: ▸   CICDDemoUITests-Runner (9096) encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying Error: Test crashed with signal kill before starting test execution.))
[05:57:22]: ▸ Failing tests:
[05:57:22]: ▸   CICDDemoTests.testOperation()
[05:57:22]: ▸ ** TEST FAILED **

My fastfile contents:

platform :ios do

    # Lane configuration
    lane :unit_tests do
        scan(
            project: 'CICDDemo',
            scheme: 'CICDDemo',
            configuration: 'Debug',
            only_testing: 'CICDDemoTests',
            devices: devices,
            prelaunch_simulator: true,
            clean: true,
            skip_build: true,
            xcodebuild_formatter: 'xcbeautify -qq --is-ci --renderer github-actions',
            code_coverage: true,
            output_types: 'junit'
            )
    end
end

Solution

  • So it seems that when running bundle exec fastlane scan, it ignores the fastfile and runs the entire test suite including Unit & UI tests. If one runs the lane instead via bundle exec fastlane unit_tests it does ignore UITests.

    [10:29:46]: ▸ Loading...
    [10:29:47]: ▸ 2023-10-25 10:29:47.143 xcodebuild[25203:305328] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
    [10:29:48]: ▸ Signing UnitTestingDemo.app (in target 'UnitTestingDemo' from project 'UnitTestingDemo')
    [10:29:48]: ▸ Build Succeeded
    [10:29:50]: ▸ [UnitTestingDemo] Processing empty-UnitTestingDemo.plist
    [10:29:51]: ▸ [UnitTestingDemoTests] Processing empty-UnitTestingDemoTests.plist
    [10:29:51]: ▸ Signing UnitTestingDemoTests.xctest (in target 'UnitTestingDemoTests' from project 'UnitTestingDemo')
    [10:29:51]: ▸ Signing UnitTestingDemo.app (in target 'UnitTestingDemo' from project 'UnitTestingDemo')
    [10:29:51]: ▸ [UnitTestingDemoUITests] Processing empty-UnitTestingDemoUITests.plist
    [10:29:52]: ▸ Signing UnitTestingDemoUITests.xctest (in target 'UnitTestingDemoUITests' from project 'UnitTestingDemo')
    [10:30:31]: ▸ Test Suite UnitTestingDemoTests started on 'Clone 1 of iPhone SE (3rd generation) - UnitTestingDemo (25470)'
    [10:30:31]: ▸     ✔ testExample on 'Clone 1 of iPhone SE (3rd generation) - UnitTestingDemo (25470)' (0.003 seconds)
    [10:30:31]: ▸     ✔ testPerformanceExample on 'Clone 1 of iPhone SE (3rd generation) - UnitTestingDemo (25470)' (0.351 seconds)
    [10:30:31]: ▸ 2023-10-25 10:30:31.895 xcodebuild[25203:305328] [MT] IDETestOperationsObserverDebug: 39.770 elapsed -- Testing started completed.
    [10:30:31]: ▸ 2023-10-25 10:30:31.896 xcodebuild[25203:305328] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
    [10:30:31]: ▸ 2023-10-25 10:30:31.896 xcodebuild[25203:305328] [MT] IDETestOperationsObserverDebug: 39.770 sec, +39.770 sec -- end
    [10:30:32]: ▸ Test Succeeded
    [10:30:35]: Skipping HTML... only available with `xcodebuild_formatter: 'xcpretty'` right now
    [10:30:35]: Your 'xcodebuild_formatter' doesn't support these 'output_types'. Change your 'output_types' to prevent these warnings from showing...
    +------------------------+
    |      Test Results      |
    +--------------------+---+
    | Number of tests    | 2 |
    | Number of failures | 0 |
    +--------------------+---+