Test script construction method, device, computer equipment and storage medium

By analyzing and merging the data to be tested in WCF communication methods and generating test scripts, the problem of low testing efficiency in the existing technology is solved, and the rapid and effective testing of complex test data under the WCF framework is achieved.

CN114579422BActive Publication Date: 2025-02-11WINNING HEALTH TECHNOLOGY GROUP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011379276.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-30
Publication Date
2025-02-11
Estimated Expiration
2040-11-30

AI Technical Summary

Technical Problem

The prior art cannot efficiently test the data to be tested generated by WCF communication methods, and requires manual writing of test scripts, which has low testing efficiency.

Method used

By obtaining the preset standard format of the test data to be tested, parsing and combining the test data of the same request, and finally adding the updated test data to the preset test script framework to generate the test script.

Benefits of technology

It realizes rapid and effective testing of complex test data under the WCF framework, improves testing efficiency, and reduces the need for manual writing of test scripts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114579422B_ABST
    Figure CN114579422B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a test script construction method, device, computer equipment and storage medium, the method comprising: obtaining test data in a preset standard format, the test data corresponding to at least one request; parsing the test data in the preset standard format to obtain a parsing result; determining the test data belonging to the same request in the parsing result according to a preset merging rule, and completing the merging of the test data of the same request to update the test data of each request; adding the updated test data of all requests to a preset test script framework to generate a test script. The method solves the problem that the prior art cannot realize efficient testing of the test data generated by the WCF communication method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer programs, and in particular to a test script construction method, apparatus, computer equipment and storage medium. Background Art

[0002] Windows Communication Foundation (WCF) is a series of application frameworks developed by Microsoft to support data communication, which can be translated as Windows communication development platform. This platform integrates the original .net Remoting, WebService and Socket mechanisms of Windows communication, and integrates related technologies such as HTTP and FTP. It is the best practice for developing distributed applications on the Windows platform.

[0003] WCF supports protocols such as HTTP, TCP, Named Pipe, MSMQ and Peer-To-Peer TCP. HTTP is divided into basic HTTP support (BasicHttpBinding) and WS-HTTP support (WsHttpBinding). TCP also supports communication methods such as NetTcpBinding and NetPeerTcpBinding.

[0004] In the process of implementing the present invention, the inventors found that the transmission requests of the above communication methods, especially other communication methods except the basic protocol, are particularly complex and require manual writing of test scripts, resulting in low test efficiency. Summary of the invention

[0005] The embodiment of the present invention provides a test script construction method, device, computer equipment and storage medium, which solves the problem that the prior art cannot realize efficient testing of the test data generated by the WCF communication mode.

[0006] In a first aspect, an embodiment of the present invention provides a test script construction method, comprising:

[0007] Acquire data to be tested in a preset standard format, where the data to be tested corresponds to at least one request;

[0008] Parsing the data to be tested in the preset standard format to obtain a parsing result;

[0009] Determine the test data belonging to the same request in the parsing result according to a preset merging rule, and complete the merging of the test data of the same request to update the test data of each request;

[0010] The updated test data of all requests are added to a preset test script framework to generate a test script.

[0011] Furthermore, the preset standard format is a standard JSON format. Accordingly, the parsing of the test data in the preset standard format to obtain the parsing result includes:

[0012] Parse the test data in standard JSON format to obtain at least one dictionary, each dictionary corresponds to a request;

[0013] The test data corresponding to the request is extracted from each dictionary according to the preset keywords to obtain the parsing result.

[0014] Furthermore, while extracting the test data corresponding to the request from each dictionary according to the preset keywords to obtain the parsing result, it also includes:

[0015] The test data extracted from each dictionary is output to the pandas module for storage, and the pandas module stores the test data of each dictionary in a dataframe format.

[0016] Further, determining the test data belonging to the same request in the parsing result according to the preset merging rule, and completing the merging of the test data of the same request to update the test data of each request, includes:

[0017] According to the principle that the index number of the same request is the same, the test data segments corresponding to the same request in the parsing result are divided into one group;

[0018] Convert the parsing results in each group into a text format, and pre-process the parsing results in the text format to update the parsing results in each group;

[0019] The test data segments in all the same groups are merged to update the test data of each group, thereby obtaining the test data for each request.

[0020] Further, the preprocessing includes:

[0021] The first target content of the parsing result in the text format is replaced and the second target content is escaped.

[0022] Furthermore, while converting the parsing result into a text format, it also includes:

[0023] If the ERR level is detected to be lower than the preset alarm threshold, the format conversion continues; otherwise, if the ERR level is detected to be higher than or equal to the preset alarm threshold, the current format conversion process is interrupted.

[0024] Further, the preset test script framework includes at least one thread group, the data to be tested corresponds to at least one business content, each business content corresponds to at least one request, and the updated test data of all requests is added to the preset test script framework to generate a test script, including:

[0025] The updated test data of all requests belonging to the same business content are added to the same thread group of the preset test script framework to generate a test script.

[0026] In a second aspect, an embodiment of the present invention further provides a test script construction device, comprising:

[0027] An acquisition module, used for acquiring the data to be tested in a preset standard format, wherein the data to be tested corresponds to at least one request;

[0028] A parsing module, used for parsing the data to be tested in the preset standard format to obtain a parsing result;

[0029] A merging module, used to determine the test data belonging to the same request in the parsing result according to a preset merging rule, and complete the merging of the test data of the same request to update the test data of each request;

[0030] The script generation module is used to add all the updated requested test data to a preset test script framework to generate a test script.

[0031] In a third aspect, an embodiment of the present invention further provides a computer device, the computer device comprising:

[0032] one or more processors;

[0033] A storage device for storing one or more programs;

[0034] When the one or more programs are executed by the one or more processors, the one or more processors implement the test script construction method as described in any embodiment.

[0035] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions are used to execute the test script construction method described in any embodiment when executed by a computer processor.

[0036] The technical solution of the test script construction method provided by the embodiment of the present invention obtains test data in a preset standard format, where the test data corresponds to at least one request; the test data in the preset standard format is parsed to obtain a parsing result, thereby solving the problem of low accuracy of the parsing result of the test data in the original format; the test data belonging to the same request in the parsing result is determined according to a preset merging rule, and the test data of the same request is merged to update the test data of each request; the updated test data of all requests is added to a preset test script framework to generate a test script, and the test scripts corresponding to the test data of all requests are quickly generated through the preset test script framework, thereby achieving the technical effect of quickly and effectively testing complex test data under the WCF framework through automatically constructed test scripts. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0038] Figure 1 is a flowchart of a test script construction method provided in Embodiment 1 of the present invention;

[0039] Figure 2 is a structural block diagram of a test script construction device provided in Embodiment 2 of the present invention;

[0040] Figure 3 It is a structural block diagram of a computer device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION

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

[0042] Embodiment 1

[0043] Figure 1: is a flowchart of the test script construction method provided in the first embodiment of the present invention. The technical solution of this embodiment is applicable to the case of automatically constructing a test script for the data to be tested in the WCF communication mode. The method can be executed by the test script construction device provided in the embodiment of the present invention, and the device can be implemented in software and / or hardware, and configured in the processor of the computer device for application. The method specifically includes the following steps:

[0044] S101: Acquire data to be tested in a preset standard format, where the data to be tested corresponds to at least one request.

[0045] The data to be tested is a hexadecimal message collected from the client or server of WCF communication, corresponding to one or more requests.

[0046] If the test object is a client, then the request in this embodiment is a request sent by the client to the server; if the test object is a server, then the request in this embodiment is a request sent by the server to the client. Taking the test object as a client as an example, when the user logs in to his account on the client, the client sends at least an account information verification request and a login time synchronization record request to the server based on the account information entered by the user. Then the account information verification request and the login time synchronization record request are both the requests described in this embodiment.

[0047] The test data of each request may exist in the form of one test data segment or in the form of at least two test data segments. Regardless of the number of test data segments, each data segment contains an index number, a sorting number, and preset first and last characters. The index number is used to index the test data segments of the same request, the sorting number is used to sort the test data segments of the same request, and the preset first and last characters are used to indicate the beginning and end of the corresponding test data segment, that is, to limit the range of the corresponding test data segment.

[0048] The preset standard format is preferably, but not limited to, a standard json format. If the preset standard format is a standard json format, the data to be tested obtained in text form is converted into the standard json format.

[0049] S102: parsing the data to be tested in a preset standard format to obtain parsing results.

[0050] Parse the test data in standard json format to obtain at least one dictionary, each dictionary corresponds to a request; extract the test data corresponding to the request from each dictionary according to the preset keywords to obtain the parsing result. In other words, each set of test data segments between the preset first and last characters corresponds to a dictionary, so that each dictionary corresponds to a request, and the test data segment it carries is all the data of a request or part of the data of a request; according to the preset keywords, the test data corresponding to the request can be extracted from each dictionary, thereby obtaining the parsing result. It can be understood that the parsing result includes at least one test data segment, and the at least one test data segment corresponds to at least one request.

[0051] The test data corresponding to the request extracted from each dictionary is output to the pandas module for storage. The pandas module stores the test data of each dictionary in dataframe format.

[0052] In addition to generating analysis results, performing analysis operations on the data to be tested also generates intermediate data, which is used to sort the requests in the analysis results according to the transaction time axis. In this embodiment, the analysis results and the intermediate data are preferably stored separately.

[0053] S103: Determine the test data belonging to the same request in the parsing result according to a preset merging rule, and complete the merging of the test data of the same request to update the test data of each request.

[0054] According to the principle that the index number of the same request is the same, the test data segments corresponding to the same request in the parsing results are divided into a group, and then the parsing results in each group are converted into text format, and the parsing results in text format are preprocessed to update the parsing results of each group, and then the test data segments in the same group are merged to update the test data of each request.

[0055] Exemplarily, based on the principle that the index numbers of the same request are the same, 10 test data segments are located in the updated parsing results, and then the index numbers of each test data segment are compared, and the test data segments with the same index number are divided into a test data group, and then the test data segments of each test data group are converted into text format, and the test data segments in each group are merged according to preset head and tail characters to update the test data corresponding to the request of each group. Since each group corresponds to one request, the test data corresponding to the request of each group is the test data corresponding to each request obtained.

[0056] The preprocessing includes but is not limited to replacing the first target content of the text format parsing result and escaping the second target content of the text format parsing result. It should be noted that the replacement process and the escaping process can be carried out by the existing technology, and this embodiment will not be described in detail.

[0057] Since the special characters contained in the analysis results can easily cause abnormal interruption of the format conversion, when converting the analysis results to text format, if the ERR level is detected to be lower than the preset alarm threshold, the format conversion will continue to be performed. On the contrary, if the ERR level is detected to be higher than or equal to the preset alarm threshold, it means that the current data to be tested cannot meet the current test requirements, so the current format conversion process is interrupted. The ERR level can improve the universality and efficiency of the format conversion of the analysis results, and avoid automatically interrupting the format conversion of the analysis results when problems that do not affect the test results occur in the analysis results.

[0058] S104: Add all updated requested test data to a preset test script framework to generate a test script.

[0059] The preset test script framework can also be understood as a test script template, which is automatically constructed by reading the configuration information in the configuration file. Preferably, the preset test script framework supports dynamic parameter transmission and has high universality. It is understandable that each preset test script framework corresponds to a test plan.

[0060] After obtaining the updated test data for each request, the test data for all requests are added to the corresponding positions of the preset test script framework, thereby generating a test script.

[0061] In one embodiment, the preset test script framework includes one or more thread groups, the data to be tested corresponds to one or more business contents, and each business content corresponds to one or more requests. One or more requests corresponding to each business content are determined according to the transaction sequence number of each business content, and the test data of each request is determined according to the index sequence number of each request, thereby determining the test data corresponding to each business content; establishing a correspondence between the business content and the thread group, and then adding the updated test data of all requests for the same business content to the same thread group of the preset test script framework to generate a test script. It can be understood that the test script can test multiple business contents in a test plan at the same time, thereby greatly improving the test efficiency of the test data under the WCF framework.

[0062] In one embodiment, the actions and message bodies of each request of each business content in the stored data are read in an index polling manner, and the actions and message bodies of each request of the business script are replaced to obtain the business script of each business content. Then, the business script of each business content is added to the corresponding thread group of the preset test script framework to obtain the test script. Among them, each thread group is preferably named after the business content to which it corresponds or the corresponding source data file name.

[0063] After the test script is built, output the test script to a file format supported by the performance testing tool and save it to a specific path. The test script format supports but is not limited to the XML format. The save path can be a fixed value or support dynamic parameter passing. Among them, the test script content is in XML format, with the suffix of jmx format, which is a standard stress testing script file supported by the tool jmeter.

[0064] The technical solution of the test script construction method provided by the embodiment of the present invention obtains test data in a preset standard format, where the test data corresponds to at least one request; the test data in the preset standard format is parsed to obtain a parsing result, thereby solving the problem of low accuracy of the parsing result of the test data in the original format; the test data belonging to the same request in the parsing result is determined according to a preset merging rule, and the test data of the same request is merged to update the test data of each request; the updated test data of all requests is added to a preset test script framework to generate a test script, and the test scripts corresponding to the test data of all requests are quickly generated through the preset test script framework, thereby achieving the technical effect of quickly and effectively testing complex test data under the WCF framework through automatically constructed test scripts.

[0065] Embodiment 2

[0066] Figure 2 : is a structural block diagram of a test script construction device provided in an embodiment of the present invention. The device is used to execute the test script construction method provided in any of the above embodiments, and the device can be optionally implemented in software or hardware. The device includes:

[0067] An acquisition module 11 is used to acquire the data to be tested in a preset standard format, wherein the data to be tested corresponds to at least one request;

[0068] The parsing module 12 is used to parse the test data in the preset standard format to obtain a parsing result;

[0069] A merging module 13, used to determine the test data belonging to the same request in the parsing result according to a preset merging rule, and complete the merging of the test data of the same request to update the test data of each request;

[0070] The script generating module 14 is used to add all the requested updated test data to a preset test script framework to generate a test script.

[0071] Optionally, the parsing module 12 is used to parse the test data in the standard JSON format to obtain at least one dictionary, each dictionary corresponding to a request; and extract the test data corresponding to the request from each dictionary according to preset keywords to obtain a parsing result.

[0072] Optionally, the device also includes a storage module, which is used to output the test data extracted from each dictionary to a pandas module for storage, and the pandas module stores the test data of each dictionary in a dataframe format.

[0073] Optionally, the merging module 13 is used to divide the test data segments corresponding to the same request in the parsing results into a group according to the principle that the index numbers of the same request are the same; convert the parsing results in each group into a text format, and preprocess the parsing results in the text format to update the parsing results of each group; complete the merging of all test data segments in the same group to update the test data of each group, thereby obtaining the test data of each request.

[0074] Optionally, if the merging module 13 detects that the ERR level is lower than a preset alarm threshold, the format conversion continues to be performed; otherwise, if the merging module 13 detects that the ERR level is higher than or equal to the preset alarm threshold, the current format conversion process is interrupted.

[0075] Optionally, the script generating module 14 is used to add the updated test data of all requests belonging to the same business content to the same thread group of a preset test script framework to generate a test script.

[0076] The technical solution of the test script construction device provided by the embodiment of the present invention obtains the test data in a preset standard format through an acquisition module, and the test data corresponds to at least one request; the test data in the preset standard format is parsed by a parsing module to obtain a parsing result, thereby solving the problem of low accuracy of the parsing result of the test data in the original format; the test data belonging to the same request in the parsing result is determined by a merging module according to a preset merging rule, and the merging of the test data of the same request is completed to update the test data of each request; the updated test data of all requests is added to a preset test script framework to generate a test script through a script generation module, thereby achieving the purpose of quickly generating test scripts corresponding to the test data of all requests through the preset test script framework, and achieving the technical effect of quickly and effectively testing complex test data under the WCF framework through automatically constructed test scripts.

[0077] The test script construction device provided in the embodiment of the present invention can execute the test script construction method provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.

[0078] Embodiment 3

[0079] Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention is shown in FIG. Figure 3 As shown, the device includes a processor 201, a memory 202, an input device 203, and an output device 204; the number of processors 201 in the device can be one or more. Figure 3 A processor 201 is taken as an example; the processor 201, the memory 202, the input device 203 and the output device 204 in the device can be connected by a bus or other means. Figure 3 The example of connecting through bus is taken in the following.

[0080] The memory 202, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the test script construction method in the embodiment of the present invention (for example, the acquisition module 11, the parsing module 12, the merging module 13 and the script generation module 14). The processor 201 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 202, that is, implements the above-mentioned test script construction method.

[0081] The memory 202 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 202 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 202 may further include a memory remotely arranged relative to the processor 201, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0082] The input device 203 may be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the device.

[0083] The output device 204 may include a display device such as a display screen, for example, a display screen of a user terminal.

[0084] Embodiment 4

[0085] An embodiment of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to execute a test script construction method when executed by a computer processor, the method comprising:

[0086] Acquire data to be tested in a preset standard format, where the data to be tested corresponds to at least one request;

[0087] Parsing the data to be tested in the preset standard format to obtain a parsing result;

[0088] Determine the test data belonging to the same request in the parsing result according to a preset merging rule, and complete the merging of the test data of the same request to update the test data of each request;

[0089] The updated test data of all requests are added to a preset test script framework to generate a test script.

[0090] Of course, the computer executable instructions of a storage medium including computer executable instructions provided by an embodiment of the present invention are not limited to the operations of the method described above, but can also execute related operations in the test script construction method provided by any embodiment of the present invention.

[0091] Through the above description of the implementation method, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (RandomAccess Memory, referred to as RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the test script construction method described in each embodiment of the present invention.

[0092] It is worth noting that in the embodiment of the above-mentioned test script construction device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0093] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A test script construction method, characterized in that: include: Acquire data to be tested in a preset standard format, where the data to be tested corresponds to at least one request; Parsing the data to be tested in the preset standard format to obtain a parsing result; Determine the test data belonging to the same request in the parsing result according to a preset merging rule, and complete the merging of the test data of the same request to update the test data of each request; Adding all the updated requested test data to a preset test script framework to generate a test script; The determining the test data belonging to the same request in the parsing result according to the preset merging rule, and completing the merging of the test data of the same request to update the test data of each request, includes: According to the principle that the index number of the same request is the same, the test data segments corresponding to the same request in the parsing result are divided into one group; Convert the parsing results in each group into a text format, and pre-process the parsing results in the text format to update the parsing results in each group; The test data segments in all the same groups are merged to update the test data of each group, thereby obtaining the test data for each request.

2. The method according to claim 1, characterized in that The preset standard format is a standard JSON format. Accordingly, the parsing of the test data in the preset standard format to obtain a parsing result includes: Parse the test data in standard JSON format to obtain at least one dictionary, each dictionary corresponds to a request; The test data corresponding to the request is extracted from each dictionary according to the preset keywords to obtain the parsing result.

3. The method according to claim 2, characterized in that The method of extracting the test data corresponding to the request from each dictionary according to the preset keywords to obtain the parsing result also includes: The test data extracted from each dictionary is output to the pandas module for storage, and the pandas module stores the test data of each dictionary in a dataframe format.

4. The method according to claim 1, characterized in that: The pre-processing comprises: The first target content of the parsing result in the text format is replaced and the second target content is escaped.

5. The method according to claim 4, characterized in that While converting the parsing result into a text format, it also includes: If the ERR level is detected to be lower than the preset alarm threshold, the format conversion continues; otherwise, if the ERR level is detected to be higher than or equal to the preset alarm threshold, the current format conversion process is interrupted.

6. The method according to any one of claims 1 to 5, characterized in that: The preset test script framework includes at least one thread group, the data to be tested corresponds to at least one business content, each business content corresponds to at least one request, and the updated test data of all requests is added to the preset test script framework to generate a test script, including: The updated test data of all requests belonging to the same business content are added to the same thread group of the preset test script framework to generate a test script.

7. A test script construction device, characterized in that: include: An acquisition module, used for acquiring the data to be tested in a preset standard format, wherein the data to be tested corresponds to at least one request; A parsing module, used for parsing the data to be tested in the preset standard format to obtain a parsing result; A merging module, used to determine the test data belonging to the same request in the parsing result according to a preset merging rule, and complete the merging of the test data of the same request to update the test data of each request; A script generation module, used for adding all the requested updated test data to a preset test script framework to generate a test script; The merging module is specifically used to group the test data segments corresponding to the same request in the parsing results according to the principle that the index numbers of the same request are the same; convert the parsing results in each group into a text format, and pre-process the parsing results in the text format to update the parsing results of each group; The test data segments in all the same groups are merged to update the test data of each group, thereby obtaining the test data for each request.

8. A computer device, characterized in that: The computer device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the test script construction method as described in any one of claims 1-6.

9. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the test script construction method according to any one of claims 1 to 6 when executed by a computer processor.

Citation Information

Patent Citations

  • Interface test method and device, and computer device

    CN109474488A

  • Method, system and device for merging request group integration

    CN111857802A