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

By parsing interface request messages and generating test scripts according to customized instructions, the problem of existing interface performance test scripts relying on manual processing is solved, and efficient and low-cost test script generation is achieved, which is suitable for agile development environments.

CN119473901APending Publication Date: 2025-02-18KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411613626.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The writing of existing interface performance test scripts relies on manual labor, has high learning costs, and is inefficient in agile development environments, which limits the application of AI technology in the field of interface testing.

Method used

By parsing the interface request message, the first type parameter and the second type parameter are extracted, and the parameter values ​​of the second type parameter are replaced according to the custom instructions to generate a test script that meets the customization needs.

Benefits of technology

Reduces dependence on testers' technical level, reduces introductory and learning costs, improves test script writing efficiency, and is suitable for rapid iteration and frequent testing in agile development environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473901A_ABST
    Figure CN119473901A_ABST
Patent Text Reader

Abstract

The invention provides a test script generation method, electronic equipment, a readable storage medium and a computer program product. The test script generation method comprises the steps that a request message about an interface is analyzed into a plurality of first type parameters and a plurality of second type parameters, the interface is used for defining an interaction rule between a requesting party and a requested party, the first type parameters represent the interaction rule, and the second type parameters represent attribute information of the requesting party; the parameter value of the second type parameter indicated by the customization instruction is replaced with a customization interval in the customization instruction, a customization parameter is obtained, the customization instruction comprises a parameter identifier with a customization requirement and the customization interval, and the customization interval represents a parameter value change range which can be supported by the interface and is related to the corresponding second type parameter; and according to the customization interval of the customization parameters, configuring the plurality of first type parameters, the second type parameters and the customization parameters to a script template, and generating a test script meeting the customization instruction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to technical fields such as performance testing, and more particularly to a test script generation method, electronic equipment, storage medium, and program product. Background Art

[0002] In the software development process, interface testing is a very important part. It ensures that different components can communicate correctly, helps testers find and fix problems in a timely manner, and ensures the quality and stability of the software. At present, the writing of interface performance test scripts relies on manual work. Even if AI (Artificial Intelligence) can provide guidance for script writing, testers still need to have relevant knowledge of the stress testing tool JMeter, which has a certain entry difficulty. Summary of the invention

[0003] In order to solve at least one of the above technical problems, the present disclosure provides a test script generation method, an electronic device, a storage medium and a program product.

[0004] According to one aspect of the present disclosure, a test script generation method is provided, comprising: parsing a request message about an interface into multiple first-type parameters and multiple second-type parameters, the interface being used to define interaction rules between a requester and a requested party, the first-type parameters representing the interaction rules, and the second-type parameters representing attribute information of the requester; replacing a parameter value of a second-type parameter indicated by a custom instruction with a custom interval in the custom instruction to obtain a custom parameter, the custom instruction comprising a parameter identifier with a custom requirement and a custom interval, the custom interval representing a parameter value variation range of the corresponding second-type parameter that the interface can support; and configuring the multiple first-type parameters, the second-type parameters and the custom parameters to a script template according to the custom interval of the custom parameter to generate a test script that satisfies the custom instruction.

[0005] In some implementations, the plurality of second type parameters are stored in a key-value pair format or a string format, and the second type parameters include a parameter identifier and a parameter value.

[0006] In some embodiments, the parameter value of the second type parameter indicated by the custom instruction is replaced with the custom interval in the custom instruction to obtain the custom parameter, including: identifying the parameter identifier and the corresponding custom interval specified by the custom instruction regarding the second type parameter; and locating the second type parameter with the parameter identifier among the multiple second type parameters, and replacing the parameter value of the second type parameter with the parameter identifier with the custom interval in the custom instruction to obtain the custom parameter.

[0007] In some embodiments, after replacing the parameter value of the second type parameter having the parameter identifier with the custom interval in the custom instruction, it includes: obtaining a process text containing the parameter identifier and its custom interval; and using a regular expression to extract the parameter identifier and its custom interval from the process text, and converting the parameter identifier and its custom interval into a key-value pair format or a string format to obtain the custom parameter.

[0008] In some embodiments, according to the customization interval of the customization parameter, the multiple first type parameters, the second type parameters, and the customization parameters are configured to a script template to generate a test script that satisfies the customization instruction, including: selecting a target parameter value in the customization interval of the customization parameter, writing the multiple first type parameters, the second type parameters, and the customization parameters with the target parameter value as the parameter value into the script template, obtaining a request action script, and generating a test script including the request action script.

[0009] In some implementations, before parsing a request message about an interface into a plurality of first type parameters and a plurality of second type parameters, it includes: monitoring a request action for the interface, and obtaining a request message about the request action.

[0010] In some implementations, before replacing the parameter value of the second type parameter having the parameter identifier with the custom interval in the custom instruction, the method further includes: obtaining a custom instruction in a natural language form, wherein the custom instruction includes a test environment.

[0011] In some implementations, the method further includes: calling a first script engine to write an environment recording script, and generating a test script including the environment recording script, wherein the environment recording script is used to record a test environment for the interface.

[0012] In some implementations, before replacing the parameter value of the second type parameter having the parameter identifier with the customized interval in the customized instruction, the method further includes: obtaining a customized instruction in a natural language form, wherein the customized instruction includes a signature verification condition.

[0013] In some implementations, it also includes: calling a first script engine to write a verification script based on the access code and access key in the signature verification condition, generating a test script including the verification script, and the verification script is used to verify whether the requesting party has the authority to call the interface.

[0014] According to one aspect of the present disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, so that the processor executes the test script generation method of any one of the above-mentioned embodiments.

[0015] According to one aspect of the present disclosure, a readable storage medium is provided, in which execution instructions are stored. When the execution instructions are executed by a processor, the test script generation method of any of the above-mentioned embodiments is implemented.

[0016] According to one aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the test script generating method of any of the above embodiments is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0018] Figure 1 It is a schematic diagram of an application scenario of the test script generation method according to an embodiment of the present disclosure.

[0019] Figure 2 It is an interactive schematic flowchart of a test script generation method according to an embodiment of the present disclosure.

[0020] Figure 3 It is an architecture diagram of a test script generation method according to an embodiment of the present disclosure.

[0021] Figure 4 It is a flow chart of a test script generation method according to an embodiment of the present disclosure.

[0022] Figure 5 It is a schematic block diagram of the structure of a test script generating device according to an embodiment of the present invention.

[0023] Figure 6 The present invention is a block diagram showing a structure of an electronic device equipped with a test script generating device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The present disclosure is further described in detail below in conjunction with the accompanying drawings and examples. It is understood that the specific examples described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.

[0025] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0026] Interfaces are important channels for communication and data interaction between users and applications. When an application is launched, a new function is developed, or a function is upgraded, interface testing should be performed to determine whether the interface can adapt to the high load and high frequency of calls brought about by the update, so as to ensure the stability and reliability of the interaction. At present, the writing of test scripts for interface performance is mainly undertaken by testers. Even though the functions of AI (Artificial Intelligence) are becoming increasingly powerful, they are only used to provide guidance and suggestions to testers when writing test scripts, and cannot replace the manual writing of test scripts in the form of jmx (JMeter Test Plan) required by performance testing tools such as JMeter. Traditional manual script writing will result in high learning costs and low work efficiency, especially in an agile development environment that requires rapid iteration and frequent testing. The inefficiency of this script writing method is particularly prominent, and it also limits the convenience and utility of AI technology in the field of interface testing.

[0027] To this end, the present disclosure proposes a test script generation method.

[0028] Figure 1 Schematic diagram of an application scenario of a test script generation method according to an embodiment of the present disclosure. Figure 1 The application scenario shown may include a terminal 100 used by a tester and a server 200 running a test script generation method. The tester can call the interface to be tested through the terminal 100 to show the actual call scenario of the interface. The server captures the request message generated by the call action of the tester, and parses these messages to obtain multiple first type parameters and multiple second type parameters about the interface. Then, the server 200 sends a customization requirement inquiry to the terminal 100 to ask the tester whether to determine the test scenario, whether signature verification is required, whether the parameter values ​​of several second type parameters need to be replaced, etc. The tester can answer these questions in natural language and feedback the customization instructions containing the customization requirements to the server 200 through the terminal 100. The server 200 generates a test script in the form of, for example, jmx according to these customization instructions, so that the test tools such as JMeter can simulate the call process of the interface according to the test script. By executing multiple test scripts simultaneously and repeatedly, the performance results of the interface in a high-load and high-frequency simulation environment are obtained.

[0029] It should be noted that the terminal 100 can be a device such as a computer, a tablet or a mobile phone that can call an interface and can edit custom instructions, and the specific form is not limited here. The server 200 can be a cloud server or a physical server. The server 200 communicates with the terminal 100 through Bluetooth, the network, etc. to obtain the tester's request message and the custom instructions in natural language. The test script generation method proposed in the present disclosure captures the request message of the actual call process of the interface, obtains the request parameters required to call the interface in the real interface call scenario, and integrates the custom instructions that meet the test requirements to generate a test script for the corresponding interface. In this process, the technical dependence on the tester is overcome. The tester only needs to perform low-tech actions to call the interface and answer custom inquiries in natural language, which reduces the entry and learning costs; and it has a high writing efficiency and is suitable for agile development scenarios with fast iterations and frequent testing.

[0030] Figure 2 It is an interactive schematic flowchart of a test script generation method according to an embodiment of the present disclosure. Figure 2 Through steps S201 to S211, Figure 1 The interactive process between the terminal 100, the server 200 and the interface is demonstrated, and the process of the server 200 executing the script generation method is shown. Among them, the server 200 is equipped with a test script generation device that can execute the test script generation method. The test script generation device is essentially an AI model that can execute the aforementioned method and has the ability to communicate with the tester in natural language.

[0031] In step S201, the tester executes an action of calling an interface through a terminal to call an interface to be tested.

[0032] The interface is the calling channel of the client to the application, and defines the interaction rules between the client and the application. The interaction rules include the protocol, request method, request path, and request parameters, request header, and the fixed part of the request body. When calling the interface through the terminal, a request message will be generated along with the calling action. The request message contains the parameters involved in completing the call in the real interface calling scenario. These parameters can characterize the interaction rules and the personalized attribute information of the requester.

[0033] Testers can send requests to obtain certain services in the application through the client of the test system. When sending the request, the corresponding interface is called. Testers can send HTTP (HyperText Transfer Protocol) requests to the application through command tools such as curl (Client URL) to complete the call to the interface. The tester's call action on the interface is the same as the user's call action on the application after the application is put into production. Therefore, the request parameters required to execute the call action can be used as the data basis for generating the test script, ensuring the effectiveness and practicality of simulating the call action by relying on the test script.

[0034] In step S202, the server monitors the calling action and captures the request message generated by the calling action. The request message is usually in HTTP format and includes the domain name, protocol, request method, request path, request parameters, request header and request body.

[0035] In step S203, the server parses the request message to obtain a first type parameter and a second type parameter.

[0036] The request message can be parsed into multiple first-type parameters and multiple second-type parameters. The first-type parameters represent the interaction rules between the requester and the requested party defined by the interface. When calling the same interface, the parameters are usually fixed; for example, when calling the interface, GET (get specified page information) is used as the request method. In this scenario, the requester is the user's client, and the requested party is a new function, function upgrade, or newly launched application. The second-type parameters represent the attribute information of the requester, which changes with the change of the requester, such as the specific content requested by the requester in the request body, the client information in the request header, etc.

[0037] The request message is usually presented in the form of HTTP, which contains a lot of content that is irrelevant to the test script and is not conducive to the replacement of parameter values ​​in the customization process. Therefore, the information in the request message that is inseparable from the generation of the test script is extracted through parsing, including the domain name, protocol, request method, request path, request parameters, request header and request body, and stored in a specified form.

[0038] For example, information such as request parameters, "x-www-form-erlencoded" and "from-data" in the request body are converted into the form of key-value pairs "key=value"; "x-www-form-erlencoded" and "from-data" are usually the formats used to send form data in HTTP requests. For example, "Authorization":"LJ-HMAC-SHA256accessKeyId=XXXonce=1bd4c605-e6ac-4e82-99c0-181cb730e4b1;timestamp=1718332600;signature=5d6XbQ8xT68N9yDQ0d+5VejjQOo82z / Lqf4psm DPrsA=", where the authentication information Authorization is a request header, including three key-value pairs: accessKeyId (access key) and its value, timestamp (timestamp) and its value, signature (signature) and its value. It can be seen that the "key" and "value" are connected by "=". When there is a subsequent customization requirement, the "value" corresponding to the corresponding key can be directly replaced with the customized value, which improves the convenience and accuracy of customization.

[0039] Of course, for other forms of parameters in the request message, you can convert them into JSON format, and then convert the parameters in JSON format into string format. The string format, for example, "request_type":"GET", indicates that the request method request_type is GET.

[0040] In step S204, the server inquires the terminal about customization requirements.

[0041] Custom requirements may include "whether to determine the test scenario", "whether signature verification is required", "whether the parameter values ​​of several second-type parameters need to be replaced", etc. Test scenarios include offline scenarios or online scenarios. If statistical test scenarios are required, the inquiry can be answered based on the actual test situation. Signature verification refers to the process of verifying requests or data through digital signature technology in the identity and access management system (IAM), and verifying the legitimacy of the signature through public key encryption technology to determine whether the request or data has been tampered with and ensure the access security of the application; it can be selected according to the security level of the interface. If there is a signature verification requirement, signature verification conditions such as access code and access key are provided. If there is a requirement to replace the parameter value of the second-type parameter, the parameter identifier of the second-type parameter that needs to be replaced, such as the name or code, is given, and the customized interval that needs to be replaced is also given. The range of the customized interval is set according to the actual situation and is not restricted.

[0042] In step S205, the terminal returns a customization instruction according to the actual customization requirements. The customization instruction may include one or more of the test scenario, signature verification condition, parameter identifier to be replaced and its customization interval. Of course, if there is no customization requirement, a null value may also be returned.

[0043] Customized instructions can be in natural language form, such as "the test scenario is offline". The test script generation device installed in the server has the ability to extract key parameters from customized instructions, which greatly reduces the learning and entry costs of testers.

[0044] In step S206, the server replaces the parameter value of the corresponding second type parameter according to the parameter identifier and the customization interval in the customization instruction.

[0045] In this process, the server finds the second type parameter with the parameter identifier in multiple second type parameters according to the parameter identifier given by the custom instruction, and replaces its parameter value with the custom interval. The custom interval is the parameter value variation range of the corresponding second type parameter that the interface can support, which provides a selection range for the subsequent generation of test scripts and ensures that each test script can simulate the call requests of different visitors. For example, when the tester calls the interface, the timestamp is 202409061330; however, since the time when each user calls the interface is different, a relatively broad custom interval can be set, such as "200001010000-203012122459", and then use this custom interval to replace the original "202409061330", so that the timestamp in the generated test script can be any value in "200001010000-203012122459", which simulates the real scene of different users calling the interface at different times, making the test results more credible and authentic. The remaining parameters associated with the attribute information of the visitor can be set to corresponding customized intervals. The span of the interval can be set according to actual conditions and will not be listed here one by one.

[0046] In step S207, the server randomly selects a target parameter value in the custom interval and generates a request action script using a script template.

[0047] The script template is a template provided in advance to the test script generation device in the server, which contains various first-type parameters and second-type parameters parsed from the request message. The request action script can be obtained by filling the values ​​of these first-type parameters and second-type parameters into the corresponding positions in the template. The request action script can be a jmx file, which can be recognized and executed by the JMeter test tool and is a program used to simulate the call action.

[0048] In step S208, the server calls the first script engine to write an environment recording script. The first script engine has the ability to write scripts according to the provided information. The environment recording script is used to instruct JMeter to record the test environment, such as online or offline, to count the preferred environment of the test.

[0049] In step S209, the server calls the first script engine to write a verification script. The custom instruction contains a verification condition, and the first script engine writes a verification script according to the verification condition. JMeter determines whether the visitor's identity is legal and whether the requester has the authority to call the interface based on the verification condition, thereby ensuring the security of the application.

[0050] Both the environment record script and the verification script can be jmx files.

[0051] In step S210, the server generates a test script according to the request action script, the environment record script and the verification script. Of course, the sub-scripts in the test script are not limited to the aforementioned three types, and can also be other scripts, which are not limited here.

[0052] In step S211, the server generates multiple test scripts and controls JMeter to execute these test scripts simultaneously and at a high frequency to obtain interface performance results.

[0053] The above-mentioned technical solution only requires the tester to send an access request to the application on the client side through low-tech actions and express customized instructions in natural language format. This technical solution captures the request message of the actual call process of the interface, obtains the request parameters required to call the interface in the real interface call scenario, and integrates the customized instructions that meet the test requirements to generate a test script for the corresponding interface. In this process, the technical dependence on the tester is overcome. The tester only needs to show the action of calling the interface and answer the customized inquiry in natural language, which reduces the entry and learning costs; and it has high writing efficiency and is suitable for agile development scenarios with fast iteration and frequent testing.

[0054] Figure 3 is a test script generation method architecture diagram according to an embodiment of the present disclosure, Figure 4 Flowchart of the test script generation method according to the embodiment of the present disclosure. In order to implement the above scheme, the present disclosure proposes a test script generation method M400. Figure 3 and Figure 4 , each step of the method M400 is described.

[0055] First, listen to the request action of the interface and obtain the request message about the request action. At this time, the tester only needs to send a read request to the application through the client of the test platform, which is not difficult to operate.

[0056] Further, step S410 is executed to parse the request message about the interface into multiple first type parameters and multiple second type parameters, the interface is used to define the interaction rules between the requester and the server, the first type parameters represent the interaction rules, and the second type parameters represent the attribute information of the requester.

[0057] Among them, multiple second-type parameters are stored in key-value pair format or string format, and the second-type parameters include parameter identifiers and parameter values. The first-type parameters may be, for example, paths and their parameter values, request methods and their parameter values, etc., all of which are set by the interface and do not change according to changes in the requester. The second-type parameters may be, for example, requester access timestamps and their parameter values, requester request content and their parameter values, etc. Different requesters or calls by the same requester at different times will generate different parameter values, so the second-type parameters are usually dynamically changing.

[0058] In order to meet the customization requirements, when parsing the request message, the parsing result needs to be converted into a key-value pair form or a string format to facilitate the implementation of customized replacement.

[0059] Furthermore, the tester is asked whether there is any customization requirement. If there is a customization requirement, the tester can feedback the customization instruction in natural language format. The customization requirement can be "need to record the test environment", "need to perform signature verification", "customization conditions are: condition 1 and condition 2", "need to replace the parameter value of the second type parameter with parameter identification 1 with interval a, and replace the parameter value of the second type parameter with parameter identification 2 with interval b", etc., which are not listed here one by one.

[0060] Specifically, before replacing the parameter value, the first model used for replacement is trained, and the first model can be a neural network model. When training the first model, "${myvar}" is used as the presentation format of the replacement subject, and myvar is the replacement subject variable. In the aforementioned example scenario, mywar is a custom interval, and the first model replaces "${myvar}" with the interface information interfaceInfo field of the second type parameter. For example, the second type parameter is {"id":"123","name":"test"}, and the custom interval of id is set to a random number between 1000 and 9999, then the custom interval of id can be written as ${__Random(1000,9999)}. After obtaining the custom interval, the first model will output the custom parameter {"id":"${__Random(1000,9999)}","name":"test"}, so that id is a random number between 1000 and 9999.

[0061] Further, execute step S420, replace the parameter value of the second type parameter indicated by the customization instruction with the customization interval in the customization instruction, and obtain the customized parameter, the customization instruction includes a parameter identifier and a customization interval with customization requirements, and the customization interval represents the parameter value variation range of the corresponding second type parameter that the interface can support.

[0062] Specifically, identify the parameter identifier and corresponding customization interval specified by the customization instruction regarding the second type parameter; and locate the second type parameter with the parameter identifier among multiple second type parameters, and replace the parameter value of the second type parameter with the parameter identifier with the customization interval in the customization instruction to obtain the customized parameter.

[0063] Of course, when replacing, a process text containing parameter identifiers and their customized intervals that is not convenient for generating scripts will be obtained. Therefore, regular expressions can be used to extract parameter identifiers and their customized intervals from the process text, and the parameter identifiers and their customized intervals can be converted into a key-value pair format or a string format to obtain customized parameters. The customized parameters can be: "timestamp" = "200001010000-203012122459". Among them, "timestamp" is the parameter identifier, and "200001010000-203012122459" is the customized interval.

[0064] Furthermore, step S430 is executed to configure the plurality of first type parameters, second type parameters and customized parameters to the script template according to the customized interval of the customized parameters, so as to generate a test script that satisfies the customized instructions.

[0065] Specifically, according to the customization interval of the customized parameters, multiple first type parameters, second type parameters and customized parameters are configured to the script template to generate a test script that meets the customized instructions. For example, in "timestamp" = "200001010000-203012122459", "202409061742" is used as the target parameter value, then the value of the timestamp in the script template will be filled in as "202409061742". When the script is executed, it means that the requester will call the interface at the corresponding time. Different requesters will have different timestamps, simulating the scenario where different requesters call the interface at different times.

[0066] Furthermore, it is determined whether the custom instruction includes a test environment. If the custom instruction includes a test environment, the first script engine is called to write an environment recording script to generate a test script including the environment recording script, where the environment recording script is used to record the test environment for the interface. The test environment includes offline or online.

[0067] Furthermore, it is determined whether the custom instruction contains a signature verification condition. If the signature verification condition is contained, the first script engine is called to write a verification script according to the access code and access key in the signature verification condition, and a test script containing the verification script is generated, and the verification script is used to verify whether the requester has the authority to call the interface.

[0068] Finally, a test script is formed that includes one or more of the request action script, environment recording script, and verification script. Then, the JMeter and other testing tools are controlled to call the interface according to the test script to obtain the performance results of the interface.

[0069] The test script generation method proposed in the present disclosure only requires the tester to send an access request to the application program on the client side through low-tech actions and to express custom instructions in natural language format. This method captures the request message of the actual call process of the interface, obtains the request parameters required to call the interface in the real interface call scenario, and integrates the custom instructions that meet the test requirements to generate a test script for the corresponding interface. In this process, the technical dependence on the tester is overcome. The tester only needs to show the action of calling the interface and answer the custom inquiry in natural language, which reduces the entry and learning costs; and it has high writing efficiency and is suitable for agile development scenarios with fast iteration and frequent testing.

[0070] Based on any of the above implementations, the present disclosure also provides a test script generating device 500 . Figure 5 It is a schematic block diagram of the structure of a test script generating device 500 according to an embodiment of the present disclosure.

[0071] like Figure 5 As shown, the test script generating device 500 includes:

[0072] The parsing module 510 is used to parse the request message about the interface into multiple first type parameters and multiple second type parameters. The interface is used to define the interaction rules between the requester and the requested party. The first type parameters represent the interaction rules, and the second type parameters represent the attribute information of the requester.

[0073] The customization module 520 is used to replace the parameter value of the second type parameter indicated by the customization instruction with the customization interval in the customization instruction to obtain the customized parameter. The customization instruction includes a parameter identifier with customization requirements and a customization interval. The customization interval represents the parameter value variation range of the corresponding second type parameter that the interface can support.

[0074] The script writing module 530 is used to configure a plurality of first type parameters, second type parameters and customized parameters to a script template according to a customized interval of the customized parameters, and generate a test script that satisfies the customized instructions.

[0075] In some implementations, the plurality of second type parameters are stored in a key-value pair format or a string format, and the second type parameters include a parameter identifier and a parameter value.

[0076] In some embodiments, the customization module 520 is executed as follows: identifying a parameter identifier and a corresponding customization interval regarding a second type parameter specified by a customization instruction; and locating a second type parameter with a parameter identifier among multiple second type parameters, and replacing the parameter value of the second type parameter with the parameter identifier with the customization interval in the customization instruction to obtain a customized parameter.

[0077] In some embodiments, the execution method of the customization module 520 is: obtaining a process text containing a parameter identifier and its customization interval; and using a regular expression to extract the parameter identifier and its customization interval from the process text, and converting the parameter identifier and its customization interval into a key-value pair format or a string format to obtain a customized parameter.

[0078] In some embodiments, the script writing module 530 is also used to: select a target parameter value in a custom interval of custom parameters, write multiple first-type parameters, second-type parameters, and custom parameters with the target parameter value as the parameter value into a script template, obtain a request action script, and generate a test script containing the request action script.

[0079] In some implementations, the apparatus 500 further includes a message capturing module (not shown) configured to monitor request actions on the interface and obtain request messages regarding the request actions.

[0080] In some implementations, the apparatus 500 further includes an interaction module (not shown) for obtaining customized instructions in a natural language form, wherein the customized instructions include a test environment.

[0081] In some implementations, the script writing module 530 is further used to: call the first script engine to write an environment recording script, generate a test script including the environment recording script, and the environment recording script is used to record the test environment of the interface.

[0082] In some implementations, the message capture module is further used to obtain custom instructions in natural language form, where the custom instructions include signature verification conditions.

[0083] In some embodiments, the script writing module 530 is further used to: call the first script engine to write a verification script based on the access code and access key in the signature verification condition, and generate a test script containing the verification script, where the verification script is used to verify whether the requesting party has the authority to call the interface.

[0084] The above modules can be implemented by computer program modules.

[0085] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0086] The test script generation device proposed in the present disclosure is an AI model that can execute the test script generation method, can monitor the access request of the tester, and interact with the tester in natural language through dialogue to obtain its customized requirements. Therefore, when using the device, the tester only needs to test the sending of access requests to the application program on the client side through low-tech actions, and express the customized instructions in natural language format. The device captures the request message of the actual call process of the interface, obtains the request parameters required to call the interface in the real interface call scenario, and integrates the customized instructions that meet the test requirements to generate a test script for the corresponding interface. In this process, the technical dependence on the tester is overcome. The tester only needs to show the action of calling the interface and answer the customized inquiry in natural language, which reduces the entry and learning costs; and it has high writing efficiency and is suitable for agile development scenarios with fast iteration and frequent testing.

[0087] The execution subject of the test script generation method in the specific implementation manner of the present disclosure may be an electronic device such as a mobile phone, a tablet computer, or a server.

[0088] Therefore, based on any of the above embodiments, the present disclosure also provides an electronic device, which can execute the test script generation method of any of the embodiments described above in the present disclosure, and the test script generation device of any of the embodiments described above can be configured on the electronic device.

[0089] Figure 6 The present invention is a block diagram showing a structure of an electronic device equipped with a test script generating device according to an embodiment of the present invention.

[0090] The electronic device 6000 may, for example, Figure 1 The server shown in Figure 2 , which is configured with a test script generating device. The hardware structure of the electronic device 6000 can be implemented using a bus architecture. The bus architecture may include any number of interconnecting buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 6100 connects various circuits including one or more processors 6200, memory 6300 and / or hardware modules together. The bus 6100 may also connect various other circuits 6400 such as peripherals, voltage regulators, power management circuits, external antennas, etc.

[0091] The bus 6100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. A bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one connecting line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0092] The electronic medium disclosed in the present invention has a built-in test script generation device, which only requires the tester to send an access request to the application program on the client side through low-tech actions and express the customized instructions in natural language format. By capturing the request message of the actual calling process of the interface, obtaining the request parameters required to call the interface in the real interface calling scenario, and integrating the customized instructions that meet the test requirements, a test script for the corresponding interface is generated. In this process, the technical dependence on the tester is overcome. The tester only needs to show the action of calling the interface and answer the customized inquiry in natural language, which reduces the entry and learning costs; and it has a high writing efficiency and is suitable for agile development scenarios with fast iteration and frequent testing.

[0093] The present disclosure also provides a readable storage medium, in which a computer program is stored, and the computer program is used to implement the above method when executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.

[0094] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed, the process or function of the present disclosure is executed in whole or in part.

[0095] The computer program or instructions may be stored in a readable storage medium or transmitted from one readable storage medium to another readable storage medium, for example, the computer program or instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The readable storage medium may be any available medium that can be accessed or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid state drive. The computer readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.

[0096] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0097] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0098] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0099] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0100] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and features of different embodiments / methods or examples, unless they are contradictory.

[0101] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0102] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.

[0103] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0104] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.

[0105] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0106] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0107] At the same time, it can be understood that the data involved in the technical solution of the present disclosure (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of relevant laws, regulations and relevant provisions.

Claims

1. A test script generation method, characterized in that: include: Parsing a request message about an interface into a plurality of first type parameters and a plurality of second type parameters, wherein the interface is used to define an interaction rule between a requester and a requested party, the first type parameters representing the interaction rule, and the second type parameters representing attribute information of the requester; Replacing the parameter value of the second type parameter indicated by the customization instruction with the customization interval in the customization instruction to obtain the customized parameter, wherein the customization instruction includes a parameter identifier with customization requirements and a customization interval, wherein the customization interval represents a parameter value variation range of the corresponding second type parameter that can be supported by the interface; as well as According to the customization interval of the customized parameters, the plurality of first type parameters, the second type parameters and the customized parameters are configured to a script template to generate a test script that satisfies the customized instructions.

2. The test script generation method according to claim 1, characterized in that: The multiple second type parameters are stored in a key-value pair format or a string format, and the second type parameters include a parameter identifier and a parameter value.

3. The test script generation method according to claim 1, characterized in that: Replacing the parameter value of the second type parameter indicated by the customization instruction with the customization interval in the customization instruction to obtain the customization parameter, including: Identifying a parameter identifier and a corresponding customization interval regarding a second type parameter specified by the customization instruction; and The second type parameter having the parameter identifier is located in the multiple second type parameters, and the parameter value of the second type parameter having the parameter identifier is replaced with the customization interval in the customization instruction to obtain the customization parameter.

4. The test script generation method according to claim 3, characterized in that: After replacing the parameter value of the second type parameter having the parameter identifier with the customized interval in the customized instruction, the method includes: Obtaining a process text including the parameter identifier and its customized interval; and The parameter identifier and the customized interval are extracted from the process text by using a regular expression, and the parameter identifier and the customized interval are converted into a key-value pair format or a character string format to obtain the customized parameter.

5. The test script generation method according to claim 1, characterized in that: According to the customization interval of the customization parameter, the plurality of first type parameters, the second type parameters and the customization parameter are configured to a script template to generate a test script that satisfies the customization instruction, including: A target parameter value is selected in the customization interval of the custom parameter, the multiple first type parameters, the second type parameters and the custom parameters with the target parameter value as the parameter value are written into a script template, a request action script is obtained, and a test script including the request action script is generated.

6. The test script generation method according to claim 1, characterized in that: Before parsing a request message about an interface into a plurality of first-type parameters and a plurality of second-type parameters, the method includes: The request action on the interface is monitored, and a request message about the request action is obtained.

7. The test script generation method according to claim 1, characterized in that: Before replacing the parameter value of the second type parameter having the parameter identifier with the custom interval in the custom instruction, the method further includes: Obtaining a custom instruction in a natural language format, wherein the custom instruction includes a test environment; Preferably, it also includes: Calling a first script engine to write an environment recording script, and generating a test script including the environment recording script, wherein the environment recording script is used to record a test environment for the interface; Preferably, before replacing the parameter value of the second type parameter having the parameter identifier with the customized interval in the customized instruction, the method further includes: obtaining a customized instruction in a natural language form, wherein the customized instruction includes a signature verification condition; Preferably, it also includes: calling the first script engine to write a verification script according to the access code and access key in the signature verification condition, generating a test script containing the verification script, and the verification script is used to verify whether the requesting party has the authority to call the interface.

8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instruction stored in the memory, so that the processor executes the test script generation method according to any one of claims 1 to 7.

9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which are used to implement the test script generation method according to any one of claims 1 to 7 when executed by a processor.

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 7 is implemented.