Skip to main content
QUICK REVIEW

[Paper Review] CoverUp: Effective High Coverage Test Generation for Python

Juan Altmayer Pizzorno, Emery D. Berger|arXiv (Cornell University)|Mar 24, 2024
Software Testing and Debugging TechniquesComputer Science6 citations
TL;DR

CoverUp combines coverage analysis with LLM-driven test generation to produce high-coverage Python regression tests, iteratively refining prompts based on measured coverage.

ABSTRACT

Testing is an essential part of software development. Test generation tools attempt to automate the otherwise labor-intensive task of test creation, but generating high-coverage tests remains challenging. This paper proposes CoverUp, a novel approach to driving the generation of high-coverage Python regression tests. CoverUp combines coverage analysis, code context, and feedback in prompts that iteratively guide the LLM to generate tests that improve line and branch coverage. We evaluate our prototype CoverUp implementation across a benchmark of challenging code derived from open-source Python projects and show that CoverUp substantially improves on the state of the art. Compared to CodaMosa, a hybrid search/LLM-based test generator, CoverUp achieves a per-module median line+branch coverage of 80% (vs. 47%). Compared to MuTAP, a mutation- and LLM-based test generator, CoverUp achieves an overall line+branch coverage of 89% (vs. 77%). We also demonstrate that CoverUp's performance stems not only from the LLM used but from the combined effectiveness of its components.

Motivation & Objective

  • Aim to increase regression test coverage for Python programs beyond prior methods.
  • Develop a feedback loop where coverage analysis guides LLM-based test generation.
  • Evaluate CoverUp against the previous state of the art (CodaMosa) and analyze the value of iterative dialog.
  • Address practical challenges in LLM-based test generation, including integration checks and flaky tests.

Proposed method

  • Measure current test coverage with SlipCover and identify code segments lacking coverage.
  • Segment code into concise excerpts containing missing coverage and provide context for LLM prompts.
  • Prompt an LLM (GPT-4 Turbo) to generate tests for each missing-segment, highlighting uncovered lines/branches.
  • Execute generated tests, measure coverage, and continue dialog to fix issues or improve coverage.
  • Perform integration checks by running the full suite and disable failing tests or isolate causes when needed.
  • Handle practical issues such as missing modules, flaky tests, and asynchronous prompting to speed up generation.

Experimental results

Research questions

  • RQ1RQ1: How does CoverUp’s coverage compare to the previous state of the art (CodaMosa codex and gpt4)?
  • RQ2RQ2: How does CoverUp’s coverage compare to CodaMosa using a state-of-the-art LLM (GPT-4)?
  • RQ3RQ3: How effective is CoverUp’s continued dialogue at increasing coverage?

Key findings

  • CoverUp achieves higher median module coverage than CodaMosa (codex): line 81% vs 62%, branch 53% vs 35%, line+branch 78% vs 55%.
  • Across all code, CoverUp increases line coverage from 54% to 61%, branch coverage from 34% to 43%, and line+branch from 49% to 57%.
  • CoverUp yields higher coverage than CodaMosa (gpt4) as well, across the entire suite and per-module analysis.
  • On the PY benchmark suite, CoverUp approaches near-100% overall and median coverage across all metrics.
  • Approximately 42.9% of successes were achieved via iterative prompts, rising to 49.2% when considering up to three prompts, highlighting the value of continued dialogue.
  • CoverUp demonstrates strong performance on code where Pynguin initially achieved full coverage, indicating robustness beyond difficult modules.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.