Skip to main content
QUICK REVIEW

[Paper Review] Automated Unit Test Improvement using Large Language Models at Meta

Nadia Alshahwan, Jubin Chheda|arXiv (Cornell University)|Feb 14, 2024
Software Testing and Debugging TechniquesComputer Science5 citations
TL;DR

Meta's TestGen-LLM automates improvement of existing human-written Kotlin test classes using LLMs, with verifiable guarantees for improvement and non-regression, deployed in Instagram and Facebook test-a-thons.

ABSTRACT

This paper describes Meta's TestGen-LLM tool, which uses LLMs to automatically improve existing human-written tests. TestGen-LLM verifies that its generated test classes successfully clear a set of filters that assure measurable improvement over the original test suite, thereby eliminating problems due to LLM hallucination. We describe the deployment of TestGen-LLM at Meta test-a-thons for the Instagram and Facebook platforms. In an evaluation on Reels and Stories products for Instagram, 75% of TestGen-LLM's test cases built correctly, 57% passed reliably, and 25% increased coverage. During Meta's Instagram and Facebook test-a-thons, it improved 11.5% of all classes to which it was applied, with 73% of its recommendations being accepted for production deployment by Meta software engineers. We believe this is the first report on industrial scale deployment of LLM-generated code backed by such assurances of code improvement.

Motivation & Objective

  • Motivate automating unit test improvement to cover missed corner cases and increase test coverage while preserving existing behavior.
  • Introduce Assured Offline LLM-Based Software Engineering (Assured LLMSE) as the guiding framework for verifiable improvements.
  • Describe the TestGen-LLM system architecture, its filtration pipeline, and telemetry for evaluating LLMs and prompts.
  • Report industrial-scale deployment experiences of TestGen-LLM at Meta, including evaluation results and lessons learned.

Proposed method

  • Use an ensemble of two Meta-developed LLMs to extend existing Kotlin test classes with additional tests.
  • Apply a multi-filter pipeline: (i) buildability filter to ensure generated tests compile, (ii) non-regression filter by requiring tests to pass consistently, (iii) coverage filter to ensure added tests improve coverage.
  • Provide per-test-case guarantees and measurable diffs showing improvement to support CI integration.
  • Incorporate telemetry and an evaluation mode to study LLM prompts, temperatures, and prompt strategies before full deployment.
  • Adopt an MVP-to-full-deployment path with diff-time deployment to maximize relevance and engineer adoption.
  • Employ prompting strategies (extend_coverage, corner_cases, extend_test, statement_to_complete) and an LLM-ensemble approach to maximize unique test additions.
Figure 1. TestGen-LLM top level architecture (an instance of Assured Offline LLMSE (Alshahwan et al . , 2024 ) ).
Figure 1. TestGen-LLM top level architecture (an instance of Assured Offline LLMSE (Alshahwan et al . , 2024 ) ).

Experimental results

Research questions

  • RQ1Can LLMs generate new unit tests that build, pass reliably, and increase code coverage for existing test suites?
  • RQ2Do AI-generated test improvements land in production at industrial scale with engineers accepting a majority of recommendations?
  • RQ3What are effective prompting strategies and configurations (LLM choice, temperature, prompts) for reliable test-generation improvements?
  • RQ4How does per-test-case assurance influence trust and adoption of automated test improvements in a large codebase?
  • RQ5What are the practical deployment considerations and lessons learned for Assured LLMSE in production testing workflows?

Key findings

  • 75% of TestGen-LLM test cases built correctly in the Instagram evaluation.
  • 57% of test classes had at least one test case that builds correctly and passes reliably.
  • 25% of test classes had at least one test case that builds correctly, passes reliably, and increases line coverage.
  • During the Instagram test-a-thon, TestGen-LLM improved 11.5% of all classes to which it was applied.
  • 73% of TestGen-LLM test improvements were accepted for production deployment by Meta engineers.
  • Across three test-a-thons, TestGen-LLM improved 196 test classes out of 1,979 applied classes (approximately 10%).
  • Over Facebook and Instagram deployment, 144 of 280 diffs were accepted, 64 rejected, 61 not reviewed, 11 withdrawn.
  • The approach landed scalable, automated test improvements with verifiable guarantees against regression.
Figure 2. Sankey diagram showing the filtration process outcomes (as percentages of all test cases) from the Experimental Study on Instagram components for Reels and Stories products, using the four prompt strategies from Table 2 and the two language models, LLM1 and LLM2.
Figure 2. Sankey diagram showing the filtration process outcomes (as percentages of all test cases) from the Experimental Study on Instagram components for Reels and Stories products, using the four prompt strategies from Table 2 and the two language models, LLM1 and LLM2.

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.