TestLauncher

public struct TestLauncher

Configures given application with provided launch options and variables. TestLauncher is a wrapper around XCUIApplication.launchArguments and XCUIApplication.launchEnvironment. By using abstract type, LaunchOption, it is possible to pass parameters to the testing application.

AutoMate provides set of options which can set system locale, language, keyboard languages, or advanced options like CoreData SQL debug verbosity level.

Example:

let app = XCUIApplication()
TestLauncher(options: [
    SystemLanguages([.English, .German]),
    SystemLocale(language: .English, country: .Canada),
    SoftwareKeyboards([.EnglishCanada, .GermanGermany])
]).configure(app).launch()

Default options:

It is not known which options should be added to TestLauncher by default. It depends on the application. That is why TestLauncher doesn’t provide any default set of options.

In your application you can create an extension to TestLauncher with default list of options.

Example:

extension TestLauncher {
    static let defaultLaunchOptions: [LaunchOption] = [AnimationLaunchEnvironment()]

    public static func configureWithDefaultOptions<T: Application>(_ application: T, additionalOptions options: [LaunchOption] = []) -> T {
        return TestLauncher(options: defaultLaunchOptions + options).configure(application)
    }
}

With such extensions the XCUIApplication can be configured with default options of your choice.

Example:

let app = XCUIApplication()
TestLauncher.configureWithDefaultOptions(app).launch()
  • Initializes TestLauncher with given options.

    Declaration

    Swift

    public init(options: [LaunchOption] = [])

    Parameters

    options

    Options to initialize with.

  • Passes stored settings to the provided application.

    Declaration

    Swift

    public func configure<T>(_ application: T) -> T where T : Application

    Parameters

    application

    Object implementing Application protocol that will receive the settings, eg. XCUIApplication.

    Return Value

    Application with passed settings.

  • Initializes TestLauncher with given options and configure application object with launch arguments and launch environments.

    Declaration

    Swift

    public static func configure<T>(_ application: T, withOptions options: [LaunchOption] = []) -> T where T : Application

    Parameters

    application

    Object implementing Application protocol that will receive the settings, eg. XCUIApplication.

    options

    Options to initialize TestLauncher and application.

    Return Value

    Application with passed settings.