Mihai Fischer
Mihai Fischer

Reputation: 339

run Kiwi tests on Jenkins with ios-sim

I want to run Kiwi tests for my app, but I'm pretty new to Jenkins so probably I'm missing out something.

I installed iOS-sim on the mac that runs Jekins. I run $ ios-sim --version just to make sure it was installed.

In my project in the Build Phases of my test target I added this script:

#!/bin/sh
# Launch application using ios-sim and set up environment to inject test bundle into application
# Source: http://stackoverflow.com/a/12682617/504494

if [ "$RUN_APPLICATION_TESTS_WITH_IOS_SIM" = "YES" ]; then
    test_bundle_path="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION"
    environment_args="--setenv DYLD_INSERT_LIBRARIES=/../../Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection --setenv XCInjectBundle=$test_bundle_path --setenv XCInjectBundleInto=$TEST_HOST"
    ios-sim launch $(dirname $TEST_HOST) $environment_args --args -SenTest All $test_bundle_path
    echo "Finished running tests with ios-sim"
else
    "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
fi

Both my app and test schemes are shared.

Every time I run the Jenkins jobwith this following shell script:

xcodebuild -sdk iPhoneSimulator -workspace path/to/my/app/AdminPanel.xcworkspace -scheme AdminPanelTests -configuration Debug RUN_APPLICATION_TESTS_WITH_IOS_SIM=YES ONLY_ACTIVE_ARCH=NO clean build

I get a succesfull job even though my test should have failed, and when i checked the log, just before it's end I have

/Users/jenkins/Library/Developer/Xcode/DerivedData/AdminPanel-gbjokymklhdmkhfglybgrvrgrcnm/Build/Intermediates/AdminPanel.build/Debug-iphonesimulator/AdminPanelTests.build/Script-73BDE2F11B7B798D009339E9.sh: line 11: ios-sim: command not found

so basically it doesn't even launch the app

Upvotes: 0

Views: 183

Answers (2)

Mihai Fischer
Mihai Fischer

Reputation: 339

The problem was the path, I had to add /usr/local/bin/ to the PATH variable before running the build phase script.

export PATH=$PATH:/usr/local/bin/

If you run into this, always check the path where Xcode runs the script.

Upvotes: 0

Adam Sharp
Adam Sharp

Reputation: 3668

These days it's possible to run application tests from the command line using plain xcodebuild without any extra work. Let's say you had a fresh project to which you'd added Kiwi, you can just run:

xcodebuild test

Or if you're using a workspace:

xcodebuild test -workspace MyWorkspace.xcworkspace -scheme MyProj

Upvotes: 0

Related Questions