Method and apparatus for generating test case records
By automatically generating test case records, the bottleneck of manual writing of test cases is solved, the efficient use of automated test platforms is achieved, labor costs are reduced and the correctness of the test sequence is ensured.
Patent Information
- Application Number
- CN202210224740.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-07
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2042-03-07
AI Technical Summary
The existing automated test platform needs to manually write test cases before use, resulting in high labor costs and becoming a bottleneck for promotion and application.
By obtaining test message data, grouping and determining the upstream and downstream relationship of interface packets, test case records are automatically generated. The test case records have execution order and are directly used to generate test cases of the test platform.
Reduces the need to write test cases manually, reduces labor costs, and ensures that test cases are executed in the correct order, improving testing efficiency.
Smart Images

Figure CN114416597B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a method and device for generating test case records. Background Art
[0002] An automated test platform can significantly improve the efficiency of the test process. However, before using the test platform for testing, testers need to write test cases on the test platform according to the requirements of business testing. The writing of test cases consumes a large amount of human resources, which has become a bottleneck in the actual popularization and application of the automated test platform. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a method and device for generating test case records, which can automatically generate test case records. The test case records can be used to generate test cases for the test platform, so that there is no need to manually write test cases in the test platform, reducing the human resources required for using the test platform.
[0004] In a first aspect, an embodiment of the present invention provides a method for generating a test case record, including:
[0005] Obtaining test message data for performing business testing;
[0006] Grouping the test message data to obtain at least one interface group;
[0007] Determining the grouping parameter values of each interface group, and determining the upstream and downstream relationships of each interface group according to the grouping parameter values;
[0008] For each interface group: generating a test case record corresponding to the interface group; wherein, the test case record is used to generate test cases in the test platform, and the test case record has an execution order, and the execution order is determined by the upstream and downstream relationships of the interface group.
[0009] Optionally, the grouping the test message data to obtain at least one interface group includes:
[0010] Parsing the test message data to generate plaintext message data;
[0011] Obtaining the message information of the test message data from the plaintext message data, where the message information includes at least one of the following: time stamp, request header content, and link address;
[0012] Grouping the test message data according to the message content to obtain at least one interface group.
[0013] Optionally, the test case record includes a plurality of use case keywords;
[0014] Generating the test case record corresponding to the interface group includes:
[0015] Determining the mapping relationship between the target parameters and the use case keywords;
[0016] For each use case keyword in the test case record: according to the mapping relationship, determine the current parameter corresponding to the current use case keyword segment from the multiple target parameters of the interface group; determine the value of the current parameter as the value of the current use case keyword.
[0017] Optionally, before determining the mapping relationship between the target parameters and the use case keywords, it further includes:
[0018] Receiving a matching instruction input by the user, where the matching instruction is used to determine the use case keywords corresponding to each target parameter;
[0019] Generating the mapping relationship between the target parameters and the use case keywords according to the matching instruction.
[0020] Optionally, generating the test case record corresponding to the interface group includes:
[0021] Determining the target execution order of the test case record according to the upstream and downstream relationships of the interface group; among them, the execution order of the test case record corresponding to the upstream group of the interface group is before the target execution order, and the execution order of the test case record corresponding to the downstream group of the interface group is after the target execution order.
[0022] Optionally, before generating the test case record corresponding to the interface group, it further includes:
[0023] Generating interface request data according to the multiple target parameter values of the interface group;
[0024] Sending the interface request data and receiving the interface return data returned by the interface request data;
[0025] Determining whether the interface request data meets the preset conditions according to the interface return data;
[0026] When the interface request data meets the preset conditions, execute the steps of generating the test case record corresponding to the interface group.
[0027] Optionally, after generating the test case record corresponding to the interface group, it further includes:
[0028] Displaying the test case record and receiving the editing operation of the user on the test case record;
[0029] Process the test case record according to the editing operation;
[0030] Import the processed test case record into the test platform.
[0031] In a second aspect, an embodiment of the present invention provides a test case record generation device, which is applied to a client and includes:
[0032] A data acquisition module, configured to acquire test message data for business testing;
[0033] A grouping module, configured to group the test message data to obtain at least one interface group;
[0034] A relationship determination module, configured to determine the grouping parameter values of each interface group, and determine the upstream and downstream relationships of each interface group according to the grouping parameter values;
[0035] A record generation module, configured to, for each interface group: generate a test case record corresponding to the interface group; wherein, the test case record is used to generate test cases in the test platform, and the test case record has an execution order, and the execution order is determined by the upstream and downstream relationships of the interface group.
[0036] In a third aspect, an embodiment of the present invention provides an electronic device, including:
[0037] One or more processors;
[0038] A storage device, configured to store one or more programs,
[0039] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0040] In a fourth aspect, an embodiment of the present invention provides a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, the method described in any of the above embodiments is implemented.
[0041] One embodiment of the above invention has the following advantages or beneficial effects: According to the test message data for business testing, test case records can be automatically generated. The test case records can be used to generate test cases in the test platform, so that there is no need to manually write test cases in the test platform, reducing the labor cost required to use the test platform.
[0042] In addition, according to the upstream and downstream relationships of each interface group in the test message data, the execution order of the test case records is determined. Thus, each test case generated according to the interface group in the test platform can be tested in the correct execution order.
[0043] The further effects of the above-mentioned non-conventional optional manner will be described below in combination with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The drawings are used to better understand the present invention and do not constitute an improper limitation to the present invention. Among them:
[0045] Figure 1 is a schematic diagram of an exemplary application scenario to which an embodiment of the present invention can be applied;
[0046] Figure 2 is a schematic diagram of the flow of a method for generating a test case record provided by an embodiment of the present invention;
[0047] Figure 3 is a schematic diagram of a form for recording a test case record provided by an embodiment of the present invention;
[0048] Figure 4 is a schematic diagram of the flow of another method for generating a test case record provided by an embodiment of the present invention;
[0049] Figure 5 is a schematic diagram of the interaction process of an interface test case conversion tool provided by an embodiment of the present invention;
[0050] Figure 6 is a schematic diagram of the structure of a device for generating a test case record provided by an embodiment of the present invention;
[0051] Figure 7 is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing the embodiments of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0052] The following describes exemplary embodiments of the present invention with reference to the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, the description below omits the description of well-known functions and structures.
[0053] Figure 1 is a schematic diagram of an exemplary application scenario to which an embodiment of the present invention can be applied. As Figure 1 shown, the system architecture 100 may include a test device 101, a network 102, and a server 103. The network 102 is used to provide a medium for a communication link between the test device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0054] Testers use the test device 101 to conduct business tests on the systems or services deployed in the server 105. The test device 101 obtains test message data for conducting business tests, groups the test message data, and determines the upstream and downstream relationships of each interface group; generates test case records that can be used to generate in the test platform. The execution order of the test case records is determined by the upstream and downstream relationships of the interface groups. The test device 101 can be a mobile phone, a server, a notebook, a tablet computer, a laptop computer, and so on.
[0055] It should be noted that the method for generating test case records provided by the embodiments of the present invention is generally executed by the test device 101. Correspondingly, the device for generating test case records is generally set in the test device 101.
[0056] It should be noted that the method or device for generating test case records provided by the embodiments of the present invention can also be applied to terminal devices or servers other than the test device 101, as long as the terminal device or the server can listen to and obtain the message data sent and received on the test device 101.
[0057] It should be understood that Figure 1 the numbers of terminal devices, networks, and servers in
[0058] Figure 2 is a schematic diagram of the process of a method for generating test case records provided by an embodiment of the present invention. As Figure 2 shown, the method includes:
[0059] Step 201: Obtain test message data for conducting business tests.
[0060] Testers use the test device to conduct business tests on front-end applications such as networks or apps or interface services. The terminal devices or servers deployed in the solutions of the embodiments of the present invention can listen to and obtain the message data sent and received on the test device. The test message data is the relevant message data sent by testers for business tests.
[0061] Step 202: Group the test message data to obtain at least one interface group.
[0062] Message data is a data stream used for transmission on the network and cannot be directly read. For example, an http message is a data stream based on the tcp protocol and cannot be directly read. Therefore, it is necessary to convert the test message data into message data, that is, convert the data stream into a string for subsequent processing.
[0063] The test message data includes multiple test request messages, and the test message data can be grouped in various ways. The link address requested by each test request message can be obtained, and the test message data can be grouped according to the requested link address. If the requested link addresses are different, the corresponding interface groups of the test request messages are also different. Each test request message can also be assigned to a different interface group.
[0064] In an embodiment of the present invention, grouping the test message data to obtain at least one interface group includes: parsing the test message data to generate plaintext message data; obtaining the message information of the test message data from the plaintext message data, and the message information includes at least one of the following: time stamp, request header content, and link address; grouping the test message data according to the message content to obtain at least one interface group. By analyzing the correlation relationships of data such as the time stamps and request header contents of each test request message, the requests in the data are grouped by interface according to the link address.
[0065] Step 203: Determine the grouping parameter values of each interface group, and determine the upstream and downstream relationships of each interface group according to the grouping parameter values.
[0066] When business personnel conduct business tests, they need to send each test message in the preset execution order. For example, for a login function, business personnel may need to send in sequence: a message to obtain the login SMS, a message to verify the login SMS, and a message to verify whether the user has logged in normally. If the sending order of the above three messages is chaotic, the test work may not be completed properly.
[0067] The upstream and downstream relationships represent the sending order of the test messages of each interface group. For example, if the first interface group is the upstream group of the second interface group and the third interface group is the downstream group of the second interface group, then when the tester conducts a business test, they need to first send the test messages in the first interface group, then send the test messages in the second interface group, and finally send the test messages in the third interface group.
[0068] The grouping parameter is a parameter related to the upstream and downstream relationships of the interface group. The grouping parameter value is the corresponding value of the grouping parameter. The grouping parameter can be set according to actual needs. These grouping parameter values have an associated order, and through these order associations, the upstream and downstream relationships of the interface groups can be determined. For example, the grouping parameter can be the requestId in the response part of the message and the requestId in the header part. The requestId in the response part of the downstream interface is the same as the requestId in the header part of the upstream interface. Through the above relationships, the upstream and downstream relationships between each interface group can be determined.
[0069] Step 204: For each interface group, generate a test case record corresponding to the interface group; wherein, the test case record is used to generate test cases in the test platform.
[0070] The test case record consists of multiple case keywords. The case keywords can be set according to the fields in the test platform or actual requirements. The case keywords can include: link address, port number, access path, header, body, etc. Through the test case record, test cases in the test platform can be generated without manually writing each test case.
[0071] The test case record has an execution order, and the execution order is determined by the upstream and downstream relationships of the interface groups. The execution order of the test case record corresponding to the upstream group of the interface group is before the target execution order, and the execution order of the test case record corresponding to the downstream group of the interface group is after the target execution order. In this way, it is ensured that the test cases generated in the test platform according to the test case record can complete the test in the correct execution order.
[0072] The test case record can be stored in excel, csv, txt, and various types of databases. Figure 3 A schematic diagram of a form for recording test case records provided by an embodiment of the present invention is as follows. Figure 3 As shown, each test case record may include fields such as link address, port number, access path, header, body, etc. The test case record is stored in an excel file, and the excel file can be directly imported into the test platform to generate the test cases corresponding to the excel file in the test platform.
[0073] In the embodiment of the present invention, according to the test message data for business testing, test case records can be automatically generated. The test case record can be used to generate test cases in the test platform, so that there is no need to manually write test cases in the test platform, reducing the labor cost required for using the test platform.
[0074] In addition, according to the upstream and downstream relationships of each interface group in the test message data, the execution order of the test case record is determined. Then, according to the execution order of the test case record, the execution order of each test case in the test platform is determined. Thus, it is ensured that each test case in the test platform is tested in the correct execution order.
[0075] Figure 4 A schematic diagram of the process of another method for generating test case records provided by an embodiment of the present invention is as follows. Figure 4 As shown, the method includes:
[0076] Step 401: Obtain test message data for business testing.
[0077] Step 402: Group the test message data to obtain at least one interface group.
[0078] Step 403: Determine the grouping parameter values of each interface group, and based on the grouping parameter values, determine the upstream and downstream relationships of each interface group.
[0079] Step 404: Determine the mapping relationship between the target parameters and the use case keywords.
[0080] The target parameter is a field from which a value can be extracted from the test message data. The target parameters may include: link address, port number, access path, header, body, etc. The use case keywords are the fields involved in the test cases in the test platform. The use case keywords may include: protocol type, request method, port number, access path, header, body, response, etc.
[0081] The mapping relationship is used to determine the corresponding relationship between the target parameters and the use case keywords. For example, the target parameter header corresponds to the use case keyword parameter header.
[0082] In an embodiment of the present invention, before determining the mapping relationship between the target parameters and the use case keywords, it further includes: receiving a matching instruction input by the user, where the matching instruction is used to determine the use case keywords corresponding to each target parameter; generating the mapping relationship between the target parameters and the use case keywords according to the matching instruction. The keywords involved in the test cases in each test platform are different. By manually matching the target parameters with the use case keywords by the user, the finally generated test case record can contain correct data and can be used by the test platform.
[0083] Step 405: For each use case keyword in the test case record: according to the mapping relationship, determine the current parameter corresponding to the current use case keyword field from the multiple target parameters of the interface group; determine the value of the current parameter as the value of the current use case keyword.
[0084] Step 406: Determine the target execution order of the test case record according to the upstream and downstream relationships of the interface groups.
[0085] The test case record has an execution order, and the execution order is determined by the upstream and downstream relationships of the interface groups. The execution order of the test case record corresponding to the upstream group of the interface group is before the target execution order, and the execution order of the test case record corresponding to the downstream group of the interface group is after the target execution order. In this way, it is ensured that the test cases generated according to the test case record in the test platform can complete the test in the correct execution order.
[0086] In an embodiment of the present invention, the values of each keyword in the test case record are determined by using the mapping relationship between the target parameter and the use case keyword. Then, according to the upstream and downstream relationships of the interface grouping, the target execution order of the test case record is determined. It is ensured that the test cases generated in the test platform according to the test case record can send test messages with correct content in a predetermined order to complete relevant tests.
[0087] In an embodiment of the present invention, before generating the test case record corresponding to the interface grouping, it further includes: generating interface request data according to multiple target parameter values of the interface grouping; sending the interface request data and receiving the interface return data returned by the interface request data; determining whether the interface request data meets the preset conditions according to the interface return data; and when the interface request data meets the preset conditions, performing the step of generating the test case record corresponding to the interface grouping.
[0088] The preset conditions can be set according to specific requirements. The preset conditions may include: whether the interface request data is sent successfully, whether the interface return data is received successfully, whether the status code in the interface request data is 200, whether the interface return data contains preset field values, etc.
[0089] Before generating the test case record corresponding to the interface grouping, first generate and send the interface request data through the extracted multiple target parameter values. When the interface request data meets the preset conditions, perform the step of generating the test case record corresponding to the interface grouping to ensure that the generated test case record contains correct content and has a preset test effect.
[0090] In an embodiment of the present invention, after generating the test case record corresponding to the interface grouping, it further includes: displaying the test case record and receiving an editing operation of the user on the test case record; processing the test case record according to the editing operation; and importing the processed test case record into the test platform.
[0091] Due to various factors, various errors are inevitable in the generated test case record. After generating the test case record corresponding to the interface grouping, display the test case record and provide an editing function for the user. The user further ensures the correctness of the test cases generated in the test platform by editing the generated test case record.
[0092] An embodiment of the present invention further provides an interface test case conversion tool. Figure 5 It is a schematic diagram of an interaction process of an interface test case conversion tool provided by an embodiment of the present invention. As Figure 5As shown, when testers conduct manual testing, the tool provided by the embodiments of the present invention can obtain the interface test behaviors generated during the testing process; based on the interface test behaviors, operations such as protocol parsing, data parsing, and interaction analysis are performed; test case records are generated, and the test case records are imported into the test platform. Using the conversion tool provided by the embodiments of the present invention, users can automatically generate test cases in the test platform through the following steps:
[0093] Step S01: The user exports the automated test case template from the automated platform.
[0094] Step S02: The user configures the keywords of the automated platform test case template into the field mapping table of this tool. If this operation is not performed, the tool will generate a general automated test case template, and the user can adjust the fields according to the requirements of the automated platform when importing it later.
[0095] Step S03: Run this tool on the proxy computer during front-end business testing such as Web or app, or interface testing.
[0096] Step S04: The user starts the front-end or interface test operation, and this tool automatically converts the test data into automated test cases.
[0097] The conversion process includes:
[0098] ① The program will listen to the HTTP packet data on the network card of the proxy computer and parse the HTTP packet into plain text.
[0099] ② By analyzing the correlation relationships of data such as the time stamps and request header contents of the HTTP packets, the requests in the data are grouped by interface according to the URL.
[0100] ③ The upstream and downstream transmitted parameters of the request content and return content within the group are extracted and associated through the keyword regular matching algorithm.
[0101] ④ Assertion judgments are made through the common keywords and structures in the preset assertion expressions. Assertions are usually defined in the program. For example: assertions are used to determine whether it is in json format, whether the status code is 200 or not 40x, 50x, and whether it contains flag fields such as success.
[0102] ⑤ The parsed data is constructed into interface request data for replay testing.
[0103] ⑥ The parsed data is converted into automated test cases through the keyword field mapping relationship.
[0104] ⑥ Call an external interface for data import, and at the same time generate an automated test case file.
[0105] Step S05: This tool will call the external interface of the test platform to import the parsed test case data into the test platform. After the import, the test cases can be reviewed and edited on the platform. Users can also import the automated test cases into the test platform in the way of file import. Before the import, users can review and edit the test cases.
[0106] In the embodiment of the present invention, this tool has a data parsing function of converting communication data into plaintext data, a data association function of automatically organizing HTTP message data into regular interface interaction data, and a test case conversion function of converting interface interaction data into automated test cases through preset templates and keyword field matching.
[0107] Using the test case conversion tool provided by the embodiment of the present invention, testers can directly generate automated test cases while performing interface tests, realizing the automatic conversion of the interface manual test process into automated test cases, saving the labor cost of editing and debugging automated test cases, and improving the efficiency of generating automated test cases. In addition, testers do not need to pay attention to the parameter changes in the automated test cases generated by this tool, reducing manual writing errors, and the execution pass rate of the generated automated test cases is high. This tool generates importable automated test cases in the way of data conversion, does not depend on the automated platform for test case operation, and reduces the operation difficulty of testers.
[0108] Figure 6 It is a schematic structural diagram of a test case record generation device provided by an embodiment of the present invention. As Figure 6 shown, the device includes:
[0109] A data acquisition module 601, configured to acquire test message data for business testing;
[0110] A grouping module 602, configured to group the test message data to obtain at least one interface group;
[0111] A relationship determination module 603, configured to determine the grouping parameter values of each interface group, and determine the upstream and downstream relationships of each interface group according to the grouping parameter values;
[0112] A record generation module 604, configured to, for each interface group: generate a test case record corresponding to the interface group; wherein, the test case record is used to generate test cases in the test platform, and the test case record has an execution order, and the execution order is determined by the upstream and downstream relationships of the interface group.
[0113] Optionally, the grouping module 602 is specifically configured to:
[0114] Parse the test message data to generate plaintext message data;
[0115] Obtain the message information of the test message data from the plaintext message data, where the message information includes at least one of the following: time stamp, request header content, and link address;
[0116] Group the test message data according to the message content to obtain at least one interface group.
[0117] Optionally, the test case record includes multiple case keywords;
[0118] The record generation module 604 is specifically configured to:
[0119] Determine the mapping relationship between the target parameters and the case keywords;
[0120] For each case keyword in the test case record: according to the mapping relationship, determine the current parameter corresponding to the current case keyword segment from the multiple target parameters of the interface group; determine the value of the current parameter as the value of the current case keyword.
[0121] Optionally, the device further includes:
[0122] A receiving module 605, configured to receive a matching instruction input by a user, where the matching instruction is used to determine the case keyword corresponding to each target parameter;
[0123] Generate the mapping relationship between the target parameters and the case keywords according to the matching instruction.
[0124] Optionally, the record generation module 604 is specifically configured to:
[0125] Determine the target execution order of the test case record according to the upstream and downstream relationships of the interface group; wherein, the execution order of the test case record corresponding to the upstream group of the interface group is before the target execution order, and the execution order of the test case record corresponding to the downstream group of the interface group is after the target execution order.
[0126] Optionally, the device further includes:
[0127] A detection module 606, configured to generate interface request data according to the multiple target parameter values of the interface group;
[0128] Send the interface request data and receive the interface return data returned by the interface request data;
[0129] Determine whether the interface request data meets a preset condition according to the interface return data.
[0130] Optionally, the device further includes:
[0131] An editing module 607, configured to display the test case record and receive an editing operation of a user on the test case record;
[0132] Process the test case record according to the editing operation;
[0133] Import the processed test case record into a test platform.
[0134] An embodiment of the present invention provides an electronic device, including:
[0135] One or more processors;
[0136] A storage device, configured to store one or more programs,
[0137] When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any of the above embodiments.
[0138] Reference is made below to Figure 7 , which shows a schematic structural diagram of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is merely an example and should not impose any limitation on the functions and usage scope of the embodiments of the present invention.
[0139] As Figure 7 shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage section 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0140] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as required. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as required, so that a computer program read from it can be installed into the storage section 708 as required.
[0141] In particular, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium. The computer program contains program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above functions defined in the system of the present invention are executed.
[0142] It should be noted that the computer-readable medium shown in the present invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, the computer-readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system, apparatus, or device. In the present invention, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries the computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0143] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code, and the above-mentioned module, segment of a program, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, as well as combinations of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0144] The modules involved in the embodiments of the present invention can be implemented in software or in hardware. The described modules can also be set in a processor. For example, they can be described as: a data acquisition module, a grouping module, a relationship determination module, and a record generation module. Among them, the names of these modules do not constitute a limitation to the module itself in some cases. For example, the data acquisition module can also be described as "a module for acquiring test packet data for business testing".
[0145] As another aspect, the present invention also provides a computer-readable medium, which can be included in the device described in the above embodiments; or can exist separately without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes:
[0146] Acquire test packet data for business testing;
[0147] Group the test packet data to obtain at least one interface group;
[0148] Determine the grouping parameter values of each interface group, and determine the upstream and downstream relationships of each interface group according to the grouping parameter values;
[0149] For each interface group: generate a test case record corresponding to the interface group; wherein the test case record is used to generate test cases in a test platform, and the test case record has an execution order, and the execution order is determined by the upstream and downstream relationships of the interface group.
[0150] According to the technical solution of the embodiment of the present invention, test case records can be automatically generated based on the test message data for business testing. These test case records can be used to generate test cases for the test platform, thus eliminating the need for manual writing of test cases in the test platform and reducing the labor cost required for using the test platform.
[0151] In addition, according to the upstream and downstream relationships of each interface group in the test message data, the execution order of the test case records is determined. Then, according to the execution order of the test case records, the execution order of each test case in the test platform is determined. Thus, it is ensured that each test case in the test platform is tested in the correct execution order.
[0152] The above specific implementation manners do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub - combinations and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for generating test case records, characterized in that, Including: Obtaining test message data for business testing; Grouping the test message data to obtain at least one interface group; wherein, the test message data includes multiple test request messages; The grouping the test message data to obtain at least one interface group includes: analyzing the correlation relationship between the time stamps and request header contents of each test request message, and grouping the test request messages in the test message data according to the link address; Determining the grouping parameter values of each interface group, and determining the upstream and downstream relationships of each interface group according to the grouping parameter values; For each interface group: generating a test case record corresponding to the interface group; wherein, the test case record is used to generate test cases in a test platform, and the test case record has an execution order, and the execution order is determined by the upstream and downstream relationships of the interface group.
2. The method according to claim 1, wherein The grouping the test message data to obtain at least one interface group includes: Parsing the test message data to generate plaintext message data; Obtaining the message information of the test message data from the plaintext message data, where the message information includes at least one of the following: time stamp, request header content, and link address; Grouping the test message data according to the message information to obtain at least one interface group.
3. The method according to claim 1, wherein The test case record includes multiple case keywords; The generating the test case record corresponding to the interface group includes: Determining the mapping relationship between the target parameters and the case keywords; For each case keyword in the test case record: according to the mapping relationship, determining the current parameter corresponding to the current case keyword segment from the multiple target parameters of the interface group; and determining the value of the current parameter as the value of the current case keyword.
4. The method according to claim 3, wherein Before determining the mapping relationship between the target parameters and the case keywords, it further includes: Receiving a matching instruction input by a user, where the matching instruction is used to determine the case keywords corresponding to each target parameter; Generating the mapping relationship between the target parameters and the case keywords according to the matching instruction.
5. The method according to claim 1, wherein The generating the test case record corresponding to the interface group includes: Determining the target execution order of the test case record according to the upstream and downstream relationships of the interface group; wherein, the execution order of the test case record corresponding to the upstream group of the interface group is before the target execution order, and the execution order of the test case record corresponding to the downstream group of the interface group is after the target execution order.
6. The method according to claim 1, characterized in that, Before generating the test case record corresponding to the interface group, it further includes: Generating interface request data according to the multiple target parameter values of the interface group; Sending the interface request data and receiving the interface return data returned by the interface request data; Determining whether the interface request data meets a preset condition according to the interface return data; When the interface request data meets the preset condition, performing the step of generating the test case record corresponding to the interface group.
7. The method according to claim 1, wherein After generating the test case record corresponding to the interface group, it further includes: Display the test case record and receive an editing operation from the user for the test case record; Process the test case record according to the editing operation; Import the processed test case record into the test platform.
8. A generating device for test case records, characterized in that, It includes: A data acquisition module for acquiring test message data for business testing; A grouping module for grouping the test message data to obtain at least one interface group; wherein, the test message data includes multiple test request messages; Specifically, the grouping module is configured to: group the test request messages in the test message data according to the link address by analyzing the time stamps of each test request message and the correlation relationship of the request header content; A relationship determination module for determining the grouping parameter values of each interface group and determining the upstream and downstream relationships of each interface group according to the grouping parameter values; A record generation module for generating, for each interface group, a test case record corresponding to the interface group; wherein, the test case record is used to generate test cases in the test platform, and the test case record has an execution order, and the execution order is determined by the upstream and downstream relationships of the interface group.
9. An electronic device, characterized in that, It includes: 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 method according to any one of claims 1-7.
10. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method according to any one of claims 1-7.
Citation Information
Patent Citations
Test Case Construction Method, Test Method, Apparatus, Equipment and Media
CN109308266A
Interface test method and device, electronic equipment and storage medium
CN112148601A
Interface automation test case generation method and system
CN113204491A