Search

CN-121979792-A - Interface test case generation method and computing device

CN121979792ACN 121979792 ACN121979792 ACN 121979792ACN-121979792-A

Abstract

The embodiment of the application relates to an interface test case generation method and computing equipment, and the method comprises the steps of obtaining a text test case and an HAR file, wherein the text test case is a document describing a test scene through natural language, the HAR file is a data file captured through monitoring network interaction in the process of executing the text test case by a user, analyzing the HAR file, extracting interface request information from the HAR file, and generating the interface test case through a large language model based on the text test case, the interface request information and a preset rule base. According to the scheme, the text case and the corresponding network flow data under the real service scene are obtained, the interface request information is extracted accurately, and finally the large language model is driven by the fusion rule base to intelligently generate the test case covering the normal, abnormal and scene interfaces, so that the efficient and accurate conversion from manual test to automatic code is realized, and the test efficiency, coverage rate and reliability are remarkably improved.

Inventors

  • YANG CHAO

Assignees

  • 河南秦尉数字技术有限公司

Dates

Publication Date
20260505
Application Date
20260113

Claims (10)

  1. 1. A method for generating an interface test case, the method comprising: acquiring a text test case and a HAR file, wherein the text test case is a document describing a test scene through natural language, and the HAR file is a data file captured through monitoring network interaction in the process of executing the text test case by a user; Analyzing the HAR file, and extracting interface request information from the HAR file; And generating the interface test case through a large language model based on the text test case, the interface request information and a preset rule base.
  2. 2. The method of claim 1, wherein prior to obtaining the HAR file, the method further comprises: Triggering a preset front injection point and a preset rear injection point when executing the text test case; A marker request identifying a single text test case boundary is recorded into the HAR file.
  3. 3. The method of claim 2, wherein the parsing the HAR file comprises: And splitting the HAR file into a plurality of sub HAR files according to the marking request, wherein each sub HAR file corresponds to an interface request sequence triggered by one text test case.
  4. 4. The method of claim 1, wherein generating interface test cases via a large language model comprises: determining the data type and the value range of parameters in the interface request based on the large language model and the interface request information; and generating a single-interface test case based on the data type, the value range and the parameter rules in the rule base, wherein the single-interface test case comprises the step of setting the value of the parameter as a boundary condition or an abnormal value.
  5. 5. The method according to claim 4, wherein the method further comprises: and generating an assertion rule for verifying response content according to response information which is extracted from the HAR file and corresponds to the interface request information through the large language model.
  6. 6. The method of claim 1, wherein generating interface test cases via a large language model comprises: Identifying a plurality of interfaces associated with business logic and corresponding calling sequences based on the text test case through the large language model; extracting parameter transfer dependency relations among the interfaces; and constructing a multi-interface scene test case based on the calling sequence and the parameter transfer dependency relationship.
  7. 7. The method according to claim 1, wherein the method further comprises: And when the interface test case is generated through the large language model, providing a structured prompt word for the large language model, wherein the prompt word is used for restraining the test case format, the assertion mode, the abnormal scene coverage and the parameter extraction rule.
  8. 8. The method according to claim 1, wherein the method further comprises: And based on the sensitive information processing rules in the rule base, performing desensitization processing on specific header fields in the HAR file, and replacing desensitized contents by using placeholders in the generated test cases.
  9. 9. The method according to claim 1, wherein the method further comprises: and filtering out non-business related requests in the interface request information when the HAR file is analyzed.
  10. 10. A computing device, comprising: At least one processor; a memory for storing the at least one processor-executable instruction; Wherein the at least one processor is configured to execute the instructions to implement the method of any of claims 1-9.

Description

Interface test case generation method and computing device Technical Field The embodiment of the application relates to the technical field of interface test, in particular to an interface test case generation method and computing equipment. Background With the rapid development of internet applications, interface testing has become an important means of ensuring software quality. However, the writing of the interface test cases at present mainly depends on manual completion, the mode is low in efficiency and difficult to cover all normal and abnormal scenes, the accuracy and the integrity of interface documents are seriously depended, and the maintenance cost is extremely high when the number of system interfaces is large and the iteration is frequent. In the related art, there are some tools for parsing and generating basic test cases by grabbing package data or environmental logs. However, the related technology can only generate an isolated single-interface case, lacks the capability of automatically identifying and connecting in series service logic association and calling time sequences among multiple interfaces, and is difficult to generate a test case fitting a real service scene, so that the test coverage rate is insufficient. Disclosure of Invention The embodiment of the application provides an interface test case generation method and computing equipment, which can improve test efficiency and coverage rate. According to a first aspect of an embodiment of the present application, there is provided a method for generating an interface test case, including: acquiring a text test case and a HAR file, wherein the text test case is a document describing a test scene through natural language, and the HAR file is a data file captured through monitoring network interaction in the process of executing the text test case by a user; analyzing the HAR file, and extracting interface request information from the HAR file; based on the text test case, the interface request information and a preset rule base, the interface test case is generated through a large language model. According to the scheme, the text case and the corresponding network flow data under the real service scene are obtained, the interface request information is extracted accurately, and finally the large language model is driven by the fusion rule base to intelligently generate the test case covering the normal, abnormal and scene interfaces, so that the efficient and accurate conversion from manual test to automatic code is realized, and the test efficiency, coverage rate and reliability are remarkably improved. In one possible implementation, before acquiring the HAR file, the method further includes: Triggering a preset front injection point and a preset rear injection point when executing the text test case; A marker request identifying a single text test case boundary is recorded into the HAR file. According to the scheme, by introducing the two prepositions, the technical problem that the interface sequence corresponding to the single test scene is accurately stripped from the mixed flow is effectively solved, and a reliable data foundation is laid for the subsequent generation of the high-fidelity scenerization interface test case. In one possible implementation, parsing the HAR file includes: and splitting the HAR file into a plurality of sub HAR files according to the marking request, wherein each sub HAR file corresponds to an interface request sequence triggered by one text test case. According to the scheme, the whole flow data can be processed by classifying the scene data, and each sub HAR file becomes an independent and pure service scene data packet, so that a data base can be provided for accurately generating an automatic test case which is strictly corresponding to a specific test scene and contains a multi-interface call sequence for a subsequent large language model, and the problem that the multi-interface scene case is difficult to automatically identify and construct can be solved. In one possible implementation, generating interface test cases through a large language model includes: Determining the data type and the value range of parameters in the interface request based on the large language model and the interface request information; And generating a single-interface test case based on the data type, the value range and the parameter rules in the rule base, wherein the single-interface test case comprises the step of setting the value of the parameter as a boundary condition or an abnormal value. By the scheme, the spanning from simple reproduction of normal flow to intelligent coverage of abnormal scene and boundary condition of test case generation can be realized, and the depth and defect discovery capability of the generated test case are obviously improved. In one possible implementation, the method further includes: And generating an assertion rule for verifying response content according to the response i