CN-121996560-A - Intelligent test system and automatic generation method of code test cases
Abstract
The application discloses an intelligent test system and an automatic generation method of code test cases. In the scheme, a receiving module receives a test case generation request, an interface calling module acquires an interface path of a code base based on an interface name in the test case generation request, the interface path and the test case generation request are sent to a context service module through a target interface for calling a context service, the context service module acquires context codes related to codes to be tested from the code base based on the interface path, context analysis is conducted on the context codes and the test case generation request to generate target prompt words, and a test case generation module generates target code test cases based on the target prompt words by using a large language model. The application solves the problem that the code analysis capability of the existing continuous service is difficult to be effectively integrated into an intelligent test system, and improves the accuracy and the effectiveness of automatically generating test cases.
Inventors
- YANG FAN
- YANG YANXU
Assignees
- 北京商银微芯科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260127
Claims (10)
- 1. The intelligent test system is characterized by comprising a receiving module, an interface calling module, a content service module and a test case generating module; the receiving module is used for receiving a test case generation request initiated by a user and sending the test case generation request to the interface calling module, wherein the test case generation request comprises a prompt word required for generating a target code test case corresponding to a code to be tested and an interface name of a code library where the code to be tested is located; the interface calling module is used for receiving the test case generation request and acquiring an interface path of the code library based on an interface name in the test case generation request, and is also used for sending the interface path and the test case generation request to the context service module by calling a target interface of the context service; The context service module is used for receiving the interface path and the test case generation request, acquiring a context code related to the code to be tested from the code base based on the interface path, performing context analysis on the context code and the test case generation request, generating a target prompt word, and sending the target prompt word to the test case generation module; the test case generation module is used for receiving the target prompt word and generating the target code test case based on the target prompt word by utilizing a large language model.
- 2. The system of claim 1, wherein the content service module comprises: The code segment obtaining unit is used for analyzing the interface path to obtain an index identifier of the code base, and obtaining a context code related to the code to be tested from the code base according to the index identifier; and the prompt word generating unit is used for analyzing the test case generating request, generating a test case generating instruction, and integrating the test case generating instruction, the context code and the prompt word into the target prompt word.
- 3. The system of claim 1, wherein the intelligent test system further comprises: The code index creating module is used for responding to an index database construction instruction before acquiring context codes related to the codes to be tested from the code database based on the interface path, acquiring all code fragments in a corresponding code warehouse based on a code warehouse address, and analyzing all the code fragments so as to respectively convert the code fragments into code vector sequences; The code index creation module is further configured to construct the code library based on all the code vector sequences, and set corresponding index identifiers for the code library.
- 4. The system of claim 1, wherein the target interface is an API interface.
- 5. The system as recited in claim 1, wherein the system further comprises: and the display module is used for receiving the target code test case sent by the content service module and displaying the target code test case in a target page.
- 6. An automatic generation method of code test cases, which is applied to the intelligent test system of any one of claims 1 to 5, and comprises the following steps: Receiving a test case generation request initiated by a user, wherein the test case generation request comprises a prompt word required for generating a target code test case corresponding to a code to be tested and an interface name of a code library where the code to be tested is located; acquiring an interface path of the code library based on the interface name in the test case generation request; the interface path and the test case generation request are sent to the context service by calling a context service target interface; acquiring a context code related to the code to be tested from the code library based on the interface path by utilizing the context service, and carrying out context analysis on the context code and the test case generation request to generate a target prompt word; And generating the target code test case based on the target prompt word by using a large language model.
- 7. The method of claim 6, wherein the obtaining the context code related to the code under test from the code library based on the interface path, and performing context analysis on the context code and the test case generation request, generating the target hint word, comprises: analyzing the interface path to obtain an index identifier of the code base, and obtaining a context code related to the code to be tested from the code base according to the index identifier; Analyzing the test case generation request to generate a test case generation instruction, and integrating the test case generation instruction, the context code and the prompt word into the target prompt word.
- 8. The method of claim 6, wherein prior to retrieving context code associated with the code under test from the code library based on the interface path, the method further comprises: Responding to an index database construction instruction, acquiring all code fragments in a corresponding code warehouse based on a code warehouse address, and analyzing all the code fragments to respectively convert the code fragments into code vector sequences; and constructing the code base based on all the code vector sequences, and setting corresponding index identifiers for the code base.
- 9. A computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, which when executed by a processor, implements the method for automatically generating code test cases according to any one of claims 6-8.
- 10. A processor, configured to execute a computer program, the computer program when executed performing the method for automatically generating code test cases according to any one of claims 6-8.
Description
Intelligent test system and automatic generation method of code test cases Technical Field The application relates to the technical field of artificial intelligence, in particular to an intelligent test system and an automatic generation method of code test cases. Background Currently, AI programming assistant frameworks, such as continuous, based on a large language model (abbreviated LLM, collectively Large Language Model) provide powerful localized programming assistance functionality for developers. Continue is a modular, configurable, cross-platform open source framework that aims to enable developers to quickly integrate and use custom LLM programming aids in a local or cloud environment. The method realizes a complete working link from dialogue collaboration, intelligent Code complementation to automatic Code modification by supporting plug-in forms of mainstream IDEs such as VS codes and JetBrains and combining with strong context awareness and Code editing capability, and remarkably improves development efficiency. However, in the core service scenario of automatically generating test cases by AI, the design and function release of the existing architecture of the content framework are fully and ecologically developed around the IDE plugin, and all the core capabilities of the architecture including depth code index, intelligent context extraction and management, semantic code analysis and the like are tightly coupled in desktop integrated development environments such as VSCode, jetBrains and the like. The strong binding makes the content unable to be called as an independent service, so that advanced code analysis capability is difficult to be effectively integrated into Web end systems such as an intelligent test system, and thus the actual requirements of high-precision and automatic test case generation cannot be met. Disclosure of Invention Based on the above problems, the application provides an intelligent test system and an automatic generation method of code test cases, which aim to solve the technical problem that the code analysis capability of the existing continuous service is difficult to be effectively integrated into the intelligent test system so as to meet the actual requirements of high-precision and automatic test case generation. The embodiment of the application discloses the following technical scheme: The application provides an intelligent test system, which comprises a receiving module, an interface calling module, a continuous service module and a test case generating module, wherein the receiving module is used for receiving a test case from a user; the receiving module is used for receiving a test case generation request initiated by a user and sending the test case generation request to the interface calling module, wherein the test case generation request comprises a prompt word required for generating a target code test case corresponding to a code to be tested and an interface name of a code library where the code to be tested is located; the interface calling module is used for receiving the test case generation request and acquiring an interface path of the code library based on an interface name in the test case generation request, and is also used for sending the interface path and the test case generation request to the context service module by calling a target interface of the context service; The context service module is used for receiving the interface path and the test case generation request, acquiring a context code related to the code to be tested from the code base based on the interface path, performing context analysis on the context code and the test case generation request, generating a target prompt word, and sending the target prompt word to the test case generation module; the test case generation module is used for receiving the target prompt word and generating the target code test case based on the target prompt word by utilizing a large language model. In an alternative implementation, the content service module includes: The code segment obtaining unit is used for analyzing the interface path to obtain an index identifier of the code base, and obtaining a context code related to the code to be tested from the code base according to the index identifier; and the prompt word generating unit is used for analyzing the test case generating request, generating a test case generating instruction, and integrating the test case generating instruction, the context code and the prompt word into the target prompt word. In an alternative implementation, the intelligent test system further includes: The code index creating module is used for responding to an index database construction instruction before acquiring context codes related to the codes to be tested from the code database based on the interface path, acquiring all code fragments in a corresponding code warehouse based on a code warehouse address, and analyzing all the code fragments so as t