Interface automation use case generation method and device, equipment and storage medium
By collecting and processing traffic data in the test environment, and automatically generating interface automation use cases in combination with call links and code coverage, the problems of slow generation and high maintenance costs caused by manual writing in the existing technology are solved, and the problem of slow generation and high maintenance costs of interface automation use cases caused by manual writing is realized. Fast regression and efficient use case updates.
Patent Information
- Application Number
- CN202411270449.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-12-31
AI Technical Summary
The existing interface automation use case generation methods require manual writing, resulting in slow writing speed, long running time, high maintenance costs, and inability to keep up with the speed of version iteration quickly.
By silently collecting traffic data in the background in the test environment, using traffic recording and playback technology to combine call links and code coverage for refined processing, automatically generate interface automation use cases, dynamically replace data dependencies, and filter and supplement tests according to change rules.
It realizes rapid generation and update of interface automation use cases, reduces writing and maintenance costs, improves version regression efficiency, and ensures the accuracy and coverage of use cases.
Smart Images

Figure CN119226159A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of program automation testing, and in particular to an interface automation use case generation method, device, equipment and storage medium. Background Art
[0002] The department's products have been integrated and the business architecture has changed, resulting in a large number of interface changes. A large number of interface automation use cases accumulated before cannot be used or need to be changed again. At the same time, new automation use cases need to be written manually, which is time-consuming and labor-intensive, and has high maintenance costs. During the version testing process, the speed of writing automation use cases cannot keep up with the speed of version release iterations. Therefore, we hope to use an innovative method to make our interface automation use cases write faster, reduce maintenance costs, increase running time, and quickly supplement the coverage of interface automation use cases to better ensure the quality of the version.
[0003] Currently, most of the methods for automatically generating interface automation use cases are as follows: One method is to obtain interface documents such as swagger and generate interface automation use cases by parsing the interface documents. However, the disadvantage of this method is that it relies on developers to write annotations when writing code, and the parameters of the generated interface automation use cases are relatively limited and are not real test data.
[0004] One method is to generate interface automation use cases by parsing YAML based on interface management platforms such as YAPI. The disadvantage of this method is that it requires manual maintenance of YAML configuration files.
[0005] One method is to use the Charles packet capture tool and the packet capture and parsing method to generate automatic interface use cases. The disadvantage of this method is that it is necessary to open Charles and other packet capture tools during testing and configure the proxy to capture the interface, and silent collection in the background cannot be achieved. Summary of the invention
[0006] Purpose of the invention: To propose a method, device, equipment and storage medium for automatically generating interface use cases, so as to effectively solve the above-mentioned problems existing in the prior art.
[0007] First, a method for automatically generating interface use cases is proposed, and the steps are as follows: Collect the flow data of a predetermined period in the test environment and regard it as the rough flow data; Periodically aggregating the coarse flow data into a first data packet; Refining the rough flow data in the first data packet to obtain accurate flow data, and aggregating the accurate flow data of a predetermined scale into a second data packet; receiving the second data packet, performing use case splicing on scattered data in the second data packet, and generating an interface automation use case script; Apply the generated interface automation use case script to the formal environment to achieve automatic update of the program interface.
[0008] In a further embodiment of the first aspect, in the process of generating the interface automation use case, the dependency on data in the interface automation use case is dynamically replaced according to the call link.
[0009] In a further embodiment of the first aspect, performing fine processing on the coarse flow data in the first data packet specifically includes: Deploy coverage probes on the application under test; The coverage probe acquires the path taken by each flow; Analyze the mapping relationship between each flow, path, and code; The mapping relationship is used as a deduplication rule to remove the remaining duplicate traffic and obtain accurate traffic data.
[0010] In a further embodiment of the first aspect, the interface automation use case generation method further includes: screening the changed program interfaces, running only the interface automation use cases of the changed interfaces, and performing supplementary testing according to the coverage rate, and this process specifically includes: Perform diff analysis based on the baseline commitid and the newly submitted commitid to parse out the change rules; According to the parsed change rules, a set of affected interface automation use cases is screened out, and a code coverage report is generated.
[0011] A second aspect of the present invention provides an interface automation use case generation device, which includes four parts: a traffic collector, a data center server, a use case generator, and a diff parser.
[0012] The flow collector is deployed in the test environment, and collects the flow data of the current scheduled period by the flow collector, which is regarded as the coarse flow data; the flow collector regularly aggregates the coarse flow data into the first data packet and transmits it back to the data center server.
[0013] The data center server performs fine processing on the coarse flow data in the first data packet to obtain precise flow data, and aggregates the precise flow data of a predetermined scale into a second data packet.
[0014] The use case generator is used to receive the second data packet and perform use case splicing on its scattered data to generate an interface automation use case script; the generated interface automation use case script is applied to the formal environment to realize automatic update of the program interface.
[0015] The diff parser is used to filter the changed program interfaces, only run the interface automation use cases of the changed interfaces, and perform additional tests based on the coverage; the diff parser performs diff analysis based on the baseline commitid and the newly submitted commitid to parse out the change rules; based on the parsed change rules, filter out the affected interface automation use case set and generate a code coverage report.
[0016] In a third aspect, an electronic device is proposed, which includes a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the interface automation use case generation method as described in the first aspect is implemented.
[0017] In a fourth aspect, a computer-readable storage medium is proposed, wherein at least one executable instruction is stored in the storage medium. When the executable instruction is executed on an electronic device, the electronic device executes the interface automation use case generation method as described in the first aspect.
[0018] Beneficial effect: The present invention proposes an interface automation use case generation method, device, equipment and storage medium, which fully utilizes the data traffic generated by testers during the test process to automatically generate interface automation use cases, and at the same time uses the method of accurately screening automation use cases to solve the problems of slow interface automation use case writing speed, long running time, high maintenance cost, etc., making version regression faster and more efficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flow chart of the method for automatically generating use cases for interfaces in an embodiment of the present invention.
[0020] Figure 2 It is a flow chart of flow data processing in an embodiment of the present invention.
[0021] Figure 3 It is a flowchart of the rapid operation of the automated use case generated in the embodiment of the present invention in CI. DETAILED DESCRIPTION
[0022] In the following description, a large number of specific details are provided to provide a more thorough understanding of the present invention. However, it is apparent to those skilled in the art that the present invention can be implemented without one or more of these details. In other examples, in order to avoid confusion with the present invention, some technical features known in the art are not described. Example 1
[0023] The purpose of the invention is to use a new technical means to solve a series of pain points such as the need for manual writing of traditional interface automation test cases, the need for interface automation case writers to be familiar with the interface automation framework, the need to unify and standardize the operation steps, the need to be familiar with code languages such as Python, and the need to constantly adjust the interface automation case scripts as the interface changes, which leads to high maintenance costs of interface automation case studies, slow writing speed, and long running time.
[0024] The present invention uses traffic recording and playback to silently collect traffic in a test environment in the background, and combines call links and code coverage as well as traffic filtering, noise reduction, deduplication and other processing to achieve a method for automatically generating interface automation use cases. This method of use case generation does not require human intervention, and as testers continue to test, the interface automation use cases will be continuously updated and iterated, and will run accurately during operation, thereby solving the problems of slow interface automation use case writing speed, long running time, and high maintenance cost.
[0025] The purpose of the embodiment of the present invention is to provide a method for generating interface automation use cases for rapid regression. By silently inserting a traffic collector in the background of the test environment, during the test of the functional tester, the traffic collected by the traffic collector is regularly transmitted back to the data center server, and then a series of automatic processing operations are performed to generate interface automation use cases. At the same time, according to the diff parser, the changed interface is screened, and only the interface automation use cases of the changed interface are run, and supplementary tests are performed according to the coverage, so as to solve the problems of slow writing speed, long running time, high maintenance cost of interface automation use cases, so as to make the regression of the version faster and more efficient. Example 2
[0026] This embodiment discloses a specific process of an interface automatic use case generation method. Figure 1 , the specific steps are as follows: A traffic collector is deployed in the test environment, and the traffic collector collects traffic data of the current scheduled period and regards it as coarse traffic data; The traffic collector periodically aggregates the coarse traffic data into the first data packet and transmits it back to the data center server; The data center server performs fine processing on the coarse flow data in the first data packet to obtain accurate flow data, and aggregates the accurate flow data of a predetermined scale into a second data packet; The use case generator receives the second data packet, performs use case splicing on the scattered data in the second data packet, and generates an interface automation use case script; in the process of generating the interface automation use case, dynamically replaces the dependency on data in the interface automation use case according to the call link; Apply the generated interface automation use case script to the formal environment to achieve automatic update of the program interface.
[0027] Figure 2 The specific process of the data center server performing refined processing on the crude flow data in the first data packet is shown: the crude flow data in the first data packet is first obtained, and the coverage probe is deployed on the application under test. The coverage probe then obtains the path that each flow has taken, and parses the mapping relationship between each flow, path, and code. The mapping relationship is used as a deduplication rule to remove the remaining duplicate flows and obtain accurate flow data.
[0028] Figure 3 The example shows the quick running process of the generated automation test cases in CI: the changed program interfaces are screened according to the diff parser, only the interface automation test cases of the changed interfaces are run, and additional tests are performed according to the coverage. The diff parser performs diff analysis based on the baseline commitid and the newly submitted commitid to parse out the change rules; based on the parsed change rules, the affected interface automation test case set is screened out to generate a code coverage report. Example 3
[0029] The embodiment of the present invention discloses an automatic use case generation method for rapid regression based on traffic recording and playback plus call chain plus code coverage, which is described in detail below. The inventive method is applied in the version iteration process, such as Figure 1 shown, including: First, deploy a traffic collector in the test environment. The collector will silently collect traffic in the test environment in the background. Second, the traffic collector will periodically transmit the collected traffic back to the data center server. Then, the traffic processor will be triggered to deduplicate, filter, and reduce noise on the collected traffic. Finally, the use case generator will be called to generate use cases for interface automation. During the use case generation process, the data dependency in the interface automation use case will be dynamically replaced according to the call link, such as Figure 1 shown.
[0030] In the above steps, the traffic processor will perform deduplication and filtering on the collected traffic. Compared with the traditional traffic processing method, the present invention uses code coverage to filter and deduplicate the traffic. First, a mapping relationship between traffic and code is established, and then the same traffic in each method is deduplicated, so that the filtered traffic is small and accurate. Figure 2 shown.
[0031] During the CI process, another branch will be taken, such as Figure 3 shown, including: First, when the version is given to the tester, the diff parser will perform diff analysis based on the baseline commitid and the newly submitted commitid to parse the changed methods. Then, based on the changed methods and results, the link parser will be called to filter the affected interface automation use case set for running. After the filtered interface automation use case set is completed, a code coverage report will be generated. Finally, additional testing will be performed based on the uncovered points, thereby reducing the interface automation running time and the scope that needs regression.
[0032] In practical applications, the operation logic of the interface automation use case generation method disclosed in the above embodiment can be written into a set of executable instructions, and the executable instructions are written into a storage medium and run on an electronic device. More specific examples of the computer-readable storage medium mentioned in this embodiment may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. The computer-readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, an apparatus, or a device.
[0033] In summary, the traditional interface automation use cases require testers to have coding skills and need to be manually written. This solution uses traffic recording and playback technology to automatically generate interface automation use cases, which does not require manual writing and reduces the cost of writing interface automation use cases. When the interface changes, traditional interface automation use cases require manual comparison and secondary modification based on interface documents or packet capture. The interface automation use cases of this solution will not be affected by interface changes, and the interface automation use cases will be automatically updated with version iterations, reducing the maintenance cost of interface automation use cases. Compared with the existing traffic playback technology, it has been upgraded and renovated, and does not require the development of a traffic playback platform, but is combined with the company's original interface automation framework. The generated interface automation use cases can be used to arrange scenarios; the traffic recording and playback are innovatively combined with the call chain, so that when automatically generating interface automation use cases, the data such as the dependency of parameters between interfaces can be automatically queried and then replaced, reducing the data dependency of generating interface automation use cases; at the same time, combined with the call chain technology, the generated automation use cases are not only for a single interface, but also support the generation of scenario automation use cases based on traceid; according to the parsed version changes, the interface automation use cases are incrementally generated to increase the efficiency of automatically generating interface automation use cases, and the effect of the automatically generated automation use cases can be checked based on the code coverage rate, so that the points not covered by the automatically generated interface automation use cases can be supplemented more quickly.
[0034] As described above, although the present invention has been shown and described with reference to specific preferred embodiments, it should not be construed as limiting the present invention itself. Various changes may be made to it in form and detail without departing from the spirit and scope of the present invention as defined in the appended claims.
Claims
1. A method for automatically generating an interface use case, characterized in that: The steps include: Collect the flow data of a predetermined period in the test environment and regard it as the rough flow data; Periodically aggregating the coarse flow data into a first data packet; Refining the rough flow data in the first data packet to obtain accurate flow data, and aggregating the accurate flow data of a predetermined scale into a second data packet; Performing use case splicing on the scattered data in the second data packet to generate an interface automation use case script; Apply the generated interface automation use case script to the formal environment to achieve automatic update of the program interface.
2. The interface automation use case generation method according to claim 1, characterized in that: In the process of generating interface automation use cases, the dependency on data in the interface automation use cases is dynamically replaced according to the call link.
3. The interface automation use case generation method according to claim 1, characterized in that: The rough flow data in the first data packet is processed in a refined manner, specifically including: Deploy coverage probes on the application under test; The coverage probe acquires the path taken by each flow; Analyze the mapping relationship between each flow, path, and code; The mapping relationship is used as a deduplication rule to remove the remaining duplicate traffic and obtain accurate traffic data.
4. The interface automation use case generation method according to claim 1, characterized in that: Also includes: Filter the changed program interfaces, only run the interface automation test cases of the changed interfaces, and perform additional tests based on the coverage.
5. The interface automation use case generation method according to claim 4, characterized in that: Filter the changed program interfaces, including: Perform diff analysis based on the baseline commitid and the newly submitted commitid to parse out the change rules; According to the parsed change rules, a set of affected interface automation use cases is screened out.
6. The method for automatically generating interface use cases according to claim 5, characterized in that: After filtering out the affected interface automation use case set, generate a code coverage report.
7. An interface automation use case generation device, characterized in that: include: Traffic collector, deployed in the test environment; The flow collector collects flow data of the current predetermined period and regards it as rough flow data; The traffic collector periodically aggregates the coarse traffic data into the first data packet and transmits it back to the data center server; Data center servers; The data center server performs fine processing on the coarse flow data in the first data packet to obtain precise flow data, and aggregates the precise flow data of a predetermined scale into a second data packet; Use case generator; The use case generator is used to receive the second data packet and perform use case splicing on its scattered data to generate an interface automation use case script; the generated interface automation use case script is applied to a formal environment to realize automatic update of the program interface.
8. The interface automation use case generation device according to claim 7, characterized in that: It also includes a diff parser; the diff parser is used to screen the changed program interfaces, only run the interface automation test cases of the changed interfaces, and perform supplementary tests according to the coverage rate; The diff parser performs diff parsing according to the baseline commitid and the newly submitted commitid to parse out the change rules; based on the parsed change rules, the affected interface automation use case set is screened out, and a code coverage report is generated.
9. An electronic device, characterized in that: The device comprises: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the method for automatically generating an interface use case according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium, characterized in that: The storage medium stores at least one executable instruction, and when the executable instruction is executed on the electronic device, the electronic device executes the interface automation use case generation method according to any one of claims 1 to 6.
