用大模型自动生成异常行为测试,补足开发中忽略的异常场景。
A Tool for Generating Exceptional Behavior Tests With Large Language Models
- 基于微调的CodeLlama生成异常抛出测试用例。
- 考虑异常触发条件和相似正常路径,提升覆盖率。
- 适合关注代码健壮性的开发者或自动化测试团队。
异常行为测试(EBTs)在软件开发中至关重要,用于验证代码能否正确处理意外事件并抛出相应异常。然而,已有研究表明开发者常优先测试正常流程(“快乐路径”),而忽视异常场景。本文提出exLong框架,利用基于CodeLlama微调的大语言模型,自动生成EBTs以填补这一空白。该框架融入对异常抛出轨迹的推理、保护抛出语句的条件表达式分析,以及执行相似轨迹的非异常测试用例。演示视频展示了exLong如何有效辅助开发者为其项目构建全面的异常测试集(视频地址:https://youtu.be/Jro8kMgplZk)。
原文摘要 · Abstract (English)
Exceptional behavior tests (EBTs) are crucial in software development for verifying that code correctly handles unwanted events and throws appropriate exceptions. However, prior research has shown that developers often prioritize testing "happy paths", e.g., paths without unwanted events over exceptional scenarios. We present exLong, a framework that automatically generates EBTs to address this gap. exLong leverages a large language model (LLM) fine-tuned from CodeLlama and incorporates reasoning about exception-throwing traces, conditional expressions that guard throw statements, and non-exceptional behavior tests that execute similar traces. Our demonstration video illustrates how exLong can effectively assist developers in creating comprehensive EBTs for their project (available at https://youtu.be/Jro8kMgplZk).
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。