Skip to content

Configuration

Aleksei Tiurin edited this page Aug 6, 2023 · 1 revision

There are 3 configs to manage Ultron framework: UltronConfig, UltronAllureConfig and UltronComposeConfig.

You can use recommended configuration and just apply it in BaseTest class (sample) :

@BeforeClass
@JvmStatic
fun config() {
    UltronConfig.applyRecommended()
    UltronAllureConfig.applyRecommended()
    UltronComposeConfig.applyRecommended()
    // these is required to finish Allure configuration for Compose part
    UltronComposeConfig.addListener(ScreenshotAttachListener())
    UltronComposeConfig.addListener(WindowHierarchyAttachListener())
    UltronComposeConfig.addListener(DetailedOperationAllureListener())
}

UltronConfig

UltronConfig object is responsible for configuring and managing settings related to the Espresso, EspressoWeb, and UiAutomator. It includes sub-classes and nested objects to manage different aspects of the framework.

You can set custom main settings using apply method.

UltronConfig.apply {
    logToFile = true
    accelerateUiAutomator = true
    operationTimeoutMs = 10_000
}

It provides methods to add and remove global listeners

UltronConfig.addGlobalListener(LogLifecycleListener())
UltronConfig.removeGlobalListener(LogLifecycleListener::class.java)
  • UltronConfig.Espresso nested Object:

Manages configurations specific to the Espresso part of the framework. Provides settings related to timeouts, view matchers, result analyzers, and action/assertion configurations.

UltronConfig.Espresso.RECYCLER_VIEW_LOAD_TIMEOUT = 20_000
UltronConfig.Espresso.RECYCLER_VIEW_OPERATIONS_TIMEOUT = 10_000
UltronConfig.Espresso.RECYCLER_VIEW_ITEM_SEARCH_LIMIT = 100
UltronConfig.Espresso.INCLUDE_VIEW_HIERARCHY_TO_EXCEPTION = true // false by default
UltronConfig.Espresso.setResultAnalyzer { operationResult ->
    // set custom operations result analyzer 
}
  • UltronConfig.Espresso.ViewActionConfig and UltronConfig.Espresso.ViewAssertionConfig nested Objects:

Manage configurations for Espresso view actions and view assertions, respectively. Provide settings for allowed exceptions and result handlers.

UltronConfig.Espresso.ViewActionConfig.allowedExceptions.add(CustomViewException::class.java)
UltronConfig.Espresso.ViewAssertionConfig.allowedExceptions.add(CustomViewException::class.java)
  • UltronConfig.Espresso.WebInteractionOperationConfig nested Object:

Manages configurations for Espresso web interaction operations. Provides settings for allowed exceptions and result handlers.

UltronConfig.Espresso.WebInteractionOperationConfig.allowedExceptions.add(CustomJSException::class.java)
  • UltronConfig.UiAutomator nested Object:

Manages configurations specific to the UiAutomator part of the framework. Provides settings related to timeouts, result analyzers, and UiDevice configurations.

UltronConfig.UiAutomator.OPERATION_TIMEOUT = 15_000
val device = UltronConfig.UiAutomator.uiDevice
UltronConfig.UiAutomator.UiObject2Config.allowedExceptions.add(CustomViewException::class.java)
  • UltronConfig.UiAutomator.UiObjectConfig and UltronConfig.UiAutomator.UiObject2Config nested Objects:

Manage configurations for UiAutomator operations using UiSelector and BySelector, respectively. Provide settings for allowed exceptions and result handlers.

  • UltronConfig.Log nested Object:

Allows you to specify date format for log messages

UltronConfig.Log.dateFormat = "MM-dd HH:mm:ss.SSS"

UltronAllureConfig

Help us to configure Allure report.

UltronAllureConfig.apply {
    addScreenshotPolicy =  mutableSetOf(
        AllureAttachStrategy.TEST_FAILURE,
        AllureAttachStrategy.OPERATION_FAILURE
    )
    addHierarchyPolicy = mutableSetOf(
        AllureAttachStrategy.TEST_FAILURE,
        AllureAttachStrategy.OPERATION_FAILURE
    )
    attachLogcat = false
    attachUltronLog = true
    addConditionsToReport = true
    detailedAllureReport = true
}

It also allow us to add or remove RunListener.

UltronAllureConfig.addRunListener(LogcatAttachRunListener())
UltronAllureConfig.removeRunListener(LogcatAttachRunListener::class.java)

UltronComposeConfig

Manages configurations for Compose part of the framework

UltronComposeConfig.apply {
    operationTimeoutMs = 10_000
    lazyColumnOperationTimeoutMs = 15_000
    operationPollingTimeoutMs = 100
    lazyColumnItemSearchLimit = 100
}

Contains methods to add or delete Compose operations listener.

UltronComposeConfig.addListener(ScreenshotAttachListener())
UltronComposeConfig.removeListener(ScreenshotAttachListener::class.java)