cakes88 cakes88 - 7 months ago 42
Swift Question

Specify what Simulator to use in XCTest XCUIApplication - Swift

In my setUp method I'd like to specify what simulator to use before launching the app. Is this possible to do, even if it's not in the setUp method? Currently I'm just setting it in Xcode in the drop down before I run the tests. I'm asking because I have some test that run on iPad and some that will run on iPod and not have to manually change this every time.

override func setUp() {
super.setUp()
continueAfterFailure = false
app.launch()
}

Answer

If you run these via command line or from team city etc... You can build your iPad specific tests in a separate scheme.

Then when you call the tests via xcodeBuild command line:

xcodebuild test -workspace YOURAPP.xcworkspace -scheme IPAD-SPECIFIC-SCHEME -destination 'platform=iOS Simulator,id=PUT THE ID FOR YOUR IPAD SIMULATOR HERE,OS=9.3'

I am not sure if you can do this specifically within the setup function.

Comments