Skip to main content
QUICK REVIEW

[논문 리뷰] Effective Test Generation Using Pre-trained Large Language Models and Mutation Testing

Arghavan Moradi Dakhel, Amin Nikanjam|arXiv (Cornell University)|2023. 08. 31.
Software Testing and Debugging TechniquesComputer Science인용 수 3
한 줄 요약

이 논문은 사전 훈련된 대규모 언어 모델(LLM)이 생성한 테스트 케이스의 효과성을 향상시키기 위해 변형 테스팅을 통합하여 테스트 오라클의 약점을 식별하고 수정하는 MuTAP 프레임워크를 제안한다. 생존하는 변형체(mutants)를 피드백으로 사용해 프롬프트를 반복적으로 개선함으로써 버그 탐지 능력을 햖으며, Llama-2-chat를 사용하여 실제 버그가 있는 코드에서 94.06%의 버그 탐지율을 달성하여 Pynguin 및 제로샷/소샷 LLM 접근 방식을 모두 뛰어넘었다.

ABSTRACT

One of the critical phases in software development is software testing. Testing helps with identifying potential bugs and reducing maintenance costs. The goal of automated test generation tools is to ease the development of tests by suggesting efficient bug-revealing tests. Recently, researchers have leveraged Large Language Models (LLMs) of code to generate unit tests. While the code coverage of generated tests was usually assessed, the literature has acknowledged that the coverage is weakly correlated with the efficiency of tests in bug detection. To improve over this limitation, in this paper, we introduce MuTAP for improving the effectiveness of test cases generated by LLMs in terms of revealing bugs by leveraging mutation testing. Our goal is achieved by augmenting prompts with surviving mutants, as those mutants highlight the limitations of test cases in detecting bugs. MuTAP is capable of generating effective test cases in the absence of natural language descriptions of the Program Under Test (PUTs). We employ different LLMs within MuTAP and evaluate their performance on different benchmarks. Our results show that our proposed method is able to detect up to 28% more faulty human-written code snippets. Among these, 17% remained undetected by both the current state-of-the-art fully automated test generation tool (i.e., Pynguin) and zero-shot/few-shot learning approaches on LLMs. Furthermore, MuTAP achieves a Mutation Score (MS) of 93.57% on synthetic buggy code, outperforming all other approaches in our evaluation. Our findings suggest that although LLMs can serve as a useful tool to generate test cases, they require specific post-processing steps to enhance the effectiveness of the generated test cases which may suffer from syntactic or functional errors and may be ineffective in detecting certain types of bugs and testing corner cases PUTs.

연구 동기 및 목표

  • 기존 LLM 기반 테스트 생성 도구의 한계를 해결하기 위해, 코드 커버리지에 집중하지만 실제 버그를 자주 탐지하지 못하는 문제를 다루기 위함.
  • 변형 테스팅을 피드백 메커니즘으로 활용해 LLM 기반 테스트 케이스의 결함 노출 능력을 향상시키기 위함.
  • 테스트 대상 프로그램(put)에 대한 자연어 기술이 없이도 효과적인 테스트 생성을 가능하게 하기 위함.
  • 변형체 피드백을 통해 반복적 개선을 통해 문법적 또는 기능적 오류가 있는 비효율적 테스트 케이스의 수를 줄이기 위함.
  • 변형 테스팅이 LLM 기반 테스트 생성을 위한 강력한 평가 및 최적화 메커니즘으로 기능할 수 있음을 입증하기 위함.

제안 방법

  • MuTAP은 PUT와 지침을 기반으로 제로샷 또는 소샷 프롬프팅을 통해 사전 훈련된 LLM을 사용해 초기 테스트 케이스를 생성한다.
  • 생성된 테스트 케이스의 문법적 정확성과 반환 값의 정확성을 검증하여 유효하지 않은 케이스를 걸러낸다.
  • PUT에 대해 변형 테스팅을 적용하여 변형체를 생성하고, 초기 테스트 세트에 의해 살해되지 않은 생존하는 변형체를 식별한다.
  • 생존하는 변형체를 원래 프롬프트에 통합하여, PUT, 초기 테스트 케이스, 변형체 전용 실패 패턴을 포함한 개선된 프롬프트를 생성한다.
  • 개선된 프롬프트를 사용해 LLM을 재프롬프팅하여 이전에 생존한 변형체를 살킬 수 있는 개선된 테스트 케이스를 생성한다.
  • 최종 테스트 케이스는 정확성과 변형체 살해 능력에 따라 검증 및 순위 매겨진다.

실험 결과

연구 질문

  • RQ1변형 테스팅이 LLM 기반 테스트 케이스의 결함 탐지 능력을 향상시키는 데 효과적으로 활용될 수 있는가?
  • RQ2생존하는 변형체를 프롬프트에 통합하는 것이 테스트 케이스 생성의 효과성에 어떤 영향을 미치는가?
  • RQ3MuTAP은 PUT에 대한 자연어 기술이 없이도 효과적인 테스트 케이스를 생성할 수 있는가?
  • RQ4MuTAP은 최신 자동 테스트 생성 도구(예: Pynguin) 및 제로샷/소샷 LLM 접근 방식과 비교해 실제 버그를 탐지하는 데 얼마나 우수한가?
  • RQ5LLM에 변형체 피드백을 통합한 결과, 귀하의 케이스나 미묘한 버그를 얼마나 잘 탐지할 수 있는가?

주요 결과

  • MuTAP은 합성된 버그가 있는 코드에서 93.57%의 변형 스코어(MS)를 기록하여 평가된 모든 접근 방식을 뛰어넘었다.
  • Codex를 사용할 경우, MuTAP은 벤치마크에서 실제 버그가 있는 코드 스니펫 86.72%를 탐지했으며, 기준 방법보다 뚜렷한 향상을 보였다.
  • Llama-2-chat를 사용할 경우, MuTAP은 버그가 있는 코드의 94.06%를 탐지했으며, Pynguin 및 제로샷/소샷 LLM 기법을 모두 초월했다.
  • MuTAP은 기존 방법보다 최대 28% 더 많은 오류가 있는 인간이 작성한 코드 스니펫을 탐지했으며, Pynguin과 LLM 기반 접근 방식이 모두 탐지하지 못한 17%의 스니펫이 존재했다.
  • 생존하는 변형체를 프롬프트에 통합함으로써 테스트 케이스의 품질이 크게 향상되었으며, 특히 미묘한 버그나 귀하의 케이스를 탐지하는 데 효과적이었다.
  • MuTAP의 반복적 개선 프로세스는 초기 LLM 기반 테스트 케이스의 문법적 및 기능적 오류를 효과적으로 수정하여 유효성과 효과성을 높였다.

더 나은 연구,지금 바로 시작하세요

논문 읽기부터 검토까지, 연구 시간을 획기적으로 줄여보세요.

카드 등록 없음 · 무료 플랜 제공

이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.