Skip to content

Conversation

@v1sar
Copy link
Member

@v1sar v1sar commented Nov 27, 2021

No description provided.

Copy link
Member

@NoNews NoNews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being honest, don't really like that we post just regular documentation here 🤔
Let's have more proper things.

From my perspective, this article:

  • Instruments for UI testing
    Short description for Espresso/UiAutomator, short points why they are bad, short examples, without how connect it to the gradle. (We have a documentation for that provided by google)

  • Available tools for UI testing (review the existed libraries, like Barista, Kakao, Kaspresso, Layout Inspector + native viewer)

What do you think about it?

UPD

@sergio-sastre waiting for your opinion :)


```kotlin
dependencies {
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure that it's worth to have a documentation description here. We can just point to the android documentation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allright, let's delete that

@v1sar
Copy link
Member Author

v1sar commented Nov 28, 2021

So, answering to @NoNews comment:

  • added info about ui testing in general
  • Added more detailed info about Espresso and UiAutomator and their comparison
  • Made more informative conclusion

My opinion is that this article should just show people the main purpose of Ui testing and short example with espresso is very good for beginners which will meet our cookbook. In conclusion i've added info where everybody can see detailed info about possible problems and which libraries may solve that. It will be quite strange to discard simple example on espresso (documentation-like) but promote documentation of external libraries :)

let's decide what to do

@sergio-sastre
Copy link
Member

Being honest, don't really like that we post just regular documentation here 🤔 Let's have more proper things.

From my perspective, this article:

  • Instruments for UI testing
    Short description for Espresso/UiAutomator, short points why they are bad, short examples, without how connect it to the gradle. (We have a documentation for that provided by google)
  • Available tools for UI testing (review the existed libraries, like Barista, Kakao, Kaspresso, Layout Inspector + native viewer)

What do you think about it?

UPD

@sergio-sastre waiting for your opinion :)
I would mention the tools with bullet points and link them to their respective sections (not part of the MVP now I would say, so no links for now), or Github repos for now.


So, if once we decided that we need to check users scenarios - we should definitely start writing Ui tests and let's start with tools, that will help us to write this type of tests.

## Main tool - Espresso and UiAutomator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth mentioning that Jetpack Compose testing library for Composables?

"Different testing tools. Espresso and UIAutomator can still test a Compose Layout - searching by text, resource, etc. However, they don’t have access to Composables’ semantics and can’t fully test them. Therefore, it’s recommended to use the Jetpack Compose testing library as it can access semantics and fully test Composables on the screen."
Link:
https://dmytroshuba.com/blog/jetpack-compose-ui-testing/

But for usual testing you should prefer `Espresso` rather then `UiAutomator`.

### Espresso

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also worth mentioning that Espresso as well as the Jetpack Compose Library support Robolectric, while UiAutomator doesn't.

That means, one can write Shared Tests written in Espresso or with Compose Library

<br/>Many cross-platforms tools for testing using `UiAutomator`.

These two tools are the main tools that everyone using for Ui testing on Android. <br/>
Remember, it's possible to create tests that will use both frameworks. For example, you can find your views and interact with them by `Espresso` and in the same test call `UiAutomator` to perform something specific, like pressing volume button. <br/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like this :) Should be bold maybe? I would like to highlight it

}
```

### What else?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather name it more meaningfully:
Espresso Cheat Sheet

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, there is the same for Compose, worth mentioning on its corresponding section
Compose Cheat sheet
https://developer.android.com/jetpack/compose/testing-cheatsheet

### Something like conclusion

To be honest, there is a lot of edge-cases once you are trying to write your own tests. That's one of the reasons why that CookBook was created, so we are suggesting to read next articles to understand how to overcome many of common problems that you will face in Ui testing. <br/>
Beside that fact, that `Espresso` and `UiAutomator` are the main tools to do Ui testing on Android, you may notice at [Companies experience article](https://android-ui-testing.github.io/Cookbook/adoption/companies_experience/) that almost nobody uses only these tools.<br/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the point. I would also add something about "new way of testing" due to "Compose emerging".

Additionally, I would reword this though.
Something like "most companies do not use Espresso or UiAutomator directly, but through frameworks that wrap them under the hood:

  1. Espresso
    • Kakao
    • Barista
    • Kaspresso
  2. UiAutomator
    • Kaspresso (Kautomator)
  3. Compose Test Library
    • Kaspresso (since 1.4.0)

Moreover you can write something about "Compose is emerging) and that Kaspresso has also added support for it in 1.4.0

@v1sar v1sar merged commit a8bfd09 into main Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants