DEV Community

Cover image for Making Android UI testing enjoyable

Making Android UI testing enjoyable

Rafa Vázquez on October 26, 2020

UI testing in Android has always been controversial for many reasons. Tests are slow because they must run in emulators or real devices. They can b...
Collapse
 
liviufromendtest profile image
Liviu Lupei

Nice article.

You should also try Endtest for building and executing automated tests for Mobile Apps.

It uses an Appium engine and it even has a test recorder.
These chapters are a good starting point:
How to create Mobile Tests
Finding elements in Mobile Applications
How to execute Mobile Tests

I actually work there, so feel free to ask me anything about it.

Collapse
 
liweijian profile image
liweijian

If Endtest is using Appium, I believe that's another topic. According to the official doc

Appium's flagship support for automating Android apps is via the UiAutomator2 driver

Espresso is much more fast, and have lots of other advantages like very good at test RecyclerView.

Collapse
 
liviufromendtest profile image
Liviu Lupei

Do you have any studies or data to support your claim that Espresso is faster than UiAutomator2?
I'm curious to learn more about that.

Thread Thread
 
liweijian profile image
liweijian • Edited

From google official training course

Espresso tests run optimally fast! It lets you leave your waits, syncs, sleeps, and polls behind while it manipulates and asserts on the application UI when it is at rest.

From 3rd introduction

In my opinion, the first trait is Espresso faster than Ui Automator.

Thread Thread
 
liviufromendtest profile image
Liviu Lupei

Espresso was built by Google.
Your first source is literally from Google.
And your second source is an article published on Medium by someone.

None of those articles contain any comparison data.

I was hoping for something more reliable, that would include data, measurements, comparisons, etc.

Collapse
 
anticafe profile image
anticafe

I also see Kakao and Kaspresso as a good library to support write UI test. How does it compare to Barista?

Collapse
 
sloydev profile image
Rafa Vázquez

I haven't personally used Kakao or Kaspresso, so take my response with a grain of salt. But from what I've seen about them, they seem more opinionated than Barista on how to write your tests. They are very linked to the concept of page object with a custom DSL, which can be helpful for some projects for sure.

Barista is more "low level", closer to Espresso but with a simpler API and some hidden "magic" as described above. You decide how to structure your own tests. In this post, I showed how we do our PageObjects, but you're free to use any other approach.

In my personal and debatable opinion, our PageObjects are more semantic, because we write them from the perspective of what the user would be doing. However, the DSL from Kakao exposes some information about the structure of the screen (button this, recyclerview that). I'm not saying that's wrong, it's just different.

I hope I could shed some light on your question :)

Collapse
 
garispe profile image
guillermo.arispe

Great job!

I want use Barista, but I have an issue:

Library Version:

3.7.0

Describe the Bug:

I followed the instructions to integrate Barista. I put this lines in my build.gradle

androidTestImplementation('com.schibsted.spain:barista:3.7.0') {
exclude group: 'org.jetbrains.kotlin'
}

But when I try to use it, Android Studio don't recognize the library.

What is my error?

I'm using Android Studio 4.1 and com.android.tools.build:gradle 4.0.1

Collapse
 
sloydev profile image
Rafa Vázquez

I see in Github you already solved it :)

Collapse
 
matzuk profile image
Eugene Matsyuk

Hi guys!
Barista is an interesting solution to make Espresso tests easier. But, there is a more modern and perfect solution - Kaspresso. Check it =)

Collapse
 
liweijian profile image
liweijian

Hi, I was wondering could you elaborate on why you think Kaspresso is more modern and perfect?