mlsanityData to 14 Oct 2026

On the risk of coding before testing: An empirical study on LLM-based test generation workflow

arXiv 2607.05139 ↗First posted 6 Jul 2026cs.SEcited by 3

Not on the map. Why?

Abstract (arXiv)

Large Language Models (LLMs) are increasingly used in software engineering workflows to generate both source code and test suites. This dual capability has enabled emerging development paradigms, including test-first and agentic workflows, where a single model is producing and validating implementations. However, these approaches assume that generated tests act as independent and reliable oracles - a fundamental requirement for effective software testing. In this paper, we challenge this assumption and investigate whether LLM-generated code biases the generation of subsequent tests. We introduce and empirically study the phenomenon of error propagation, where faults in generated code are systematically replicated in associated test artifacts. This leads to cases where incorrect implementations and tests are mutually consistent, masking defects rather than revealing them. We evaluate this effect across a range of programming tasks and agentic workflows, analyzing the consistency between generated code and test assertions, with particular focus on scenarios of aligned failures. Our study examines (i) whether erroneous code artifacts bias test generation, (ii) whether such bias persists under different prompting strategies, including chain-of-thought reasoning, and (iii) how errors propagate across multi-step workflows in which intermediate outputs are reused as context. The results show that error propagation is prevalent and impactful: generating tests after faulty code significantly reduces fault detection effectiveness compared to generating tests independently (14% vs. 25%). These findings highlight a fundamental limitation of current workflows, where lack of independence between generated artifacts undermines the reliability of automated testing. Furthermore, our results expose a previously underexplored threat to validity in empirical studies relying on coupled generation pipelines.

Key facts. Cited by 3 papers in the map (data through 14 Oct 2026). First posted on arXiv 6 Jul 2026.

Builds on

No reference list yet.

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 3.

3 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026Bias in the Loop: Auditing LLM-as-a-Judge for Software Engineering
  2. 2026Test-Driven Approaches to Software Engineering with Large Language Models: A Survey of Phases, Tasks, and Agent Skills
  3. 2024Large-scale, Independent and Comprehensive study of the power of LLMs for test case generation
  4. 2026Rethinking the Value of Agent-Generated Tests for LLM-Based Software Engineering Agents
  5. 2024SWT-Bench: Testing and Validating Real-World Bug-Fixes with Code Agents
  6. 2024Understanding Defects in Generated Codes by Language Models
  7. 2026LLMs taking shortcuts in test generation: A study with SAP HANA and LevelDB
  8. 2025AugmenTest: Enhancing Tests with LLM-Driven Oracles