Skip to content

Commit

Permalink
KasperskyLab#314 compose readme last additions
Browse files Browse the repository at this point in the history
  • Loading branch information
matzuk committed Nov 24, 2021
1 parent aa56fc9 commit dab4b2d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Kaspresso is a great framework for UI testing. Based on [Espresso](https://developer.android.com/training/testing/espresso) and [UI Automator](https://developer.android.com/training/testing/ui-automator), Kaspresso provides a wide range of additional amazing features, such as:
* 100% stability, no flakiness.
* *[WIP] Jetpack Compose support.*
* Jetpack Compose support [since version 1.4].
* Significantly faster execution of UI Automator commands.
With Kaspresso, some UI Automator commands run **10 times faster**!
* Excellent readability due to human DSL.
Expand Down Expand Up @@ -252,7 +252,7 @@ dependencies {
androidTestImplementation 'com.kaspersky.android-components:kaspresso:<latest_version>'
# Allure support
androidTestImplementation "com.kaspersky.android-components:kaspresso-allure-support:<latest_version>"
# Jetpack Compose support
# Jetpack Compose support (since version 1.4)
androidTestImplementation "com.kaspersky.android-components:kaspresso-compose-support:<latest_version>"
}
```
Expand Down
42 changes: 39 additions & 3 deletions wiki/10_Jetpack-Compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,40 @@ I/KASPRESSO: ___________________________________________________________________
I/KASPRESSO: TEST STEP: "3. Click on the Second button" in ComposeSimpleFlakyTest
```

## Caveats
Remember, that Jetpack Compose and all relative tools are developing.
It means Jetpack Compose is not learned very well and some things can be unexpected after "Old fashioned View World" experience.
Let me show the interesting case.

For example, this code
```kotlin
composeSimpleFlakyScreen(composeTestRule) {
firstButton {
performClick()
}
}
```
can be the source of flakiness behavior if `firstButton` is located in non visible for a user area
(you just need to scroll to see the element).

But, this code will always work stably:
```kotlin
composeSimpleFlakyScreen(composeTestRule) {
firstButton {
assertIsDisplayed()
performClick()
}
}
```

The explanation is in the nature of SemanticsNode Tree and Jetpack Compose. `firstButton` is a Node and presented in the Tree.
It means that `performClick()` may work and nothing bad doesn't happen. But, `firstButton` is not visible physically and a real click doesn't occur.
Such behavior causes the crash of a test a little bit later.<br>
But, `assertIsDisplayed()` check doesn't pass on the first try (we don't see the element on the screen) and
launches work of all Interceptors including Autoscroll interceptor which scrolls the Screen to the desired element.

Please, [share your experience](https://github.com/KasperskyLab/Kaspresso/issues/new) to help other developers.

## What else

### Configuration
Expand Down Expand Up @@ -175,6 +209,8 @@ All information about Robolectric support is available [here](./08_Kaspresso-Rob

### Compose is compatible with all sweet Kaspresso extensions
Sweet Kaspresso extensions means using of the such constructions as
- `flakySafely`,
- `continuously`,
- etc.
- `flakySafely`
- `continuously`

The support of some constructions is in progress: [issue-317](https://github.com/KasperskyLab/Kaspresso/issues/317).

0 comments on commit dab4b2d

Please sign in to comment.