Skip to main content
QUICK REVIEW

[논문 리뷰] Domain Adaptation for Code Model-based Unit Test Case Generation

Jiho Shin, Sepehr Hashtroudi|arXiv (Cornell University)|2023. 08. 15.
Software Engineering ResearchComputer Science인용 수 9
한 줄 요약

이 논문은 CodeT5의 프로젝트 수준 도메인 적응을 사용하여 Def defects4j 프로젝트용 컴파일 가능한 단위 테스트를 생성하고, 라인 커버리지, BLEU/CodeBLEU, 그리고 EvoSuite와의 호환성에서 향상을 보인다.

ABSTRACT

Recently, deep learning-based test case generation approaches have been proposed to automate the generation of unit test cases. In this study, we leverage Transformer-based code models to generate unit tests with the help of Domain Adaptation (DA) at a project level. Specifically, we use CodeT5, a relatively small language model trained on source code data, and fine-tune it on the test generation task. Then, we apply domain adaptation to each target project data to learn project-specific knowledge (project-level DA). We use the Methods2test dataset to fine-tune CodeT5 for the test generation task and the Defects4j dataset for project-level domain adaptation and evaluation. We compare our approach with (a) CodeT5 fine-tuned on the test generation without DA, (b) the A3Test tool, and (c) GPT-4 on five projects from the Defects4j dataset. The results show that tests generated using DA can increase the line coverage by 18.62%, 19.88%, and 18.02% and mutation score by 16.45%, 16.01%, and 12.99% compared to the above (a), (b), and (c) baselines, respectively. The overall results show consistent improvements in metrics such as parse rate, compile rate, BLEU, and CodeBLEU. In addition, we show that our approach can be seen as a complementary solution alongside existing search-based test generation tools such as EvoSuite, to increase the overall coverage and mutation scores with an average of 34.42% and 6.8%, for line coverage and mutation score, respectively.

연구 동기 및 목표

  • 신경망 단위 테스트 생성의 강건성 및 도메인 이동성 addressed.
  • 사전 학습된 코드 모델을 테스트 생성에 맞게 도메인 특정 데이터로 적응시키기.
  • baselines(GPT-4, A3Test) 및 탐색 기반 도구(EvoSuite)와의 비교 평가.
  • 실제 실행 지표(라인 커버리지, 변이 점수)와 같은 지표를 사용하여 개선 사항 시연.

제안 방법

  • Methods2test 데이터셋을 사용하여 테스트-생성 다운스트림 작업에서 CodeT5를 미세 조정합니다.
  • 라인을 커버하는 테스트에 매핑하고 각 라인에 대해 세 가지 컨텍스트를 추출하여 프로젝트 특정 데이터셋을 생성합니다.
  • 프로젝트 특정 데이터셋에 대해 추가로 학습하여 프로젝트 수준 도메인 적응을 적용합니다.
  • 트리-시터 기반 파서와 증분 컴파일을 사용하여 생성된 테스트의 컴파일 가능성을 보장하기 위한 후처리.
  • 생성된 테스트를 실제로 실행하여 라인 커버리지와 변이 점수를 측정하고 BLEU/CodeBLEU 지표를 평가합니다.

실험 결과

연구 질문

  • RQ1RQ1: 트랜스포머 기반 코드 모델이 상당한 라인 커버리지를 가진 컴파일 가능한 고품질 테스트 케이스를 생성할 수 있는가?
  • RQ2RQ2: 프로젝트 수준 도메인 적응이 자동으로 생성된 코드 커버리지를 향상시키는 데 얼마나 효과적인가?
  • RQ3RQ3: 제안된 접근법이 EvoSuite와 같은 탐색 기반 테스트 생성 도구를 보강하거나 상호 보완할 수 있는가?

주요 결과

  • 도메인 적응은 DA 없이 CodeT5 대비 평균 18.62%의 라인 커버리지 증가, A3Test 대비 19.88% 증가, GPT-4 기준선 대비 18.02% 증가를 보여준다.
  • 이 접근법은 BLEU 및 CodeBLEU 점수의 향상을 가져오고 EvoSuite와 보완하여 전반적인 커버리지와 변이 점수를 증가시킨다.
  • 도메인 적응된 테스트 생성과 EvoSuite를 함께 사용하면 라인 커버리지 평균 34.42% 증가와 변이 점수 6.8% 증가를 보인다.
  • 평가는 NLP 기반 지표뿐 아니라 실제 테스트 실행 지표(라인 커버리지 및 변이 테스트)를 사용한다.

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.