UTFix: Change Aware Unit Test Repairing using LLM

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Rahman, Shanto, Kuhar, Sachit, Cirisci, Berk, Garg, Pranav, Wang, Shiqi, Ma, Xiaofei, Deoras, Anoop, Ray, Baishakhi
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866915204553506816
author Rahman, Shanto
Kuhar, Sachit
Cirisci, Berk
Garg, Pranav
Wang, Shiqi
Ma, Xiaofei
Deoras, Anoop
Ray, Baishakhi
author_facet Rahman, Shanto
Kuhar, Sachit
Cirisci, Berk
Garg, Pranav
Wang, Shiqi
Ma, Xiaofei
Deoras, Anoop
Ray, Baishakhi
contents Software updates, including bug repair and feature additions, are frequent in modern applications but they often leave test suites outdated, resulting in undetected bugs and increased chances of system failures. A recent study by Meta revealed that 14%-22% of software failures stem from outdated tests that fail to reflect changes in the codebase. This highlights the need to keep tests in sync with code changes to ensure software reliability. In this paper, we present UTFix, a novel approach for repairing unit tests when their corresponding focal methods undergo changes. UTFix addresses two critical issues: assertion failure and reduced code coverage caused by changes in the focal method. Our approach leverages language models to repair unit tests by providing contextual information such as static code slices, dynamic code slices, and failure messages. We evaluate UTFix on our generated synthetic benchmarks (Tool-Bench), and real-world benchmarks. Tool- Bench includes diverse changes from popular open-source Python GitHub projects, where UTFix successfully repaired 89.2% of assertion failures and achieved 100% code coverage for 96 tests out of 369 tests. On the real-world benchmarks, UTFix repairs 60% of assertion failures while achieving 100% code coverage for 19 out of 30 unit tests. To the best of our knowledge, this is the first comprehensive study focused on unit test in evolving Python projects. Our contributions include the development of UTFix, the creation of Tool-Bench and real-world benchmarks, and the demonstration of the effectiveness of LLM-based methods in addressing unit test failures due to software evolution.
format Preprint
id arxiv_https___arxiv_org_abs_2503_14924
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle UTFix: Change Aware Unit Test Repairing using LLM
Rahman, Shanto
Kuhar, Sachit
Cirisci, Berk
Garg, Pranav
Wang, Shiqi
Ma, Xiaofei
Deoras, Anoop
Ray, Baishakhi
Software Engineering
Software updates, including bug repair and feature additions, are frequent in modern applications but they often leave test suites outdated, resulting in undetected bugs and increased chances of system failures. A recent study by Meta revealed that 14%-22% of software failures stem from outdated tests that fail to reflect changes in the codebase. This highlights the need to keep tests in sync with code changes to ensure software reliability. In this paper, we present UTFix, a novel approach for repairing unit tests when their corresponding focal methods undergo changes. UTFix addresses two critical issues: assertion failure and reduced code coverage caused by changes in the focal method. Our approach leverages language models to repair unit tests by providing contextual information such as static code slices, dynamic code slices, and failure messages. We evaluate UTFix on our generated synthetic benchmarks (Tool-Bench), and real-world benchmarks. Tool- Bench includes diverse changes from popular open-source Python GitHub projects, where UTFix successfully repaired 89.2% of assertion failures and achieved 100% code coverage for 96 tests out of 369 tests. On the real-world benchmarks, UTFix repairs 60% of assertion failures while achieving 100% code coverage for 19 out of 30 unit tests. To the best of our knowledge, this is the first comprehensive study focused on unit test in evolving Python projects. Our contributions include the development of UTFix, the creation of Tool-Bench and real-world benchmarks, and the demonstration of the effectiveness of LLM-based methods in addressing unit test failures due to software evolution.
title UTFix: Change Aware Unit Test Repairing using LLM
topic Software Engineering
url https://arxiv.org/abs/2503.14924