Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift CI Tests with Travis - Test runner exited before starting test execution

I recently started with implementing Travis, but I couldn't get it working. When I run the test locally they succeed.

Can anyone help me how to get it working properly?

.travis.yml

language: swift
osx_image: xcode10.1
script:
  - xcodebuild -scheme sample -workspace sample.xcodeproj -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' build test

sampleTest

class sampleTests: XCTestCase {

    func testThis() {
        XCTAssertTrue(true)
    }
}

error:

2018-12-09 12:12:27.188 xcodebuild[2161:5999] [MT] IDETestOperationsObserverDebug: 111.527 elapsed -- Testing started completed.
2018-12-09 12:12:27.188 xcodebuild[2161:5999] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2018-12-09 12:12:27.189 xcodebuild[2161:5999] [MT] IDETestOperationsObserverDebug: 111.527 sec, +111.527 sec -- end
2018-12-09 12:12:27.190 xcodebuild[2161:5999] Error Domain=IDETestOperationsObserverErrorDomain Code=6 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted, NSUnderlyingError=0x7f981ebb72f0 {Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Test runner exited before starting test execution." UserInfo={NSLocalizedDescription=Test runner exited before starting test execution., NSLocalizedRecoverySuggestion=If you believe this error represents a bug, please attach the result bundle at /Users/travis/Library/Developer/Xcode/DerivedData/sample-dxurjdnpbvvpbicqtjbvdmsoceyy/Logs/Test/Test-sample-2018.12.09_12-10-05-+0000.xcresult}}}
Testing failed:
    sample.app (2474) encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying error: Test runner exited before starting test execution.))
** TEST FAILED **
The command "xcodebuild -scheme sample -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' test" exited with 65.
Done. Your build exited with 1.
like image 514
Milander Avatar asked Dec 09 '18 12:12

Milander


1 Answers

There are some issues with UI tests with the new build system introduced in Xcode 10. You should add -UseModernBuildSystem=NO.

The full script I am using is:

- xcodebuild -workspace sample.xcworkspace -scheme sample -sdk iphonesimulator12.1 -destination "platform=iOS Simulator,OS=12.1,name=iPhone Xs Max" -UseModernBuildSystem=NO test | xcpretty --test --color; test ${PIPESTATUS[0]} -eq 0

Note that I also use xcpretty, with some params to make sure the logs don't become lengthy. The last part is to make sure that the build fails in case a test fails.

Hope it helps!

like image 58
Peter Robert Avatar answered Sep 21 '22 19:09

Peter Robert