Passing arguments to iOS tests with xcodebuild

前端 未结 2 806
忘了有多久
忘了有多久 2021-02-08 13:05

I\'d like to pass command line arguments to my iOS tests through the command line (xcodebuild). I\'m looking for the equivalent of this setting on XCode:

Simply

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-08 13:30

    To add to @ManWithBear's answer, I ended up doing this in a script:

    #Remove previous command line arguments
    /usr/libexec/PlistBuddy -c "Delete DetoxTestRunner:CommandLineArguments" "$TESTRUN" || true
    #Add an empty array
    /usr/libexec/PlistBuddy -c "Add DetoxTestRunner:CommandLineArguments array" "$TESTRUN"
    
    #Add script arguments as launch arguments of the test runner app
    for i in $*; do
      /usr/libexec/PlistBuddy -c "Add DetoxTestRunner:CommandLineArguments: string '$i'" "$TESTRUN"
    done
    

    In the code above, I add all arguments passed to a script as launch argument to the tester app. DetoxTestRunner is the name if the test scheme/target.

提交回复
热议问题