xcodexctestplan

XCode TestPlan: specify which configuration to use from command line


I have a few configurations in my XCode project's test plan, by default, executing UI tests will execute all configurations, but for some requirement I need to exclude one or two based on certain conditions on CI, I found that I can specify what scheme or test plan to execute, but is there a way to specify what test plan configurations to include or exclude, from command line? Thanks!


Solution

  • You can pass the configurations like this:

    $> xcodebuild test -workspace <path> 
                       -scheme <name> 
                       -destination <specifier>
                       -testPlan <name>
                       -only-test-configuration <configuration1> 
                       -only-test-configuration <configuration2>
                       ...
    

    Or skip configurations like this:

    $> xcodebuild test -workspace <path> 
                       -scheme <name> 
                       -destination <specifier>
                       -testPlan <name>
                       -skip-test-configuration <configuration1> 
                       -skip-test-configuration <configuration2>
                       ...
    

    The relevant lines from the help page:

    $> xcodebuild -help
    Usage: xcodebuild ...
    Options:
        -workspace NAME                    build the workspace NAME
        -scheme NAME                       build the scheme NAME
        -destination DESTINATIONSPECIFIER  use the destination described by DESTINATIONSPECIFIER (a comma-separated set of key=value pairs describing the destination to use)
        -testPlan                          specifies the name of the test plan associated with the scheme to use for testing
        -only-test-configuration           constrains testing by specifying test configurations to include, and excluding other test configurations
        -skip-test-configuration           constrains testing by specifying test configurations to exclude, but including other test configurations
        ...