ChatUniTest

repository·main·Indexed 41 days ago

https://github.com/zju-aces-ise/chatunitest

An LLM-based framework for automated unit test generation featuring an adaptive focal context and a generation-validation-repair cycle. It includes a core workflow library and a toolchain available as a Maven plugin, supporting various research implementations such as HITS, TESTSPARK, and COVERUP.

Tokens
888
Snippets
1
Records
4
Agent score
2%

What's inside ChatUniTest

  1. Overview of ChatUniTest

    main

    ChatUniTest is an LLM-based framework designed to automate and improve unit test generation. It addresses common issues like incorrect code execution and manual integration friction by using two key mechanisms:

    1. Adaptive Focal Context: Enhances prompts by including relevant code context.
    2. Generation-Validation-Repair: A cycle that generates tests, validates them, and automatically repairs errors to ensure they execute correctly.

    The project consists of ChatUniTest Core (the workflow library) and the ChatUniTest Toolchain (integrated tools).

  2. Overview of ChatUniTest architecture

    main

    ChatUniTest is a unit test generation tool that utilizes ChatGPT to overcome the limitations of traditional program analysis (which often lacks readability) and pre-trained models (which often suffer from low coverage).

    It operates on a generate-verify-fix framework:

    1. Generate: Collects necessary context information for the target method and uses ChatGPT to generate initial test cases.
    2. Verify: Checks if the generated test cases execute correctly.
    3. Fix: If verification fails, the compiler error information is fed back to ChatGPT to fix the test cases. This process iterates until the tests pass or the maximum number of iterations is reached.
  3. Use ChatUniTest via Maven Plugin

    main

    Most research implementations of ChatUniTest are available as a Maven plugin. You can run different research-specific versions of the tool by specifying different phaseType values during the Maven execution.

    To use a specific implementation, identify the corresponding phaseType from the implementation list and run your Maven command with that phase.

    # Example: Running the HITS implementation (replace <phaseType> with the specific one)
    mvn <phaseType>
    
    # Available phaseTypes based on research papers:
    # - CHATTESTER (Evaluating and Improving ChatGPT...)
    # - TESTSPARK (TestSpark: IntelliJ IDEA's Companion)
    # - SYMPROMPT (Code-Aware Prompting...)
    # - HITS (HITS: High-coverage LLM-based...)
    # - MUTAP (Effective Test Generation Using...)
    # - TELPA (Enhancing LLM-based Test Generation...)
    # - COVERUP (CoverUp: Coverage-Guided...)
    # - TESTPILOT (An Empirical Evaluation...)
  4. Reference of ChatUniTest Maven phaseTypes

    main

    The following phaseType values correspond to specific research implementations within the ChatUniTest Maven plugin:

    phaseTypeResearch Paper / Implementation
    CHATTESTEREvaluating and Improving ChatGPT for Unit Test Generation
    TESTSPARKTestSpark: IntelliJ IDEA’s Ultimate Test Generation Companion
    SYMPROMPTCode-Aware Prompting: A study of Coverage Guided Test Generation...
    HITSHITS: High-coverage LLM-based Unit Test Generation via Method Slicing
    MUTAPEffective Test Generation Using Pre-trained Large Language Models and Mutation Testing
    TELPAEnhancing LLM-based Test Generation for Hard-to-Cover Branches via Program Analysis
    COVERUPCoverUp: Coverage-Guided LLM-Based Test Generation
    TESTPILOTAn Empirical Evaluation of Using Large Language Models for Automated Unit Test Generation