# How One Kotlin Keyword Broke Our UI Automation

11 approvals, green tests, and a silent UI failure.

- **Source:** [ProAndroidDev - Medium](https://brifing.si/source/d9553fa9-7b72-4b9b-bc73-c6bf9a40dd5f)
- **Published:** 2026-07-14
- **Topic:** [Software & Engineering](https://brifing.si/c/engineering)
- **Original article:** <https://proandroiddev.com/11-approvals-green-tests-and-a-broken-prod-how-one-kotlin-keyword-blinded-our-ui-automation-34e2b1a3216c?source=rss----c72404660798---4>
- **On Brifing:** https://brifing.si/s/b4591d27-2752-44bc-9287-7548190f63fe

## The Root Cause

A misuse of a Kotlin keyword caused UI automation tests to fail silently. Using apply instead of let led to incorrect test results.

## Code Review Process

The faulty code was reviewed and approved by 11 different engineers. The code's idiomatic Kotlin appearance masked the error.

## Misleading Test Results

While tests remained green, UI components did not contain the correct text. This delayed the detection of the issue.

## Difference Between apply and let

apply returns the original object, while let returns the result of the block. This difference created a critical error in UI tests.

## The Mechanism of the Bug

The applyIf function silently ignored text checks. This caused tests to approve incorrect components.

## Solution: Using letIf

Replacing apply with letIf ensured correct text checks. This fixed the error.

## API Redesign

The API was redesigned to prevent reintroduction of the bug. This ensured similar errors would not compile.

## Testing the Test Infrastructure

Testing the matchers themselves prevented similar errors. This increased the reliability of the test infrastructure.

## Team Communication and Responsibility

11 approvals diffused responsibility. This highlighted the need for more effective code review processes.

## Lessons Learned

This incident emphasized the importance of correct Kotlin scope function usage and continuous testing of test infrastructure.

## Sources covering this story

- https://proandroiddev.com/11-approvals-green-tests-and-a-broken-prod-how-one-kotlin-keyword-blinded-our-ui-automation-34e2b1a3216c?source=rss----c72404660798---4 — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
