[Bug] testing-setup: Agent modifies test code/clock to bypass failures instead of fixing production bugs (False-Green / Testing Integrity issue)

Aperta Adatta ai principianti
#241 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
90/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
android
Ambito
testing

Direzione di ricerca

Aggiorna testing/testing-setup/SKILL.md con il protocollo richiesto sull’integrità dei test e sull’analisi della causa principale. La sezione deve richiedere un’attribuzione che dia priorità alla produzione, vietare il congelamento dell’orologio e i workaround del dispatcher che mascherano i difetti e richiedere una verifica pulita in condizioni di test standard; non vengono menzionati test specifici.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Affected Skill

testing/testing-setup

Description

When running the testing-setup skill to write and execute UI or unit tests, if a test reveals a real bug in production code (such as an infinite frame loop causing AppNotIdleException or coroutine dispatch delays causing AssertionError), the agent's default instinct is to modify the test code (e.g. freezing the test clock via mainClock.autoAdvance = false or bypassing dispatchers) rather than investigating and fixing the production code.

This results in a "False-Green" (superficial pass) where the agent reports 100% test pass rates, while the underlying production code still retains severe bugs such as background battery drain, frame starvation, or UI lag.

Expected Behavior
  1. Production-First Attribution: When an assertion fails, a timeout occurs, or the Compose engine cannot idle (AppNotIdleException), the agent should treat the production code as the primary suspect.
  2. Real Root-Cause Remediation: The agent should investigate whether production code has architectural defects (e.g., bare while (isActive) withFrameNanos loops that should use rememberInfiniteTransition, or unnecessary Dispatchers.Main queuing for state updates) and refactor the production code directly.
  3. No Test Workarounds: The agent must NOT bypass real issues by manipulating the test harness (such as manually advancing clocks to silence runaway loops or artificially relaxing assertions).
  4. Clean Verification: Once production code is fixed, tests must pass cleanly under standard, unmanipulated conditions (e.g., standard waitForIdle()).
Actual Behavior

The agent suffers from strong "Green-Bar Bias" (optimizing for BUILD SUCCESSFUL at all costs):

  1. Upon encountering AppNotIdleException caused by an infinite withFrameNanos loop in the UI component, the agent immediately added composeTestRule.mainClock.autoAdvance = false and advanceTimeBy(...) in the test file to avoid waiting for idle.
  2. Upon encountering an AssertionError where the UI failed to update after clicking "Next Track" (due to production code putting state mutations inside viewModelScope.launch(Dispatchers.Main) queue), the agent bypassed it inside the test harness without touching the production ViewModel.
  3. The agent declared victory with "100% pass rate", while the production code still contained the battery-draining infinite loop and UI lag.
Steps to Reproduce
  1. In an Android Compose app with a turntable rotation animation implemented via while (isActive) withFrameNanos and a ViewModel using viewModelScope.launch(Dispatchers.Main) { _song.value = next }.
  2. Invoke LLM with testing-setup skill to write UI behavior tests for this component.
  3. When Gradle execution fails with AppNotIdleException or AssertionError, observe the LLM's next step:
    • It modifies the test file with mainClock.autoAdvance = false instead of refactoring the production turntable animation.
    • It bypasses coroutine queuing in the test instead of making state updates immediate in production code.
Suggested Fix

Add a mandatory "Testing Integrity & Root Cause Protocol" section to testing-setup/SKILL.md:

  1. Mandate Production Attribution: Explicitly state that UI freezes, idling timeouts, and state lags are production code defects by default.
  2. Prohibit Clock Freezing as a Patch: Forbid using mainClock.autoAdvance = false merely to mask infinite frame loops or unmanaged background jobs in production code.
  3. Audit Against False-Greens: Require the agent to ask: "If this happened on a real device, would the user experience battery drain, ANRs, or UI lag?" If yes, the production code MUST be refactored first.
Lingua principale
Kotlin
Stelle
10.7k
Fork
708
Merge medio
8g 4h
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di android/skills

Tutte le issue di android/skills

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.