Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-561: setup Kakao and Kautomator settings before each test #569

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.test.espresso.FailureHandler
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.Configurator
import com.kaspersky.adbserver.common.log.logger.LogLevel
import com.kaspersky.components.kautomator.KautomatorConfigurator
import com.kaspersky.components.kautomator.intercept.interaction.UiDeviceInteraction
import com.kaspersky.components.kautomator.intercept.interaction.UiObjectInteraction
import com.kaspersky.kaspresso.device.Device
Expand Down Expand Up @@ -1001,29 +1002,36 @@ data class Kaspresso(
configurator.waitForIdleTimeout = kautomatorWaitForIdleSettings.waitForIdleTimeout
configurator.waitForSelectorTimeout = kautomatorWaitForIdleSettings.waitForSelectorTimeout

injectKaspressoInKakao(
kaspresso.viewBehaviorInterceptors,
kaspresso.dataBehaviorInterceptors,
kaspresso.webBehaviorInterceptors,
kaspresso.viewActionWatcherInterceptors,
kaspresso.viewAssertionWatcherInterceptors,
kaspresso.atomWatcherInterceptors,
kaspresso.webAssertionWatcherInterceptors,
kaspresso.params.clickParams
)

injectKaspressoInKautomator(
kaspresso.objectBehaviorInterceptors,
kaspresso.deviceBehaviorInterceptors,
kaspresso.objectWatcherInterceptors,
kaspresso.deviceWatcherInterceptors
)
kaspresso.injectInKakaoAndKautomator()

failureHandler?.let { Espresso.setFailureHandler(it) }

return kaspresso
}
}

internal fun reset(): Unit = Kakao.reset()
internal fun injectInKakaoAndKautomator() {
injectKaspressoInKakao(
viewBehaviorInterceptors,
dataBehaviorInterceptors,
webBehaviorInterceptors,
viewActionWatcherInterceptors,
viewAssertionWatcherInterceptors,
atomWatcherInterceptors,
webAssertionWatcherInterceptors,
params.clickParams
)

injectKaspressoInKautomator(
objectBehaviorInterceptors,
deviceBehaviorInterceptors,
objectWatcherInterceptors,
deviceWatcherInterceptors
)
}

internal fun reset() {
Kakao.reset()
KautomatorConfigurator.reset()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ internal class TestRunner<InitData, Data>(
private val kaspresso: Kaspresso
) {
fun run(testBody: TestBody<InitData, Data>) {
/**
* We reset Kakao and Kautomator settings after each test.
* So we should set it up before launching test because in some cases one test is launching several times
* e.g. Screenshot tests with several locales
*/
kaspresso.injectInKakaoAndKautomator()

val exceptions: MutableList<Throwable> = mutableListOf()
val resultException: Throwable?
val baseTestContext = BaseTestContext(kaspresso)
Expand Down