arXiv:2504.15286cs.SEcs.AI2025-04中稿 · ICST 2025 Industry…被引 5

用大模型自动生成Java测试用例,提升覆盖率与开发效率

CUBETESTERAI: Automated JUnit Test Generation using the LLaMA Model

  • 基于LLaMA大模型生成JUnit测试代码,支持Spring Boot项目
  • 生成测试覆盖率达90%以上,优于主流工具
  • 集成GitLab与Docker,支持私密化部署与持续集成

本文提出一种基于LLaMA大模型的自动化JUnit测试生成方法,用于Java Spring Boot应用。所构建的CUBETESTERAI工具通过网页界面与GitLab+Docker的CI/CD流程集成,实现从代码片段直接生成测试用例,显著减少人工干预。测试生成依托RunPod在线GPU服务,保障数据隐私。利用LLaMA的自然语言理解能力,生成的测试具备高代码覆盖率(部分场景超90%),并自动修复缺失导入、私有方法调用等常见问题。在多个真实项目中对比现有先进工具,本方案在多数情况下表现更优,且稳定可靠。

原文摘要 · Abstract (English)

This paper presents an approach to automating JUnit test generation for Java applications using the Spring Boot framework, leveraging the LLaMA (Large Language Model Architecture) model to enhance the efficiency and accuracy of the testing process. The resulting tool, called CUBETESTERAI, includes a user-friendly web interface and the integration of a CI/CD pipeline using GitLab and Docker. These components streamline the automated test generation process, allowing developers to generate JUnit tests directly from their code snippets with minimal manual intervention. The final implementation executes the LLaMA models through RunPod, an online GPU service, which also enhances the privacy of our tool. Using the advanced natural language processing capabilities of the LLaMA model, CUBETESTERAI is able to generate test cases that provide high code coverage and accurate validation of software functionalities in Java-based Spring Boot applications. Furthermore, it efficiently manages resource-intensive operations and refines the generated tests to address common issues like missing imports and handling of private methods. By comparing CUBETESTERAI with some state-of-the-art tools, we show that our proposal consistently demonstrates competitive and, in many cases, better performance in terms of code coverage in different real-life Java programs.

测试生成大模型Java自动化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。