Test script generation method and device, equipment, storage medium and program product

By mounting a probe on the application to record traffic data and generating test scripts, the problem that manual writing of test scripts in the existing technology cannot respond to interface changes in real time, real-time response and reduced maintenance costs are achieved, and it is suitable for a fast iterative development environment.

CN120029909APending Publication Date: 2025-05-23SHANGHAI FAIRYLAND INFORMATION TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510048639.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-13
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

In the prior art, manual writing of test scripts cannot respond to application interface changes in real time, resulting in high maintenance costs for test scripts and difficult to adapt to a rapidly iterative application development environment.

Method used

By mounting a probe on the application, recording the traffic data sent by the application, and generating test scripts after the interface changes based on the recorded traffic data, real-time response to interface changes is achieved.

Benefits of technology

It realizes that without modifying the application code, the application traffic data is recorded and analyzed in real time, and the application traffic data is generated suitable for the interface changes is reduced, which reduces the maintenance cost of test scripts and is suitable for the application development environment that it is rapidly iterated.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029909A_ABST
    Figure CN120029909A_ABST
Patent Text Reader

Abstract

The invention provides a test script generation method and device, equipment, a storage medium and a program product, and belongs to the technical field of computers.The method comprises the steps that under the condition that an interface of an application package is changed, a probe mounted on an application program is used for recording flow data sent by the application program; the flow data is generated after the application program responds to the interface calling request; the interface calling request is sent by a user terminal or an upstream application program; and generating a test script after the interface is changed based on the flow data. According to the method, the probe is mounted on the application program, recording of all flow data sent by the application program can be achieved under the condition that application program codes are not modified, the changed interface information is mastered in real time by analyzing the flow data, the test script suitable for the application program package with the changed interface is generated, and the test efficiency is improved. The interface change can be responded in real time, the test script maintenance cost is reduced, and the method is suitable for a rapid iteration application program development environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a test script generation method, device, equipment, storage medium and program product. Background Art

[0002] Testing applications using test scripts is an important step in ensuring that application development meets expectations.

[0003] At present, the main method of generating test scripts is for testers to learn the business logic, interface design and interaction between data services of the application in advance, become familiar with the various parameters during interface communication, and then use the available test data collected in advance to manually write test scripts for the test application.

[0004] However, applications are updated and iterated quickly, and the internal interfaces and service logic of the applications will also change accordingly. Therefore, when testers manually write test scripts, it is easy for them to fail to respond to interface changes in real time, resulting in high maintenance costs for test scripts and difficulty in adapting to the rapidly iterating application development environment. Summary of the invention

[0005] The present invention provides a test script generation method, device, equipment, storage medium and program product, which are used to solve the defect that manually written test scripts in the prior art cannot respond to changes in application program interfaces in real time, achieve real-time response to interface changes and reduce test script maintenance costs, and are suitable for test script generation solutions in fast-iteration application development environments.

[0006] The present invention provides a test script generation method, comprising: In the case where the interface of the application package changes, the flow data sent by the application is recorded by using the probe mounted by the application; the flow data is generated after the application responds to the interface call request; the interface call request is sent by the user terminal or the upstream application; Based on the traffic data, a test script is generated after the interface changes.

[0007] According to a test script generation method provided by the present invention, the test script after the interface changes is generated based on the traffic data, comprising: Based on the traffic data, determine the remote call protocol and code penetration information of the test script; Based on the remote call protocol, determining the script generation logic corresponding to the test script from a script generation logic library; The test script is generated based on the script generation logic and the code penetration information.

[0008] According to a test script generation method provided by the present invention, before recording the traffic data sent by the application using the probe mounted by the application, the method further includes: In the case where the first hash value of the application package is not equal to the second hash value of the application package, confirming that the interface of the application package has changed; the first hash value is the hash value of the current version of the application package; the second hash value is the hash value of the previous version of the application package; When the application package is equal to the second hash value, it is confirmed that the interface of the application package has not changed.

[0009] According to a test script generation method provided by the present invention, when the interface of the application package changes, using a probe mounted by the application to record the traffic data sent by the application includes: In case the interface of the application package changes, receiving the interface call request; Parsing the interface call request to determine whether the interface call request includes a recording identifier; In a case where the interface call request includes the recording identifier, the flow data sent by the application to the downstream application is recorded using the probe mounted by the application.

[0010] According to a test script generation method provided by the present invention, the use of a probe mounted by the application to record traffic data sent by the application to a downstream application includes: The probe mounted by the application program marks a recording flag in a first thread based on the recording identifier, and executes the first thread to obtain an execution result; The execution result is written into the local disk, and the second thread synchronizes the execution result to the write interface for recording the traffic data, so as to realize recording the traffic data sent by the application to the downstream application.

[0011] According to a test script generation method provided by the present invention, when the interface call request is sent by the upstream application, the interface call request is sent by the upstream application based on the following steps: Using the probe mounted by the upstream application, adding a recording identifier to the initial call request generated by the upstream application to generate the interface call request; The interface calling request is sent to the application program so that the application program responds to the interface calling request.

[0012] The present invention also provides a test script generating device, comprising: A traffic recording module is used to record the traffic data sent by the application program by using a probe mounted by the application program when the interface of the application program package changes; the traffic data is generated after the application program responds to an interface call request; the interface call request is sent by a user terminal or an upstream application program; The script generation module is used to generate a test script after the interface changes based on the traffic data.

[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the computer program, any of the test script generation methods described above is implemented.

[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the test script generating method described in any one of the above is implemented.

[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the test script generating method described in any one of the above is implemented.

[0016] The test script generation method, apparatus, equipment, storage medium and program product provided by the present invention can record all traffic data sent by an application without modifying the application code by mounting a probe on the application, thereby realizing the recording of requests and code penetration; on this basis, it is possible to automatically analyze the traffic data recorded by the probe, and grasp the interface information of the application package after the change in real time, so as to generate a test script suitable for the application package after the interface changes according to the interface information grasped in real time, respond to the interface changes in real time, reduce the maintenance cost of the test script, and be suitable for a fast-iteration application development environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 This is one of the flow charts of the test script generation method provided by the present invention.

[0019] Figure 2 This is the second flow chart of the test script generation method provided by the present invention.

[0020] Figure 3 It is a structural schematic diagram of the test script generating device provided by the present invention.

[0021] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] It should be noted that, in the description of the present invention, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0024] The terms "first", "second", etc. in the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more.

[0025] Combine the following Figure 1-Figure 4 The present invention describes the test script generation method, device, equipment, storage medium and program product provided by the present invention.

[0026] Figure 1 This is one of the flow charts of the test script generation method provided by the present invention, such as Figure 1 As shown, the test script generating method includes but is not limited to steps 101 to 102.

[0027] It should be noted that the execution subject of the test script generation method provided by the present invention can be a server, a computer device, such as a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc.

[0028] Step 101: When the interface of the application package changes, the flow data sent by the application is recorded using a probe mounted on the application.

[0029] The traffic data is generated after the application program responds to an interface call request.

[0030] The interface call request is sent by a user terminal or an upstream application.

[0031] Among them, the application is deployed on the server side.

[0032] Traffic data refers to all network traffic data recorded in real time by the probe mounted on the application during the process of the application receiving requests, processing logic, and returning responses.

[0033] Recording is essentially recording the application's request content and response, as well as the code penetration during the request process.

[0034] Specifically, before the application responds to the interface call request to record traffic data, it is first determined whether the interface of the application package corresponding to the application has changed. If the interface of the application package has not changed, the probe will not be used to record the traffic data sent by the application. Specifically, the probe can be prevented from recording traffic data by not mounting the probe, not receiving the interface call request, or not responding to the interface call request.

[0035] When the interface of the application package changes, multiple applications deployed on the server side will respond to the interface call request sent by the user terminal or upstream application. Each application will mount a probe, and the probe mounted on each application will record the traffic data sent by the application after the application responds to the interface call request and generates traffic data. The traffic data recorded by the probe mounted on each application will be stored in the database on the server side to be retrieved when generating the test script.

[0036] For each application deployed on the server side, if there is an upstream application for the application, the interface call request to which the application responds is sent by the upstream application; if there is no upstream application for the application, the interface call request to which the application responds is sent by the user terminal.

[0037] Figure 2 This is the second flow chart of the test script generation method provided by the present invention. Figure 2 As shown, applications A, B, C, and D are all deployed on the server side of the test software, application A is the upstream application of application B, and application B is the common upstream application of application C and application D. When the interface of the application package changes, the tester sends an interface call request through the user terminal, such as sending an interface call request to the server side through an APP installed by the user terminal or a web page opened by the user terminal.

[0038] For application A, application A will receive and respond to the interface call request sent by the user terminal, generate traffic data and send the traffic data to the downstream application B. For application B, application B will receive and respond to the interface call request sent by the upstream application A, generate traffic data and send the traffic data to the downstream applications C and D.

[0039] Generally speaking, the traffic data generated and sent by applications A and B include interface call requests.

[0040] It should be noted that the time for the application to mount the probe can be determined according to the specific settings of the tester, and the present invention does not limit this.

[0041] For example, after confirming that the interface of the application package has changed, the startup parameters of the probe are added to each application to mount the probe on each application. For another example, after the application receives the interface call request sent by the user terminal, the startup parameters of the probe are added to each application to mount the probe on each application. For another example, after the application responds to the interface call request sent by the user terminal, the startup parameters of the probe are added to each application to mount the probe on each application.

[0042] Optionally, the probe is implemented by a Java program agent developed based on Java Agent technology.

[0043] Step 102: Based on the traffic data, generate a test script after the interface changes.

[0044] Specifically, the flow data recorded by the probe is retrieved from the database, and the flow data is analyzed using data analysis technologies such as code penetration technology. After the interface of the application package changes, key information such as the execution path between the various applications within the application package, key variable information, and code penetration information can be obtained. This information can also be formatted to obtain data suitable for generating test scripts. The data suitable for generating test scripts includes request details such as URL (Uniform Resource Locato) path, request method, request header information, and request body, as well as response details such as status code, response header information, and response body.

[0045] By using data suitable for generating test scripts and combining it with certain script generation logic, you can automatically generate test scripts that are suitable for application packages after the interface changes, and include key steps such as request construction, parameter passing, and response processing.

[0046] It should be noted that the essence of test script generation is a sophisticated process of deep mining and conversion of recorded information. The core is that the detailed interactive traffic data between applications captured by the probe can be used to extract key information for generating test scripts. The probe mounted on the application can be used to obtain the traffic data of the application responding to the interface call request after the interface changes. After that, the traffic data can be analyzed by various analysis methods to obtain data suitable for generating test scripts. The data suitable for generating test scripts can also be processed in various ways to obtain the test script after the interface changes. In this regard, the present invention does not limit the specific methods of analyzing traffic data and generating test scripts.

[0047] In one embodiment, the key information obtained by analyzing the traffic data includes but is not limited to at least one of the following information: URL path, request method of interface call request (such as GET method, POST method, etc.), parameter details attached to the interface call request, data format of interface response, specific content of interface response, identification information used to unify the intrinsic connection between each request and response between various applications (such as session identifier sessionID, authentication token, specific status code in business logic, etc.), variable data that may change in different test scenarios or iterations (such as user input, timestamp, randomly generated test data, etc.), etc.

[0048] Optionally, variable data that may change in different test scenarios or iterations can be encapsulated as assembler parameters. Through parameterized design, the script can be made highly flexible and scalable to cope with changes in various test requirements.

[0049] In one embodiment, for traffic data obtained after recording multiple applications in the server side caused by an interface call request sent by a user terminal, the same identification field value is added to the traffic data when storing the traffic data in the database, so as to generate a test script corresponding to the interface call request using the traffic data with the same identification field value.

[0050] For example, combined with Figure 2 As shown, after application A responds to the interface call request a sent by the user terminal, the probes mounted by application A, application B, application C and application D will each record traffic data once. When the traffic data recorded by the four applications is stored in the database, the same identification field value will be added to generate a test script corresponding to the interface call request a using the traffic data with the same identification field value.

[0051] In one embodiment, before the application responds to the interface call request sent by the user terminal, it is determined whether the request path of the interface call request sent by the user terminal exists in the recording path list. If so, the probe mounted by the application is used to record the traffic data sent by the application.

[0052] The test script generation method provided by the present invention can record all traffic data sent by an application without modifying the application code, thereby realizing the recording of requests and code penetration, by mounting a probe on the application. On this basis, it can automatically analyze the traffic data recorded by the probe, and grasp the interface information of the application package after the change in real time, so as to generate a test script suitable for the application package after the interface change according to the interface information grasped in real time, respond to the interface change in real time, reduce the maintenance cost of the test script, and be suitable for a fast-iteration application development environment.

[0053] Based on the above embodiment, as an optional embodiment, generating a test script after the interface changes based on the traffic data includes: Based on the traffic data, determine the remote call protocol and code penetration information of the test script; Based on the remote call protocol, determining the script generation logic corresponding to the test script from a script generation logic library; The test script is generated based on the script generation logic and the code penetration information.

[0054] The remote call protocol determined based on the traffic data includes but is not limited to any one of the Hypertext Transfer Protocol (HTTP) and the Dubbo protocol.

[0055] The script generation logic library stores script generation logic corresponding to a variety of mainstream remote call protocols.

[0056] Specifically, by analyzing the traffic data recorded by the probe stored in the database, the remote call protocol used by the application and the relationship between the interface and code between the applications are determined, and then the remote call protocol and code penetration information of the generated test script are determined. Further, from the script generation logic library pre-built according to multiple mainstream remote call protocols, the script generation logic corresponding to the remote call protocol required by the test script is determined, and the test script is generated in combination with the script generation logic and code penetration information.

[0057] The test script generation method provided by the present invention supports multiple mainstream remote call protocols, provides special script generation logic for different remote call protocols in advance, and combines the script generation logic and code penetration information to ensure the automatic generation of interface test scripts with clear structure, easy to understand and complete key steps including request construction, parameter passing, response processing, etc., which can ensure that the finally generated test script complies with both protocol specifications and actual traffic conditions, thereby improving the user experience of testers in automatically generating test scripts.

[0058] Based on the above embodiment, as an optional embodiment, before the probe mounted by the application program records the traffic data sent by the application program, the method further includes: In the case where the first hash value of the application package is not equal to the second hash value of the application package, confirming that the interface of the application package has changed; the first hash value is the hash value of the current version of the application package; the second hash value is the hash value of the previous version of the application package; When the application package is equal to the second hash value, it is confirmed that the interface of the application package has not changed.

[0059] Before using the probe mounted by the application to record the traffic data sent by the application, first determine whether the interface of the application package has changed. If the interface of the application package has not changed, regardless of whether the application deployed on the server receives the interface call request, the probe mounted by the application will not record the traffic data of the application responding to the interface call request. Only when the interface of the application package has changed, the probe mounted by the application will be used to record the traffic data sent by the application.

[0060] Specifically, when determining whether the interface of the application package has changed, first calculate the first hash value according to the current version of the application package, calculate the second hash value according to the previous version of the application package, and determine whether the first hash value is equal to the second hash value. If the first hash value is not equal to the second hash value, it is confirmed that the interface of the application package has changed; if the first hash value is equal to the second hash value, it is confirmed that the interface of the application package has not changed.

[0061] The first hash value and the second hash value are obtained according to the same hash value calculation method. For example, the first hash value is the MD5 value of the current version of the application package, and the second hash value is the MD5 value of the previous version of the application package.

[0062] Optionally, after confirming that the interface of the application package has changed, the user is prompted on the business interface to re-record and generate the corresponding interface automation test script to ensure that the test script can adapt to the interface changes in real time, thereby keeping the test case consistent with the latest status of the interface.

[0063] Optionally, after determining that the interface of the application package has changed based on the current version and the previous version of the application package and generating a new test script, the new test script replaces the old test script. The old test script refers to the test script generated when determining that the interface of the application package has changed based on the previous version and the previous previous version of the application package.

[0064] The test script generation method provided by the present invention can quickly determine whether the interface of the application package has changed by calculating the hash value of the current version and the previous version of the application package, and then quickly prompt the user to generate a test script when the interface changes, ensuring that the test script can adapt to the interface changes between applications in real time, and is suitable for a fast-iteration application development environment.

[0065] Based on the above embodiment, as an optional embodiment, when the interface of the application package changes, using the probe mounted by the application to record the traffic data sent by the application includes: In case the interface of the application package changes, receiving the interface call request; Parsing the interface call request to determine whether the interface call request includes a recording identifier; In a case where the interface call request includes the recording identifier, the flow data sent by the application to the downstream application is recorded using the probe mounted by the application.

[0066] The recording identifier is a field in the interface call request used to implement the probe mounted by the instructing application to record the traffic data sent by the application when an interface call is involved.

[0067] Specifically, when the interface of the application package changes, after receiving the interface call request, the application parses the interface call request to determine whether the interface call request includes a recording identifier. If the interface call request does not include a recording identifier, the probe mounted by the application does not record the traffic data generated and sent after the application responds to the interface call request.

[0068] Only when the interface call request includes a recording identifier, the probe mounted by the application is used to mark the recording mark bit in the thread context of the application's response to the interface call request, so that the application's traffic data including the requested network interaction data and code penetration information are recorded.

[0069] Optionally, in the case where the interface call request is sent by a user terminal, the recording identifier is a URL path in the interface call request that is the same as any recording path in the preset recording path list; Figure 2 As shown, in the case where the interface call request is sent by an upstream application, the recording identifier is a preset specific character traceID added by the upstream application in the interface call request.

[0070] The test script generation method provided by the present invention can accurately collect the traffic data of applications involving interface changes and grasp the interface information after the application package changes in real time by parsing the interface call request after receiving it and recording the traffic data based on the judgment result of whether the interface call request includes a recording identifier.

[0071] Based on the above embodiment, as an optional embodiment, the using the probe mounted by the application to record the traffic data sent by the application to the downstream application includes: The probe mounted by the application program marks a recording flag in a first thread based on the recording identifier, and executes the first thread to obtain an execution result; The execution result is written into the local disk, and the second thread synchronizes the execution result to the write interface for recording the traffic data, so as to realize recording the traffic data sent by the application to the downstream application.

[0072] Specifically, when the interface call request includes a recording identifier, the probe mounted by the application marks the recording flag in the first thread of the application's response to the interface call request according to the recording identifier, obtains the execution result after executing the first thread, writes the execution result to the local disk, and the second thread that synchronizes the execution result synchronizes the execution result to the write interface of the recording traffic data, so as to ultimately realize the recording of the traffic data sent by the application to the downstream application by the probe.

[0073] The test script generation method provided by the present invention utilizes two different threads to implement the application program responding to the interface call request to obtain the execution result, and synchronizes the execution result to the write interface of the traffic data recording. It can manage the traffic data recording more flexibly and avoid the traffic data recording affecting the speed of the application program responding to the interface call request.

[0074] Based on the above embodiment, as an optional embodiment, in the case where the interface call request is sent by the upstream application, the interface call request is sent by the upstream application based on the following steps: Using the probe mounted by the upstream application, adding a recording identifier to the initial call request generated by the upstream application to generate the interface call request; The interface calling request is sent to the application program so that the application program responds to the interface calling request.

[0075] Specifically, when the interface call request is sent by an upstream application, the probe mounted by the upstream application, in addition to recording the traffic data sent by the upstream application, also adds a recording identifier to the initial call request in the traffic data generated by the upstream application (such as adding a mark bit based on preset recording rules in the message header of the initial call request), and obtains the interface call request with the recording identifier added. The traffic data containing the interface call request is sent by the upstream application to the downstream application, so that after the downstream application responds to the interface call request, the mounted probe records the traffic data sent after the response request.

[0076] Optionally, when the traffic data sent by the upstream application includes messages of multiple initial call requests for calling an interface, the probe mounted by the upstream application adds the same recording identifier to each initial call request to obtain corresponding multiple interface call requests, so that after the downstream application responds to the multiple interface call requests, the probe mounted by the downstream application can record the traffic data after responding to each interface call request.

[0077] Optionally, after responding to an interface call request sent by a user terminal, subsequent interface call requests in traffic data sent by the application to downstream applications caused by responding to the same interface call request sent by the user terminal are all added with the same recording identifier.

[0078] Optionally, when the probe mounted by the application stores the recorded traffic data in the database, it determines the identification field value when storing the traffic data according to the recording identifier in the interface call request in response to the generation of the traffic data. When the recording identifiers are the same, the identification field value is also the same. When generating a test script, the traffic data with the identification field value is extracted from the database, and a test script is generated using the traffic data with the identification field value.

[0079] For example, combined with Figure 2 As shown, after application A responds to the interface call request sent by the user terminal, the interface call request sent by application A to application B, the interface call request sent by application B to application C, and the interface call request sent by application B to application D contain the same recording identifier traceID, and the flow data recorded by the probes of application A, application B, application C, and application D are all set with the same identification field value α when stored in the database. When generating a test script, the flow data with the identification field value α is extracted from the database, and multiple test scripts suitable for testing application A, application B, application C, and application D are generated. When the key information such as the execution path, key variable information, and code penetration information between each application can be analyzed through the flow data, the generated test script can be applied to each application after the interface changes.

[0080] The test script generation method provided by the present invention can ensure the consistency of the traffic data recorded by the probe by adding the same recording identifier in the interface call request sent by the upstream application to the downstream application, so as to ensure that the finally generated test script is suitable for each application.

[0081] In order to better illustrate the test script generating method provided by the present invention, an embodiment is provided below to fully illustrate the test script generating method provided by the present invention.

[0082] Combination Figure 2 As shown, when the hash values ​​of the current version and the previous version of the application package are different and it is determined that the interface of the application package has changed, application A receives an interface call request sent by the user terminal to the server for generating a test script. Application A parses the interface call request and determines that the interface call request includes a recording marker.

[0083] Application A generates and sends traffic data to application B in response to an interface call request. At the same time, under the control of the data collection engine, the traffic data is recorded using the probe mounted by application A, and the recorded traffic data and the corresponding identification field value are stored in the database. At the same time, the probe is used to add a recording identifier traceID to the initial call request of the traffic data to obtain the traffic data including the interface call request.

[0084] Application B receives the traffic data including the interface call request, and marks the recording mark bit in the thread according to the recording identifier, so that the probe mounted by application B records the traffic data generated and sent by application B in response to the interface call request under the control of the data collection engine, and stores it in the database, setting the same identification field value as the traffic data recorded by the probe mounted by application A. At the same time, the same recording identifier traceID is added to the traffic data by the probe to obtain the traffic data sent to application C and application D. And so on. When the traffic data recorded by the probes mounted by application C and application D are stored in the database, the same identification field value will be set.

[0085] After recording the traffic data caused by the interface call request sent by the same user terminal, the traffic data with the same identification field value can be extracted from the database, and the traffic data can be analyzed using the interface and code relationship analysis engine to obtain key information including but not limited to remote call protocol, code penetration information, etc. The script generation engine determines the script generation logic according to the remote call protocol, and combines the script generation logic and code penetration information to generate a test script suitable for after the interface changes.

[0086] Finally, the test scripts generated for changes in interfaces of different versions of the application package can be stored in the database for quick call during software testing; the test scripts can also be automatically executed after a preset period of time when the test scripts are generated.

[0087] Figure 3 is a schematic diagram of the structure of the test script generating device provided by the present invention, such as Figure 3 As shown, the test script generating device includes but is not limited to a traffic recording module 301 and a script generating module 302 .

[0088] The traffic recording module 301 is used to record the traffic data sent by the application using the probe mounted on the application when the interface of the application package changes; the traffic data is generated after the application responds to the interface call request; the interface call request is sent by the user terminal or the upstream application.

[0089] The script generation module 302 is used to generate a test script after the interface changes based on the traffic data.

[0090] It should be noted that the test script generating device provided by the present invention can execute the test script generating method described in any of the above embodiments when it is specifically run, which will not be elaborated in this embodiment.

[0091] The test script generating device provided by the present invention can record all the traffic data sent by the application without modifying the application code by mounting a probe on the application, thereby realizing the recording of requests and code penetration; on this basis, it can automatically analyze the traffic data recorded by the probe, grasp the interface information after the application package changes in real time, and generate a test script suitable for the application package after the interface changes according to the interface information grasped in real time, respond to the interface changes in real time, reduce the maintenance cost of the test script, and is suitable for a fast-iteration application development environment.

[0092] Figure 4 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 4 As shown, the electronic device may include: a processor (Processor) 410, a communication interface (Communications Interface) 420, a memory (Memory) 430 and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the test script generation method provided in any of the above embodiments, and the test script generation method includes but is not limited to the following steps: when the interface of the application package changes, using the probe mounted by the application to record the traffic data sent by the application; the traffic data is generated after the application responds to the interface call request; the interface call request is sent by the user terminal or the upstream application; based on the traffic data, generate a test script after the interface changes.

[0093] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.

[0094] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the test script generation method provided in any of the above embodiments, and the test script generation method includes but is not limited to the following steps: when the interface of the application package changes, using a probe mounted on the application to record the traffic data sent by the application; the traffic data is generated after the application responds to an interface call request; the interface call request is sent by a user terminal or an upstream application; based on the traffic data, generate a test script after the interface changes.

[0095] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the test script generation method provided in any of the above embodiments is implemented. The test script generation method includes but is not limited to the following steps: when the interface of the application package changes, using a probe mounted on the application to record the traffic data sent by the application; the traffic data is generated after the application responds to an interface call request; the interface call request is sent by a user terminal or an upstream application; based on the traffic data, a test script is generated after the interface changes.

[0096] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0097] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0098] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A test script generation method, characterized in that: include: In the case where the interface of the application package changes, the flow data sent by the application is recorded using the probe mounted by the application; The traffic data is generated after the application program responds to an interface call request; The interface call request is sent by a user terminal or an upstream application; Based on the traffic data, a test script is generated after the interface changes.

2. The test script generation method according to claim 1, characterized in that: The generating, based on the traffic data, a test script after the interface changes, comprises: Based on the traffic data, determine the remote call protocol and code penetration information of the test script; Based on the remote call protocol, determining the script generation logic corresponding to the test script from a script generation logic library; The test script is generated based on the script generation logic and the code penetration information.

3. The test script generation method according to claim 1, characterized in that: Before the probe mounted by the application program records the traffic data sent by the application program, the method further includes: In the case where the first hash value of the application package is not equal to the second hash value of the application package, confirming that the interface of the application package has changed; the first hash value is the hash value of the current version of the application package; the second hash value is the hash value of the previous version of the application package; When the application package is equal to the second hash value, it is confirmed that the interface of the application package has not changed.

4. The test script generation method according to claim 1, characterized in that: When the interface of the application package changes, using the probe mounted by the application to record the traffic data sent by the application includes: In case the interface of the application package changes, receiving the interface call request; Parsing the interface call request to determine whether the interface call request includes a recording identifier; In a case where the interface call request includes the recording identifier, the flow data sent by the application to the downstream application is recorded using the probe mounted by the application.

5. The test script generation method according to claim 4, characterized in that: The use of the probe mounted by the application to record the traffic data sent by the application to the downstream application includes: The probe mounted by the application program marks a recording flag in a first thread based on the recording identifier, and executes the first thread to obtain an execution result; The execution result is written into the local disk, and the second thread synchronizes the execution result to the write interface for recording the traffic data, so as to realize recording the traffic data sent by the application to the downstream application.

6. The test script generation method according to claim 1, characterized in that: In the case where the interface call request is sent by the upstream application, the interface call request is sent by the upstream application based on the following steps: Using the probe mounted by the upstream application, adding a recording identifier to the initial call request generated by the upstream application to generate the interface call request; The interface calling request is sent to the application program so that the application program responds to the interface calling request.

7. A test script generating device, characterized in that: include: A traffic recording module, used to record the traffic data sent by the application using a probe mounted by the application when the interface of the application package changes; The traffic data is generated after the application program responds to an interface call request; The interface call request is sent by a user terminal or an upstream application; The script generation module is used to generate a test script after the interface changes based on the traffic data.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the test script generating method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the test script generating method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the test script generating method according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Automatic test script generation method and system based on browser recording

    CN122387863A