-
Notifications
You must be signed in to change notification settings - Fork 158
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
Conversation
@@ -28,6 +28,8 @@ class ScreenshotsImpl( | |||
|
|||
override fun takeAndApply(tag: String, block: File.() -> Unit): Unit = doTakeAndApply(tag, block) | |||
|
|||
override fun getScreenshotDir(): File = resourceFilesProvider.provideScreenshotFile("").parentFile as File |
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.
Ugly hack. Add a provideScreenshotDir
function to the resourceFilesProvider
@@ -1,4 +1,4 @@ | |||
package com.kaspersky.kaspresso.composesupport.sample.screen | |||
package com.kaspresky.kaspresso.composesupport.sample.screen |
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.
typo
MUNICH_LOCATION_LAT, location.latitude, | ||
DELTA | ||
) | ||
flakySafely(timeoutMs = 10_000, intervalMs = 500) { |
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.
Checking for non-null is not actual now
@@ -16,6 +18,8 @@ class DeviceLogcatSampleTest : TestCase() { | |||
|
|||
@Test | |||
fun logcatTest() { | |||
Assume.assumeTrue(Build.VERSION.SDK_INT != Build.VERSION_CODES.O) // "logcat -c" fails on android 8 for some reason |
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.
We should fix it or describe this limitation in the docs (and throw an exception)
@@ -16,6 +18,8 @@ class DeviceLogcatSampleTest : TestCase() { | |||
|
|||
@Test | |||
fun logcatTest() { | |||
Assume.assumeTrue(Build.VERSION.SDK_INT != Build.VERSION_CODES.O) // "logcat -c" fails on android 8 for some reason |
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.
Assume.assumeTrue(Build.VERSION.SDK_INT != Build.VERSION_CODES.O) // "logcat -c" fails on android 8 for some reason | |
Assume.assumeTrue(Build.VERSION.SDK_INT != Build.VERSION_CODES.O) // "logcat -c" fails on Android 8 for some reason |
assertFalse(screenshotExists()) | ||
device.screenshots.take(SCREENSHOT_TAG) | ||
assertTrue(screenshotExists()) | ||
assertTrue(screenshotsDir.list()?.isEmpty() ?: true) |
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.
Intention of the assertion has been changed
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.
How? We check that screenshot folder is empty, take screenshot and check that it exists as we did before
Thread.sleep(3000) | ||
} | ||
fun showAndroidSettings() { | ||
Assume.assumeTrue(Build.VERSION.SDK_INT <= Build.VERSION_CODES.O) // Can't change system locale on newer versions |
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.
We should fix it or describe this limitation in the docs
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.
Maybe throw an exception too?
@@ -6,6 +6,7 @@ allure = "2.4.0" | |||
compose = "1.0.5" | |||
activityCompose = "1.4.0" | |||
androidXTest = "1.4.0" | |||
testOrchestrator = "1.4.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.
@@ -39,22 +39,22 @@ class WebComposeTest : TestCase() { | |||
} | |||
} | |||
|
|||
step("Find \"Sign in\" button and \"Protect your data\" title") { | |||
step("Find \"Sign in\" button and title") { |
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.
Maybe it makes sense to create our own simple WebPage?
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.
Yeah, It make sense. I'll work on that
@@ -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 comment
The 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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand how is it possible that flaky safety
can't solve this. Any PerformException
that was thrown in case of click failure would be handled anyway. Maybe there was some other exception that was not handled by flaky safety
intentionally? For me this test passed successfully any time I launched it. I don't think that we should add Screen.idle()
here. If you will be able to reproduce the problem and will provide more details, we could try to solve this in a proper way.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
is
instead of does
?
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.
Why? "Does" is a modal verb as an "is" and fits English rules
@@ -20,7 +20,7 @@ All examples are located in [device_tests](../samples/kaspresso-sample/src/andro | |||
11. `hackPermissions` provides the possibility of allowing any permission requests without default Android permission dialog. See the example [DeviceHackPermissionsSampleTest](../samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/device_tests/DeviceHackPermissionsSampleTest.kt). | |||
12. `exploit` allows to rotate device or press system buttons. See the example [DeviceExploitSampleTest](../samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/device_tests/DeviceExploitSampleTest.kt). | |||
13. `language` allows to switch language. See the example [DeviceLanguageSampleTest](../samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/device_tests/DeviceLanguageSampleTest.kt). | |||
14. `logcat` provides access to adb logcat. See the example [DeviceLogcatSampleTest](../samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/device_tests/DeviceLogcatSampleTest.kt). <br> | |||
14. `logcat` provides access to adb logcat. See the example [DeviceLogcatSampleTest](../samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/device_tests/DeviceLogcatSampleTest.kt). Please, notice that due to Android 8 bug this test won't run successfully on AVD with API 26 <br> |
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.
what about API > 26?
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.
It runs ok on any API I've tried except for 26. The problem is exactly API 26
/** | ||
* @return directory used to store screenshots | ||
*/ | ||
fun getScreenshotDir(): File |
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.
For what purpose is it added? First, I see the only usage in a sample test, second, it semantically doesn't belong to this interface and the implementation just proxies the call to resource provider.
If you really need to get the used directories in test runtime I would suggest to make the ResourcesDirsProvider
accessible via the TestContext
. It can be done by providing it to TestAssistantsProvider
.
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.
Ok, thanks, I'll fix that
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.
Pls see comments
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is more useful to have an access to ResourceFilesProvider
? If we need only root dirs we still can get them from the files paths.
@@ -35,7 +34,7 @@ class DeviceAccessibilitySampleTest : TestCase() { | |||
@get:Rule | |||
val activityRule = ActivityTestRule(DeviceSampleActivity::class.java, false, true) | |||
|
|||
@Test | |||
// @Test |
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.
Did you forgot to remove it?
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.
Nope, I forgot to leave a comment. I'm creating a CI for running UI tests for kaspresso PRs and unstable test is not ideal. I've tried increasing timeouts up to minute, but no luck.
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.
Maybe @Ignore("FIXME")
then? :)
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.
Sure, it's better
@@ -50,12 +49,12 @@ class DeviceAccessibilitySampleTest : TestCase() { | |||
device.targetContext.packageName, | |||
SERVICE_CLASS_NAME | |||
) | |||
assertTrueSafely { isAccessibilityServiceEnabled() } | |||
assertTrueSafely(timeoutMs = 60_000L, intervalMs = 1_000L) { isAccessibilityServiceEnabled() } |
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.
Isn't 60 sec too much?
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.
Yeah, looks like it's either working or not. I've experienced cases when 60secs wasn't enough
@@ -55,13 +55,16 @@ class DeviceExploitSampleTest : TestCase() { | |||
Configuration.ORIENTATION_LANDSCAPE == | |||
activityTestRule.activity.resources.configuration.orientation | |||
} | |||
Screen.idle() // kaspresso misses the button in case we won't wait | |||
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Did you forgot to remove it?
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.
Yep
Decided to split this task into two: fix broken tests and configure CI. This PR contains test fixes