惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
Jina AI
Jina AI
罗磊的独立博客
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
J
Java Code Geeks
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
腾讯CDC
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
InfoQ
月光博客
月光博客
博客园_首页
Vercel News
Vercel News
P
Proofpoint News Feed
GbyAI
GbyAI
Y
Y Combinator Blog

ashishb.net

A day in Luxembourg - the richest country in the world I was asked to install malware during a fake interview Book summary: Breakneck - China's quest to engineer the future by Dan Wang Book summary: How to Teach Your Baby to Read Book Summary: The Discontented Little Baby Book by Pamela Douglas Introducing Amazing Sandbox - run third-party tools and AI agents securely on your machine Why software outsourcing gets a bad reputation? Book summary: The Natural Baby Sleep Solution by Polly Moore A day in Antwerp, Belgium Journey of online influencers Two days in Brussels, Belgium Shortcuts - when we love them and when we don't A visit to Rakhigarhi Three days in overhyped Paris Empty Japan, crowded Tokyo The real lock-in in GitHub is not the code, but the stars 11-day Norwegian Breakaway East Caribbean cruise Sanskrit and Sri Lankan Air Force Use REST with Open API The Achilles heel of American capitalism Costa Rica in 4 days At a juice stall in Sri Lanka A short stay at Warsaw, Poland Best practices for using Python & uv inside Docker Two days in Vilnius, Lithuania How IntelliJ IDEs waste disk space Pregnancy Why there aren't many digital nomads from India Two days in Riga, Latvia To keep your machine secure, run third-party tools inside Docker
End-to-end testing of mobile apps
Ashish Bhatia · 2023-08-02 · via ashishb.net

Google released a new version of the Google Auth library.

It had a bug that broke Google Login on Android for API 26 and earlier.

This impacted my small but popular Music Player app in Google Play.

It reveals the kind of problem, I have alluded to in end-to-end testing.

The only way to avoid such problems is by end-to-end testing.

However, I find all Android testing frameworks to be terrible.

Most of the frameworks are focused on testing the underlying code.

However, I’m interested in UI interactions to prove the user can accomplish the job.

And that’s how I came across mobile.dev.

Mobile.dev has an excellent open-source framework called Maestro which one can use to write intuitive tests.

You describe how the UI interactions and expectations.

And the framework just verifies that.

Here’s a sample for the test I wrote to prevent my app from breaking in the future.

This snippet describes a basic test that I wrote to assert that Google Drive Folder sharing is always working.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Same this file inside ".maestro" folder in the repo root
---
# Ref: https://maestro.mobile.dev/api-reference
appId: "net.ashishb.androidmusicplayer"
---
- launchApp
- waitForAnimationToEnd

- tapOn:
    id: "shareable_link"
- inputText: "https://drive.google.com/drive/folders/<folder-id>"
- tapOn: "Link Google Drive Folder"
- waitForAnimationToEnd

- assertVisible: "Cached Files"
- assertVisible: "Recently Added"
- assertVisible: "Local Files"
- assertVisible: "song.mp3"
- assertVisible: "Files: 1,0*.*"
- assertVisible: "Files: 1,55.*"

# Now download a file and play it
- tapOn: "song.mp3"
- waitForAnimationToEnd

- assertNotVisible:
    id: "rewind_button"
# Verify bottom sheet expands
- tapOn:
    id: "music_status"
- assertVisible:
    id: "artist_name"
...

And here’s a simple GitHub Actions code to run all the tests on mobile.dev

1
2
3
4
5
6
7
# Run all test flows in ".maestro" directory
- name: Run end to end tests with mobile.dev
  uses: mobile-dev-inc/action-maestro-cloud@v1
  with:
  # The API key can be found at https://console.mobile.dev/quickstart
          api-key: ${{ secrets.MAESTRO_CLOUD_API_KEY }}
          app-file: <path-to-apk>

Update: As of Jan 1, 2025, mobile.dev is no longer free. One can, however, run Maestro on GitHub Actions instead using Android Emulator Runner directly.

Note

  1. You can run maestro CLI locally against a connected device/emulator.
  2. For the Google Auth bug, I still cannot test using Maestro as it only supports recent Android versions. However, the Maestro testing prevented me from shipping another Gradle-related bug.