iOS - Running UITests crash on CircleCI

All is on title. Running UITests success locally with fastlane scan but once on CircleCI, I get an error Exit status 65.

Here my simple code:

class ExampleUITests: XCTestCase {

	let app = XCUIApplication()
	
	override func setUp() {
		super.setUp()
		
		continueAfterFailure = false
		setupSnapshot(app)
		app.launch()
	}
	
	override func tearDown() {
		super.tearDown()
		
		app.terminate()
	}
	
	func testExample() {
		snapshot("01TestExample")
	}    	
}

Here the error:

Test Suite ExampleUITests.xctest started
ExampleUITests
âś— testExample, Application Example is not running


ExampleUITests.ExampleUITests
testExample, Application Example is not running
SnapshotHelper.swift:226


	 Executed 1 test, with 1 failure (0 unexpected) in 35.061 (35.063) seconds

** TEST FAILED **
[10:05:49]: Exit status: 65
+--------------------+---+
|      Test Results      |
+--------------------+---+
| Number of tests    | 1 |
| Number of failures | 1 |
+--------------------+---+


[!] Tests have failed

It seems Simulator is not loaded. How can I fix it ?

Hi there!

I’m facing the exactly same problem. Locally all UI Tests are running fine (using fastlane scan command) and the simulator is performing the UI Tests as expected. However, CircleCI is not able to run the tests and exit’s with “Exit status: 65” along with the error message “Application X is not running”.

Have you been able to fix this?

Best regards

Hi @ftsz, I stopped to use CircleCi because it took me too much time to maintain and whereas I’m alone on the project. But I can share you my config:

# .circleci/config.yml
version: 2
jobs:
  build-and-test:
    macos:
      xcode: "9.3.0"
    shell: /bin/bash --login -eo pipefail
    working_directory: /Users/distiller/project
    environment:
      GYM_CODE_SIGNING_IDENTITY: "iPhone Distribution: YOUR_CODE_SIGNING_IDENTITY"
      FL_OUTPUT_DIR: /Users/distiller/project/output
      LANG: en_US.UTF-8
      LC_ALL: en_US.UTF-8

    steps:
      - checkout

     # - run: brew upgrade sqlite3

     # - run:
     #      name: Setup - Set Ruby Version
     #      command: echo "ruby-2.4" > ~/.ruby-version

      - restore_cache:
              keys:
                - gems-{{ checksum "Gemfile.lock" }}

      - run:
            name: Setup - Running bundle install
            command: bundle check || bundle install --path vendor/bundle

      - save_cache:
            key: gems-{{ checksum "Gemfile.lock" }}
            paths:
              - vendor/bundle

      - restore_cache:
            keys:
              - pods-{{ checksum "Podfile.lock" }}

      - run:
            name: Setup - Running pod install
            command: |
              curl -sS https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash
              bundle exec pod install

      - save_cache:
              key: pods-{{ checksum "Podfile.lock" }}
              paths:
                - Pods

      - run:
            name: Build and run tests
            command: bundle exec fastlane test
            environment:
              SCAN_DEVICE: iPhone 6

workflows:
  version: 2
  build-and-test:
    jobs:
      - build-and-test

Hope it helps you

1 Like

Hi @grifas, thanks for the reply.

I was able to fix the issue on our project by handling system dialogs (location permission, etc) via addUIInterruptionMonitor and adding
- run: name: pre-start simulator command: xcrun instruments -w "iPhone 6 (11.3) [" || true
to the Circle CI config file.

Having the same issue where tests run perfectly fine locally but fail on CircleCI. Any luck with a definite fix or determining the cause of this? I have already implemented addUIInterruptionMonitor however I am still seeing the issue.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.