android / android/android-test

Customizing string rendering of view hierarchy

Open
#724 8 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

### Description

@zach-klippenstein and I are working on releasing https://github.com/square/radiography , a utility that renders both Android & Compose view hierarchies to readable strings.

Espresso errors include a string rendering of the view hierarchy, unfortunately that rendering is not as human readable as it could be.

At Square, I've replaced Espresso's string rendering with the output from Radiography. I did that with a giant hack, setting a FailureHandler delegate and using reflection to replace the Throwable's `detailMessage` field 💩💩💩. Shared in a tweet here: https://twitter.com/Piwai/status/1291771701584252928

It would be great if Espresso would provide a hook to set up a view hierarchy renderer. Also, if you feel comfortable with it, it could depend directly on Radiography in some way or offer it as an alternate impl (might be more involve to sign off on that?).

If you're ok with the idea of adding such an API I'm happy to open up a PR and we can take it from there.

Contributor guide

Open the contributing guide

Research direction

Start by locating Espresso's failure-handling and view-hierarchy rendering entry points. Clarify the API for selecting a custom renderer, including whether Radiography should be a direct dependency or an alternate implementation, and confirm that the chosen design can replace the current reflection-based approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.