-
Notifications
You must be signed in to change notification settings - Fork 149
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 121/run fix tests #371
Changes from 8 commits
226151c
dd9ef20
3ce85e1
c375a28
6819e69
3492846
c651b1d
90333d8
1d395bc
822684d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,8 @@ data class Kaspresso( | |
internal val objectBehaviorInterceptors: List<ObjectBehaviorInterceptor>, | ||
internal val deviceBehaviorInterceptors: List<DeviceBehaviorInterceptor>, | ||
internal val stepWatcherInterceptors: List<StepWatcherInterceptor>, | ||
internal val testRunWatcherInterceptors: List<TestRunWatcherInterceptor> | ||
internal val testRunWatcherInterceptors: List<TestRunWatcherInterceptor>, | ||
internal val resourcesRootDirsProvider: ResourcesRootDirsProvider | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it is more useful to have an access to |
||
) { | ||
|
||
companion object { | ||
|
@@ -930,6 +931,7 @@ data class Kaspresso( | |
), | ||
|
||
instrumentalDependencyProvider = instrumentalDependencyProviderFactory.getTestProvider(instrumentation), | ||
resourcesRootDirsProvider = resourcesRootDirsProvider, | ||
|
||
params = Params( | ||
flakySafetyParams = flakySafetyParams, | ||
|
@@ -957,7 +959,7 @@ data class Kaspresso( | |
deviceBehaviorInterceptors = deviceBehaviorInterceptors, | ||
|
||
stepWatcherInterceptors = stepWatcherInterceptors, | ||
testRunWatcherInterceptors = testRunWatcherInterceptors | ||
testRunWatcherInterceptors = testRunWatcherInterceptors, | ||
) | ||
|
||
configurator.waitForIdleTimeout = kautomatorWaitForIdleSettings.waitForIdleTimeout | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import com.kaspersky.kaspressample.screen.MainScreen | |
import com.kaspersky.kaspressample.utils.SafeAssert.assertTrueSafely | ||
import com.kaspersky.kaspresso.device.exploit.Exploit | ||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase | ||
import io.github.kakaocup.kakao.screen.Screen | ||
import org.junit.Assert.assertNull | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
@@ -54,9 +55,10 @@ class DeviceExploitSampleTest : TestCase() { | |
Configuration.ORIENTATION_LANDSCAPE == | ||
activityTestRule.activity.resources.configuration.orientation | ||
} | ||
Screen.idle() // kaspresso misses the button in case we won't wait | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. Kaspresso should handle all possible stuff in related Interceptors. Are you sure that everything is fine here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Nikitae57 Can you share more context on this? I am not able to reproduce this issue, for me test passes. And I don't see how is it possible actually to miss a button as flaky safety should solve this problem. I also changed the button id to wrong one to make sure the flaky safety works and it works: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kaspresso didn't handle this in a "flaky safety" way because it kinda worked right. I encountered a scenario when kaspresso didn't wait for orientation change, tried to press button but missed as orientation change performed at this moment. I assume that changing orientation command sends signal to OS and returns control immediately before actual orientation change happens There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't understand how is it possible that |
||
} | ||
|
||
step("Press back button") { | ||
step("Open web view and press back button") { | ||
MainScreen { | ||
webViewButton { | ||
click() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package com.kaspersky.kaspressample.device_tests | ||
|
||
import android.os.Build | ||
import androidx.test.rule.ActivityTestRule | ||
import com.kaspersky.kaspressample.MainActivity | ||
import com.kaspersky.kaspresso.device.logcat.LogcatBufferSize | ||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Assume | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
|
@@ -16,6 +18,11 @@ class DeviceLogcatSampleTest : TestCase() { | |
|
||
@Test | ||
fun logcatTest() { | ||
Assume.assumeTrue( | ||
"Due to Android 8 bug 'logcat -c' fails. To run this test please use another device", | ||
Build.VERSION.SDK_INT != Build.VERSION_CODES.O | ||
) | ||
|
||
before { | ||
device.logcat.setBufferSize(LogcatBufferSize(8, LogcatBufferSize.Dimension.MEGABYTES)) | ||
device.logcat.disableChatty() | ||
|
@@ -119,11 +126,11 @@ class DeviceLogcatSampleTest : TestCase() { | |
step("Using reader block") { | ||
repeat(100) { testLogger.i("Test6Row$it") } | ||
|
||
var fullLogcatList = device.logcat.readLogcatRows() | ||
val fullLogcatList = device.logcat.readLogcatRows() | ||
|
||
var inneContainsSize = 0 | ||
val isContainsBreaked = device.logcat.readLogcatRows { logcatRow -> | ||
inneContainsSize++ | ||
var innerContainsSize = 0 | ||
val doesContainBreaked = device.logcat.readLogcatRows { logcatRow -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? "Does" is a modal verb as an "is" and fits English rules |
||
innerContainsSize++ | ||
logcatRow.contains("Test6Row42") | ||
} | ||
|
||
|
@@ -139,7 +146,7 @@ class DeviceLogcatSampleTest : TestCase() { | |
logcatRow.contains("beginning of") | ||
} | ||
|
||
assertTrue(isContainsBreaked && fullLogcatList.size > inneContainsSize) | ||
assertTrue(doesContainBreaked && fullLogcatList.size > innerContainsSize) | ||
assertTrue(!isNotContainsBreaked && fullLogcatList.size <= innerNotContainsSize) | ||
|
||
assertTrue(isBreakedOnBeginningRow && indexOfBeginningRow == 1) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need testOrchestrator?
I've (and not only me) observed a lot of cases when Orchestrator "doesn't see" tests while you try to run some bunch of them. Temporary removing of Orchestrator from the dependencies and usage of base AndroidTestRun resolved the issue for a lot of cases. Let's try to remove Orchestrator because anyway we use Marathon or something similar for more smart tests execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nikitae57 Were there any problems with the app state being shared between tests inside the test run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matzuk I've encountered this behavior too, but it got resolved by upgrading orchestrator from 1.4.0 to 1.4.1.
@eakurnikov Yes, without orchestrator some tests worked fine when I launched them in scope of their module (gradlew moduleName:connectedDebugAndoirdTest) but failed when I run them in all modules (gradlew connectedAndroidDebugTest)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.4.0 doesn't work with 31 api at all. Even after the update orchestrator remains flaky especially when it comes to local test run. But I think it is fine to have it here for now. We can add other runner in future.