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

Open Beginner friendly
#241 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
90/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
android
Domain
testing

Research direction

Update testing/testing-setup/SKILL.md with the requested Testing Integrity & Root Cause Protocol. The section should require production-first attribution, prohibit clock freezing and dispatcher workarounds that mask defects, and require clean verification under standard test conditions; no specific tests are mentioned.

Written by the indexing model from the issue text.

Description

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.
Dominant language
Kotlin
Stars
10.7k
Forks
708
Avg merge
8d 4h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from android/skills

All issues in android/skills

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.