Test script generation method and system based on bs architecture

CN115408258BActive Publication Date: 2026-09-08WINNING HEALTH TECHNOLOGY GROUP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110589966.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-28
Publication Date
2026-09-08
Estimated Expiration
2041-05-28

AI Technical Summary

Technical Problem

[0003]然而,目前fiddler的插件方案,仅仅支持在抓取报文时转换,无法支持多业务、无法支持参数化功能;同时该方案存在环境依赖必须安装fiddler及插件,无法达到灵活使用的目的,且在某些系统中,由于部分请求结构特殊,无法通过fiddler工具抓取进行转换

Benefits of technology

[0049]The aforementioned test script generation method, system, computer equipment, and storage medium based on a B/S architecture involve: acquiring the original message for script construction; parsing the original message and storing the parsing results in a request array; traversing all requests in the request array and parsing each request to extract key information; grouping the key information according to request type and obtaining the group for each key information; cleaning the key information to obtain granular information; sorting each request according to the key information to obtain a sorting result, and simultaneously splitting and storing the request and response data of each request; constructing script logical architecture elements; building the script based on the script logical architecture elements, key information, key information groups, and granular information to obtain an initial script; for the request information in each group, acquiring the request data of the current request, and based on the sorting result, acquiring the response data of the preceding requests based on the current request; determining parameters based on the request data of the current request and the response data of the preceding requests, and parameterizing the parameters to obtain parameterized data; and generating a test script based on the sorted initial script and the parameterized data. By grouping key information according to request type, with the aim of supporting the simultaneous construction of multiple business test scripts, the function of supporting multiple business test scripts simultaneously is realized; by parameterizing the parameters returned by a certain pre-request for the confirmation response data, the parameterization function is realized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115408258B_ABST
    Figure CN115408258B_ABST
Patent Text Reader

Abstract

The scheme relates to a test script generation method based on a BS architecture. The method comprises the following steps: parsing an original message and storing the parsing result into a request array, traversing the requests in the request array, and screening out key information; sorting the requests according to the key information, meanwhile, splitting and storing the request data and response data of each request; generating an initial script; for the request information in each group, obtaining the request data of the current request, and obtaining the response data of the previous request based on the current request according to the sorting result, determining the parameters according to the request data of the current request and the response data of the previous request, thereby performing parameterization processing to obtain parameterized data; and generating a test script according to the initial script after sorting and the parameterized data. The grouping realizes the function of simultaneously supporting multiple business test scripts; and the parameterization processing of the parameters returned by the response data from a certain previous request realizes the parameterization function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of performance testing technology, and in particular to a test script generation method, system, computer device, and storage medium based on a B / S architecture. Background Technology

[0002] A script is an executable file written in a specific descriptive language according to a certain format; it is also called a macro or batch file. A script is an extension of batch files; it is a plain text program. Generally, a computer script is a defined series of actions that control the computer to perform calculations and operations, and it can implement logical branches, etc. Traditional B / S architecture system performance testing script conversion is usually done manually by copying or with the help of tools like Fiddler. Fiddler currently offers a plugin that supports script conversion. Fiddler is an HTTP protocol debugging proxy tool that can record and inspect all HTTP communications between the computer and the Internet, set breakpoints, and view all data "entering" and "exiting" Fiddler.

[0003] However, the current Fiddler plugin solution only supports conversion when capturing packets, and cannot support multiple services or parameterization. At the same time, this solution has environmental dependencies and requires the installation of Fiddler and its plugins, which cannot achieve the purpose of flexible use. Furthermore, in some systems, due to the special structure of some requests, it is impossible to capture and convert them using the Fiddler tool. Summary of the Invention

[0004] In order to solve the above technical problems, a test script generation method, system, computer equipment and storage medium based on BS architecture are provided, which can support the simultaneous conversion of multiple services and the parameterization of conversion requests.

[0005] A test script generation method based on a B / S architecture, the method comprising:

[0006] Obtain the original message of the construction script, parse the original message and store the parsing result in the request array, traverse all requests in the request array, parse each request and filter out the key information in each request;

[0007] The key information is grouped according to the request type, and the group of each key information is obtained; the key information is cleaned to obtain granular information; the requests are sorted according to the key information to obtain a sorting result, and the request data and response data of each request are split and stored.

[0008] Construct script logic architecture elements, and build a script based on the script logic architecture elements, the key information, the group of the key information, and the granular information to obtain an initial script;

[0009] For the request information in each of the groups, obtain the request data of the current request, and obtain the response data of the preceding request based on the sorting result. Determine the parameters based on the request data of the current request and the response data of the preceding request, and perform parameterization processing on the parameters to obtain parameterized data.

[0010] A test script is generated based on the sorted initial script and the parameterized data.

[0011] In one embodiment, the step of traversing all requests in the request array and parsing each request to filter out key information from each request includes:

[0012] Obtain key-value pairs, and iterate through all requests in the request array using the key-value pairs, extracting key information from the requests during the iteration process;

[0013] The key information includes request type, request method, message body, path information, response data, and timestamp.

[0014] In one embodiment, the process of cleaning the key information to obtain granular information includes:

[0015] Retrieve pre-set filtering rules;

[0016] According to the filtering rules, auxiliary fields in the key information are deleted, and target information in the key information is filtered and retained; the target information includes the path information.

[0017] The path information is extracted from the target information, and the path information is parsed step by step to obtain the granular information.

[0018] In one embodiment, the step of sorting the requests according to the key information to obtain a sorting result includes:

[0019] Extract the timestamp from the key information corresponding to each request;

[0020] The requests are sorted according to the timestamps to obtain the sorting result.

[0021] In one embodiment, the method further includes, prior to constructing the script logic architecture elements:

[0022] Construct the target script architecture and analyze the node elements based on the target script architecture;

[0023] The node element is saved as the script logic architecture element and in the form of a configuration file.

[0024] In one embodiment, the step of obtaining response data of preceding requests based on the current request according to the sorting result, determining parameters based on the request data of the current request and the response data of the preceding requests, and parameterizing the parameters includes:

[0025] Obtain the parameter scoring range corresponding to each request respectively. Based on the sorting result, backtrack upwards step by step from the current request and compare the request data of the current request with the response data of each request to obtain the comparison result.

[0026] When the comparison result is a successful match, the corresponding data in the current request is parameterized.

[0027] In one embodiment, generating a test script based on the sorted initial script and the parameterized data includes:

[0028] Based on the sorted initial script and the parameterized data, construct thread groups; create logic controllers based on the grouping of the key information; and create parameter fields and parameter data to be passed based on the key information.

[0029] The test script is generated based on the thread group, the logic controller, the passed parameter fields, and the passed parameter data;

[0030] Output the test script content as a target file and save it to the target path.

[0031] A test script generation system based on a B / S architecture, the system comprising:

[0032] The information parsing module is used to obtain the original message of the construction script, parse the original message and store the parsing result in the request array, traverse all requests in the request array, parse each request, and filter out the key information in each request;

[0033] The data storage module is used to group the key information according to the request type and obtain the group of each key information; clean the key information to obtain granular information; sort each request according to the key information to obtain a sorting result, and at the same time split the request data and response data of each request, and store the request data and response data of each request.

[0034] The script building module is used to build script logic architecture elements, and to build a script based on the script logic architecture elements, the key information, the group of the key information, and the granular information to obtain an initial script.

[0035] The parameterization module is used to obtain the request data of the current request for the request information in each of the groups, and obtain the response data of the previous request based on the current request according to the sorting result, determine the parameters according to the request data of the current request and the response data of the previous request, and perform parameterization processing on the parameters to obtain the parameterized data.

[0036] The test script generation module is used to generate test scripts based on the sorted initial scripts and the parameterized data.

[0037] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:

[0038] Obtain the original message of the construction script, parse the original message and store the parsing result in the request array, traverse all requests in the request array, parse each request and filter out the key information in each request;

[0039] The key information is grouped according to the request type, and the group of each key information is obtained; the key information is cleaned to obtain granular information; the requests are sorted according to the key information to obtain a sorting result, and the request data and response data of each request are split and stored.

[0040] Construct script logic architecture elements, and build a script based on the script logic architecture elements, the key information, the group of the key information, and the granular information to obtain an initial script;

[0041] For the request information in each of the groups, obtain the request data of the current request, and obtain the response data of the preceding request based on the sorting result. Determine the parameters based on the request data of the current request and the response data of the preceding request, and perform parameterization processing on the parameters to obtain parameterized data.

[0042] A test script is generated based on the sorted initial script and the parameterized data.

[0043] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0044] Obtain the original message of the construction script, parse the original message and store the parsing result in the request array, traverse all requests in the request array, parse each request and filter out the key information in each request;

[0045] The key information is grouped according to the request type, and the group of each key information is obtained; the key information is cleaned to obtain granular information; the requests are sorted according to the key information to obtain a sorting result, and the request data and response data of each request are split and stored.

[0046] Construct script logic architecture elements, and build a script based on the script logic architecture elements, the key information, the group of the key information, and the granular information to obtain an initial script;

[0047] For the request information in each of the groups, obtain the request data of the current request, and obtain the response data of the preceding request based on the sorting result. Determine the parameters based on the request data of the current request and the response data of the preceding request, and perform parameterization processing on the parameters to obtain parameterized data.

[0048] A test script is generated based on the sorted initial script and the parameterized data.

[0049] The aforementioned test script generation method, system, computer equipment, and storage medium based on a B / S architecture involve: acquiring the original message for script construction; parsing the original message and storing the parsing results in a request array; traversing all requests in the request array and parsing each request to extract key information; grouping the key information according to request type and obtaining the group for each key information; cleaning the key information to obtain granular information; sorting each request according to the key information to obtain a sorting result, and simultaneously splitting and storing the request and response data of each request; constructing script logical architecture elements; building the script based on the script logical architecture elements, key information, key information groups, and granular information to obtain an initial script; for the request information in each group, acquiring the request data of the current request, and based on the sorting result, acquiring the response data of the preceding requests based on the current request; determining parameters based on the request data of the current request and the response data of the preceding requests, and parameterizing the parameters to obtain parameterized data; and generating a test script based on the sorted initial script and the parameterized data. By grouping key information according to request type, with the aim of supporting the simultaneous construction of multiple business test scripts, the function of supporting multiple business test scripts simultaneously is realized; by parameterizing the parameters returned by a certain pre-request for the confirmation response data, the parameterization function is realized. Attached Figure Description

[0050] Figure 1 This is an application environment diagram of a test script generation method based on a B / S architecture in one embodiment;

[0051] Figure 2 This is a flowchart illustrating a test script generation method based on a B / S architecture in one embodiment;

[0052] Figure 3 Here is a block diagram of a test script generation system based on a B / S architecture in one embodiment;

[0053] Figure 4 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0054] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0055] The test script generation method based on a B / S architecture provided in this application can be applied to, for example... Figure 1 The application environment shown. For example... Figure 1As shown, the application environment includes computer equipment 110. Computer device 110 can acquire the original message of the script construction, parse the original message and store the parsing result in a request array, traverse all requests in the request array, parse each request, and filter out the key information in each request; computer device 110 can group the key information according to the request type and obtain the group of each key information; clean the key information to obtain granular information; sort each request according to the key information to obtain a sorting result, and simultaneously split the request data and response data of each request, and store the request data and response data of each request; computer device 110 can construct script logical architecture elements, construct the script according to the script logical architecture elements, key information, key information groups, and granular information to obtain an initial script; for the request information in each group, computer device 110 can acquire the request data of the current request, and according to the sorting result, acquire the response data of the preceding request based on the current request, determine the parameters according to the request data of the current request and the response data of the preceding request, and perform parameterization processing on the parameters to obtain parameterized data; computer device 110 can generate a test script according to the sorted initial script and the parameterized data. Among them, computer equipment 110 may include, but is not limited to, various personal computers, laptops, smartphones, robots, unmanned aerial vehicles, tablets, etc.

[0056] In one embodiment, such as Figure 2 As shown, a test script generation method based on a B / S architecture is provided, including the following steps:

[0057] Step 202: Obtain the original message of the construction script, parse the original message and store the parsing result in the request array, traverse all requests in the request array, parse each request, and filter out the key information in each request.

[0058] The computer device can acquire the raw messages of the build script, parse the raw messages, store the parsing results in a request array, and iterate through all requests in the request array. Specifically, during the process of iterating through all requests, the computer device needs to parse each request to filter out key information from each request based on specific formats and content. This key information can represent basic information and auxiliary data required when building the script; basic information may include the request method, request content, and request response content, while auxiliary information may include the request timestamp. The source file can be based on the Chrome browser, saving the tracked request content as a HAR file. The HAR file content can be in JSON format or other formats, which are not limited here.

[0059] Step 204: Group the key information according to the request type and obtain the group of each key information; clean the key information to obtain granular information; sort each request according to the key information to obtain the sorting result, and at the same time split the request data and response data of each request, and store the request data and response data of each request.

[0060] Different request types can represent different services. Computer devices can group key information according to request type (i.e., service) and obtain the grouping of each key information. Similarly, different groups can represent different services. In this embodiment, the purpose of grouping is to support the simultaneous construction of multiple service test scripts.

[0061] Computer equipment can cleanse key information in messages. Cleaning can include filtering and refining data, removing unnecessary content and granulating the information to obtain granular data. Simultaneously, the computer equipment can sort requests based on key information to obtain a ranking result. Furthermore, the computer equipment can break down request and response data for each request and store them in a specific format, such as using a dataframe.

[0062] Step 206: Construct script logic architecture elements. Based on the script logic architecture elements, key information, the group of key information, and the granular information, construct the script to obtain the initial script.

[0063] The script logic architecture can be the JMeter script architecture. Computer devices can construct JMeter script logic architecture elements to obtain the initial script based on the parsing results of each request and the script logic architecture elements.

[0064] Step 208: For the request information in each group, obtain the request data of the current request, and based on the sorting result, obtain the response data of the previous request based on the current request. Determine the parameters based on the request data of the current request and the response data of the previous request, and perform parameterization processing on the parameters to obtain the parameterized data.

[0065] In this embodiment, each request corresponds to request data and response data. The computer device can locate the current request and obtain the corresponding request data based on the request information in each group. Simultaneously, the computer device can obtain the response data corresponding to previous requests based on the current request, according to the sorting results.

[0066] Specifically, computer devices can match the request data of the current request with the response data of the previous request to determine that the request data of the current request comes from the response data of the previous request. At this time, the parameters corresponding to the request data of the current request can be parameterized to obtain parameterized data.

[0067] Step 210: Generate a test script based on the sorted initial script and the parameterized data.

[0068] Computer devices can automatically construct test scripts based on a sorted initial script and parameterized data. The constructed test scripts can cover key information such as requests, transaction controllers, and thread groups.

[0069] In this embodiment, the process involves obtaining the original message of the script construction, parsing the original message and storing the parsing result in a request array, traversing all requests in the request array, parsing each request, and filtering out key information from each request; grouping the key information according to the request type and obtaining the group of each key information; cleaning the key information to obtain granular information; sorting each request according to the key information to obtain a sorting result, and simultaneously splitting the request data and response data of each request, storing the request data and response data of each request; constructing script logical architecture elements, and building the script based on the script logical architecture elements, key information, key information groups, and granular information to obtain the initial script; for the request information in each group, obtaining the request data of the current request, and obtaining the response data of the preceding request based on the sorting result, determining parameters based on the request data of the current request and the response data of the preceding request, and parameterizing the parameters to obtain parameterized data; and generating a test script based on the sorted initial script and the parameterized data. By grouping key information according to request type, with the aim of supporting the simultaneous construction of multiple business test scripts, the function of supporting multiple business test scripts simultaneously is realized; by parameterizing the parameters returned by a certain pre-request for the confirmation response data, the parameterization function is realized.

[0070] In one embodiment, a test script generation method based on a B / S architecture may further include a process of parsing each request. The specific process includes: obtaining key-value pairs, traversing all requests in the request array through the key-value pairs, and extracting key information from the requests during the traversal. The key information includes request type, request method, message body, path information, response data, and timestamp.

[0071] Key-value pairs can be pre-defined, specifying key:value pairs. Computer devices can read the request array using the specified key-value pairs and iterate through all requests in the array to extract key information from each request.

[0072] In one embodiment, a test script generation method based on a B / S architecture may further include an information cleaning process, specifically including: obtaining pre-set filtering rules; deleting auxiliary fields from key information according to the filtering rules, and filtering and retaining target information from the key information; the target information contains path information; extracting the path information from the target information, and parsing the path information step by step to obtain granular information.

[0073] Computer equipment can clean key information in messages according to pre-set filtering rules. Cleaning can include filtering out unnecessary content, deleting auxiliary fields from key information, and filtering to retain target information from key information. For example, after cleaning, some fields, such as auxiliary fields, are no longer needed and need to be deleted. Filtering refers to two actions: selecting and retaining valid data and deleting invalid data from the cleaned data.

[0074] Among these, path information is considered valid data, and computer equipment can retain this valid data during the cleaning of critical information. The computer equipment can then progressively parse the path information within this valid data to obtain granular information. Specifically, this granular information can be used to define request names when building scripts.

[0075] In one embodiment, a test script generation method based on a B / S architecture may further include a process of sorting each request to obtain a sorting result. The specific process includes: extracting the timestamp from the key information corresponding to each request; and sorting each request according to the timestamp to obtain a sorting result.

[0076] Because the key information contains timestamps, computer devices can extract the timestamps from the key information corresponding to each request, and then sort the requests according to the timestamps to obtain the sorting results.

[0077] In one embodiment, a test script generation method based on a B / S architecture may further include a process of obtaining node elements, specifically including: constructing a target script architecture, and analyzing and obtaining node elements based on the target script architecture; and saving the node elements as script logic architecture elements in the form of a configuration file.

[0078] The target script architecture can be a JMeter script architecture. The computer can construct the JMeter script architecture and analyze it to obtain node elements. These node elements can be saved and referenced in a configuration file.

[0079] In one embodiment, a test script generation method based on a B / S architecture may further include a parameterization process, which specifically includes: obtaining the parameter scoring range corresponding to each request, backtracking upwards step by step based on the current request according to the sorting result, comparing the request data of the current request with the response data of each request to obtain the comparison result; when the comparison result is a successful match, parameterizing the corresponding data in the current request.

[0080] Specifically, the computer device can construct a data set from parameters key, value, and key+value. Based on the sorting results of the requests, the computer device can progressively backtrack the request data of the current request and compare it with the response data of each subsequent request to obtain a comparison result. This comparison process can be based on weighted and feature matching algorithms. For example, with a total score of 10, the scoring intervals are divided proportionally, and a threshold is set. A match is considered successful when the score exceeds the threshold. The feature matching principle is to compare key, value, and key+value separately, returning a score based on the scoring interval and matching degree. In this embodiment, the scoring interval for the key item is 0-3, for the value item it is 0-3, and for the key+value item it is 0-4, with a threshold of 8. During parameterization, the number of backtracking requests can be set. If the maximum backtracking limit has been reached and the source of the returned data has not been confirmed, the backtracking is terminated, and a message indicating that the parameter source is unconfirmed is returned to the user. If the parameter source has been confirmed, the backtracking action is terminated, and the parameter source data is returned. For example, if we trace back the parameter `parameter_d` of request `request_d`, we find that the feature value comparison result between the return value `responses_a` and `parameter_d` in request `request_a` is 8.5. Therefore, we assume that the parameter `parameter_d` of request `request_d` originates from the return value `responses_a` of request `request_a`. Then, we parameterize the return field of request `request_a` as a parameter in request `request_d`.

[0081] In this embodiment, because key information is grouped, different groups represent different services. When multiple services exist, the computer device can repeatedly execute the initial script construction and parameterization processes. Specifically, the service name is used to create the corresponding thread group or transaction controller.

[0082] In one embodiment, a test script generation method based on a B / S architecture may further include a process of generating test scripts, specifically including: constructing thread groups based on sorted initial scripts and parameterized data; creating logic controllers based on the groups of key information; creating parameter fields and parameter data to be passed based on the key information; generating test scripts based on thread groups, logic controllers, parameter fields, and parameter data; and outputting the script content of the test scripts as target file format and saving them to the target path.

[0083] In this embodiment, the computer device can first construct a thread group according to the logical architecture of the JMeter script, then create a logic controller based on the business logic, and then add requests; while adding requests, the parameter fields and parameter data to be transmitted are created based on the parsed data.

[0084] In this embodiment, the script can utilize configuration files to fulfill different requirements. For example, execution methods and user parameters can be set via computer devices, thus ensuring the completed script meets its specific needs. Specifically, the test script is automatically built, and the generated test script can cover key information such as requests, transaction controllers, and thread groups.

[0085] After the script is built, its content is output as a target file format. This target file format can be a file format supported by the performance testing tool, and it is saved to a target path, which can be a specific path specified by the user on their computer device. The script file format is supported, but not limited to, XML. The save path can be a fixed value or support dynamic parameter passing. For example, in this embodiment, the built script is a *.jmx file with XML content, which is a standard script file supported by the performance testing tool JMeter.

[0086] In this embodiment, the generated test script can be easily converted and used after simple settings according to its own different needs; by merging the different needs into the script building process through parameterization, the same goal of instant conversion and use can be achieved.

[0087] It should be understood that although the steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the above flowcharts may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0088] In one embodiment, such as Figure 3 As shown, a test script generation system based on a B / S architecture is provided, including: an information parsing module 310, a data storage module 320, a script construction module 330, a parameterization module 340, and a test script generation module 350, wherein:

[0089] The information parsing module 310 is used to obtain the original message of the construction script, parse the original message and store the parsing result in the request array, traverse all requests in the request array, parse each request and filter out the key information in each request;

[0090] The data storage module 320 is used to group key information according to request type and obtain the group of each key information; clean the key information to obtain granular information; sort each request according to key information to obtain sorting results, and at the same time split the request data and response data of each request, and store the request data and response data of each request.

[0091] The script building module 330 is used to build script logical architecture elements. Based on the script logical architecture elements, key information, the group of key information, and granular information, the script is built to obtain the initial script.

[0092] The parameterization module 340 is used to obtain the request data of the current request for the request information in each group, and obtain the response data of the previous request based on the sorting result, determine the parameters based on the request data of the current request and the response data of the previous request, and perform parameterization processing on the parameters to obtain the parameterized data.

[0093] The test script generation module 350 is used to generate test scripts based on the sorted initial scripts and parameterized data.

[0094] In one embodiment, the information parsing module 310 is further configured to obtain key-value pairs, traverse all requests in the request array through the key-value pairs, and extract key information from the requests during the traversal process; wherein, the key information includes request type, request method, message body, path information, response data, and timestamp.

[0095] In one embodiment, the data storage module 320 is further configured to obtain pre-set filtering rules; delete auxiliary fields in key information according to the filtering rules, filter and retain target information in key information; the target information contains path information; extract the path information in the target information, and parse the path information step by step to obtain granular information.

[0096] In one embodiment, the data storage module 320 is further configured to extract the timestamp from the key information corresponding to each request; and sort the requests according to the timestamp to obtain a sorting result.

[0097] In one embodiment, the script building module 330 is further configured to build a target script architecture and obtain node elements based on the target script architecture analysis; the node elements are then saved as script logic architecture elements in the form of a configuration file.

[0098] In one embodiment, the parameterization module 340 is further configured to obtain the parameter scoring range corresponding to each request, and based on the sorting result, backtrack upwards step by step from the current request to compare the request data of the current request with the response data of each request to obtain the comparison result; when the comparison result is a successful match, the corresponding data in the current request is parameterized.

[0099] In one embodiment, the test script generation module 350 is further configured to: construct a thread group based on the sorted initial script and parameterized data; create a logic controller based on the group of key information; create the parameter fields and parameter data to be passed based on the key information; generate a test script based on the thread group, logic controller, parameter fields and parameter data; and output the script content of the test script as a target file format and save it to the target path.

[0100] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 4As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a test script generation method based on a B / S architecture. The display screen can be an LCD screen or an e-ink display screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.

[0101] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0102] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0103] Obtain the original message of the build script, parse the original message and store the parsing result in the request array, traverse all requests in the request array, parse each request and filter out the key information in each request;

[0104] Group key information according to request type and obtain the group of each key information; clean the key information to obtain granular information; sort each request according to key information to obtain sorting results, and at the same time split the request data and response data of each request, and store the request data and response data of each request.

[0105] Construct script logic architecture elements, and build the script based on script logic architecture elements, key information, key information groups, and granular information to obtain the initial script;

[0106] For the request information in each group, obtain the request data of the current request, and based on the sorting result, obtain the response data of the previous request based on the current request. Determine the parameters based on the request data of the current request and the response data of the previous request, and perform parameterization on the parameters to obtain the parameterized data.

[0107] Generate a test script based on the sorted initial script and the parameterized data.

[0108] In one embodiment, when the processor executes the computer program, it also performs the following steps: obtaining key-value pairs, traversing all requests in the request array through the key-value pairs, and extracting key information from the requests during the traversal; wherein the key information includes request type, request method, message body, path information, response data, and timestamp.

[0109] In one embodiment, when the processor executes the computer program, it further performs the following steps: obtaining pre-set filtering rules; deleting auxiliary fields in the key information according to the filtering rules, filtering and retaining the target information in the key information; the target information contains path information; extracting the path information in the target information, and parsing the path information step by step to obtain granular information.

[0110] In one embodiment, when the processor executes the computer program, it further performs the following steps: extracting the timestamp from the key information corresponding to each request; sorting the requests according to the timestamps to obtain a sorting result.

[0111] In one embodiment, when the processor executes the computer program, it also performs the following steps: constructing a target script architecture and analyzing the node elements based on the target script architecture; and saving the node elements as script logic architecture elements in the form of a configuration file.

[0112] In one embodiment, when the processor executes the computer program, it further performs the following steps: obtaining the parameter scoring range corresponding to each request, and backtracking upwards step by step based on the current request according to the sorting result, comparing the request data of the current request with the response data of each request to obtain the comparison result; when the comparison result is a successful match, parameterizing the corresponding data in the current request.

[0113] In one embodiment, when the processor executes the computer program, it further performs the following steps: constructing a thread group based on the sorted initial script and parameterized data; creating a logic controller based on the group of key information; creating the parameter fields and parameter data to be passed based on the key information; generating a test script based on the thread group, logic controller, parameter fields and parameter data; and outputting the script content of the test script as a target file format and saving it to the target path.

[0114] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0115] Obtain the original message of the build script, parse the original message and store the parsing result in the request array, traverse all requests in the request array, parse each request and filter out the key information in each request;

[0116] Group key information according to request type and obtain the group of each key information; clean the key information to obtain granular information; sort each request according to key information to obtain sorting results, and at the same time split the request data and response data of each request, and store the request data and response data of each request.

[0117] Construct script logic architecture elements, and build the script based on script logic architecture elements, key information, key information groups, and granular information to obtain the initial script;

[0118] For the request information in each group, obtain the request data of the current request, and based on the sorting result, obtain the response data of the previous request based on the current request. Determine the parameters based on the request data of the current request and the response data of the previous request, and perform parameterization on the parameters to obtain the parameterized data.

[0119] Generate a test script based on the sorted initial script and the parameterized data.

[0120] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining key-value pairs, traversing all requests in the request array through the key-value pairs, and extracting key information from the requests during the traversal; wherein the key information includes request type, request method, message body, path information, response data, and timestamp.

[0121] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining pre-set filtering rules; deleting auxiliary fields in the key information according to the filtering rules, filtering and retaining the target information in the key information; the target information contains path information; extracting the path information in the target information, and parsing the path information step by step to obtain granular information.

[0122] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: extracting the timestamp from the key information corresponding to each request; sorting the requests according to the timestamps to obtain a sorting result.

[0123] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: constructing a target script architecture and analyzing the node elements based on the target script architecture; and saving the node elements as script logic architecture elements in the form of a configuration file.

[0124] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining the parameter scoring range corresponding to each request, and tracing back step by step upward based on the current request according to the sorting result, comparing the request data of the current request with the response data of each request to obtain the comparison result; when the comparison result is a successful match, parameterizing the corresponding data in the current request.

[0125] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: constructing a thread group based on the sorted initial script and parameterized data; creating a logic controller based on the group of key information; creating the parameter fields and parameter data to be passed based on the key information; generating a test script based on the thread group, logic controller, parameter fields and parameter data; and outputting the script content of the test script as a target file format and saving it to the target path.

[0126] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0127] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0128] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A test script generation method based on a B / S architecture, characterized in that, The method includes: Obtain the original message of the construction script, parse the original message and store the parsing result in the request array, traverse all requests in the request array, parse each request and filter out the key information in each request; The key information is grouped according to the request type, and the group of each key information is obtained; the key information is cleaned to obtain granular information; the requests are sorted according to the key information to obtain a sorting result, and the request data and response data of each request are split and stored; wherein, different request types are used to represent different services. Construct script logic architecture elements, and build a script based on the script logic architecture elements, the key information, the group of the key information, and the granular information to obtain an initial script; For the request information in each of the groups, obtain the request data of the current request, and obtain the response data of the preceding request based on the sorting result. Determine the parameters based on the request data of the current request and the response data of the preceding request, and perform parameterization processing on the parameters to obtain parameterized data. A test script is generated based on the sorted initial script and the parameterized data.

2. The test script generation method based on a B / S architecture according to claim 1, characterized in that, The process involves traversing all requests in the request array, parsing each request, and filtering out key information from each request, including: Obtain key-value pairs, and iterate through all requests in the request array using the key-value pairs, extracting key information from the requests during the iteration process; The key information includes request type, request method, message body, path information, response data, and timestamp.

3. The test script generation method based on a B / S architecture according to claim 2, characterized in that, The process of cleaning the key information to obtain granular information includes: Retrieve pre-set filtering rules; According to the filtering rules, auxiliary fields in the key information are deleted, and target information in the key information is filtered and retained; the target information includes the path information. The path information is extracted from the target information, and the path information is parsed step by step to obtain the granular information.

4. The test script generation method based on a B / S architecture according to claim 2, characterized in that, The step of sorting the requests according to the key information to obtain a sorting result includes: Extract the timestamp from the key information corresponding to each request; The requests are sorted according to the timestamps to obtain the sorting result.

5. The test script generation method based on a B / S architecture according to claim 1, characterized in that, Before constructing the script logic architecture elements, the method further includes: Construct the target script architecture and analyze the node elements based on the target script architecture; The node element is saved as the script logic architecture element and in the form of a configuration file.

6. The test script generation method based on a B / S architecture according to claim 1, characterized in that, The step of obtaining response data of preceding requests based on the current request according to the sorting result, determining parameters based on the request data of the current request and the response data of the preceding requests, and parameterizing the parameters includes: Obtain the parameter scoring range corresponding to each request respectively. Based on the sorting result, backtrack upwards step by step from the current request and compare the request data of the current request with the response data of each request to obtain the comparison result. When the comparison result is a successful match, the corresponding data in the current request is parameterized.

7. The test script generation method based on a B / S architecture according to claim 1, characterized in that, The step of generating a test script based on the sorted initial script and the parameterized data includes: Based on the sorted initial script and the parameterized data, construct thread groups; create logic controllers based on the grouping of the key information; and create parameter fields and parameter data to be passed based on the key information. The test script is generated based on the thread group, the logic controller, the passed parameter fields, and the passed parameter data; Output the test script content as a target file and save it to the target path.

8. A test script generation system based on a B / S architecture, characterized in that, The system includes: The information parsing module is used to obtain the original message of the construction script, parse the original message and store the parsing result in the request array, traverse all requests in the request array, parse each request, and filter out the key information in each request; The data storage module is used to group the key information according to the request type and obtain the group of each key information; clean the key information to obtain granular information; sort each request according to the key information to obtain a sorting result, and at the same time split the request data and response data of each request, and store the request data and response data of each request; wherein, different request types are used to represent different services. The script building module is used to build script logic architecture elements, and to build a script based on the script logic architecture elements, the key information, the group of the key information, and the granular information to obtain an initial script. The parameterization module is used to obtain the request data of the current request for the request information in each of the groups, and obtain the response data of the previous request based on the current request according to the sorting result, determine the parameters according to the request data of the current request and the response data of the previous request, and perform parameterization processing on the parameters to obtain the parameterized data. The test script generation module is used to generate test scripts based on the sorted initial scripts and the parameterized data.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Test case generation method and device, equipment and storage medium

    CN110750442A

  • Database comparison-based interface testing method and system, device and storage medium

    WO2020000706A1