- Notifications
You must be signed in to change notification settings - Fork 30
Article UI testing #27
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
Conversation
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.
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 :)
docs/content/basics/ui_testing.md Outdated
| | ||
| ```kotlin | ||
| dependencies { | ||
| androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0') |
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'm not really sure that it's worth to have a documentation description here. We can just point to the android documentation
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.
allright, let's delete that
| So, answering to @NoNews comment:
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 |
|
| | ||
| 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 |
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 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 | ||
| |
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 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/> |
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.
Really like this :) Should be bold maybe? I would like to highlight it
docs/content/basics/ui_testing.md Outdated
| } | ||
| ``` | ||
| | ||
| ### What else? |
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 would rather name it more meaningfully:
Espresso Cheat Sheet
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.
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/> |
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 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:
- Espresso
- Kakao
- Barista
- Kaspresso
- UiAutomator
- Kaspresso (Kautomator)
- 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
No description provided.