Data interaction testing method and device
By collecting real interaction data sets and building a transmission protocol structure, test data can be automatically acquired, solving the problems of low efficiency and accuracy in data interaction testing and achieving more efficient and accurate testing.
Patent Information
- Application Number
- CN202210143576.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-16
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-02-16
AI Technical Summary
The efficiency and accuracy of data interaction testing in existing technologies are low, and they mainly rely on manual writing of test data, which leads to low efficiency and prone to deviations.
Collect real interaction data sets, determine the transmission protocol structure, and based on this, obtain test data from the real interaction data sets. Construct test data by matching and converting format trees, and automate data interaction testing.
It improves the efficiency and accuracy of data interaction testing, reduces labor costs, ensures that test data is more consistent with real scenarios, and reduces errors caused by manual writing.
Smart Images

Figure CN114528206B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a data interaction testing method and device. Background Art
[0002] Currently, game development is divided into two main tasks: server-side development and client-side development. The server processes player data and provides game services, while the client presents player data on a graphical user interface. To ensure that the server-side game services and the client-side interface logic are properly aligned, joint debugging of the server and client is required, along with testing of data interaction between the client and server.
[0003] However, the test data used for data interaction testing in related technologies is relatively small and is mostly manually written, resulting in low test efficiency and accuracy. Currently, no effective solution has been proposed to address the above issues. Summary of the Invention
[0004] At least some embodiments of the present invention provide a data interaction testing method and apparatus to at least solve the technical problem of low testing efficiency and accuracy of data interaction testing methods in related technologies.
[0005] According to one embodiment of the present invention, a method for testing data interaction is provided, comprising: collecting a real interaction data set, wherein the real interaction data set is used to characterize the interaction data that actually occurs between multiple test devices; determining a transmission protocol structure between the multiple test devices; obtaining test data from the real interaction data set based on the transmission protocol structure; and testing the data interaction between the multiple test devices based on the test data.
[0006] Optionally, based on the transmission protocol structure, obtaining test data from the real interaction data set includes: determining the data structure of each real interaction data in the real interaction data set; matching the data structure of each real interaction data with the transmission protocol structure to obtain successfully matched interaction data; and determining the successfully matched interaction data as test data.
[0007] Optionally, matching the data structure of each real interaction data with the transmission protocol structure to obtain successfully matched interaction data includes: converting the data structure of each real interaction data into a tree structure to obtain a first format tree corresponding to each real interaction data; converting the transmission protocol structure into a tree structure to obtain a second format tree; and obtaining successfully matched interaction data based on the distance between the first format tree and the second format tree corresponding to each real interaction data.
[0008] Optionally, based on the distance between the first format tree and the second format tree corresponding to each real interaction data, obtaining the successfully matched interaction data includes: determining the degree of difference corresponding to each real interaction data based on the distance between the first format tree and the second format tree corresponding to each real interaction data, wherein the degree of difference is used to characterize the degree of difference between the data structure of each real interaction data and the transmission protocol structure; sorting each real interaction data in ascending order of the degree of difference to obtain sorted interaction data; and determining that a plurality of interaction data ranked at the top in the sorted interaction data are the successfully matched interaction data.
[0009] Optionally, testing data interaction between multiple test devices based on test data includes: receiving a request data packet sent by a target device among the multiple test devices; obtaining target test data in the test data that matches the request data packet; generating a response data packet corresponding to the request data packet based on the target test data; and sending the response data packet to the target device.
[0010] Optionally, obtaining target test data in the test data that matches the request data packet includes: determining a first protocol structure corresponding to the request data packet; and obtaining target test data in the test data, wherein the data structure of the target test data successfully matches the first protocol structure.
[0011] Optionally, generating a response data packet corresponding to the request data packet based on the target test data includes: determining a second protocol structure corresponding to the response data packet based on a protocol table corresponding to the target device; and encapsulating the target test data according to the second protocol structure to generate a response data packet.
[0012] Optionally, after obtaining test data from a real interaction data set based on a transmission protocol structure, the method further includes: outputting the test data; receiving feedback results corresponding to the test data, wherein the feedback results are used to characterize the results obtained by modifying the test data; and testing the data interaction between multiple test devices based on the test data and the feedback results.
[0013] According to one embodiment of the present invention, a data interaction testing device is also provided, including: an acquisition module for collecting a real interaction data set, wherein the real interaction data set is used to characterize the interaction data actually sent between multiple test devices; a determination module for determining the transmission protocol structure between multiple test devices; an acquisition module for acquiring test data from the real interaction data set based on the transmission protocol structure; and a testing module for testing the data interaction between multiple test devices based on the test data.
[0014] Optionally, the acquisition module includes: a structure determination unit, used to determine the data structure of each real interaction data in the real interaction data set; a matching unit, used to match the data structure of each real interaction data with the transmission protocol structure to obtain successfully matched interaction data; and a data determination unit, used to determine that the successfully matched interaction data is test data.
[0015] Optionally, the matching unit includes: a first conversion subunit, used to convert the data structure of each real interaction data into a tree structure to obtain a first format tree corresponding to each real interaction data; a second conversion subunit, used to convert the transmission protocol structure into a tree structure to obtain a second format tree; a matching subunit, used to obtain successfully matched interaction data based on the distance between the first format tree and the second format tree corresponding to each real interaction data.
[0016] Optionally, the matching sub-unit is also used to: determine the degree of difference corresponding to each real interaction data based on the distance between the first format tree and the second format tree corresponding to each real interaction data, wherein the degree of difference is used to characterize the degree of difference between the data structure of each real interaction data and the transmission protocol structure; sort each real interaction data in order from small to large according to the degree of difference to obtain sorted interaction data; and determine that the top multiple interaction data in the sorted interaction data are the interaction data with successful matching.
[0017] Optionally, the test module includes: a receiving unit for receiving a request data packet sent by a target device among multiple test devices; an acquiring unit for acquiring target test data in the test data that matches the request data packet; a generating unit for generating a response data packet corresponding to the request data packet based on the target test data; and a sending unit for sending the response data packet to the target device.
[0018] Optionally, the acquisition unit includes: a first determination subunit, used to determine a first protocol structure corresponding to the request data packet; and an acquisition subunit, used to acquire target test data in the test data, wherein the data structure of the target test data successfully matches the first protocol structure.
[0019] Optionally, the generation unit includes: a second determination subunit, used to determine the second protocol structure corresponding to the response data packet based on the protocol table corresponding to the target device; and a generation subunit, used to encapsulate the target test data according to the second protocol structure and generate a response data packet.
[0020] Optionally, the device also includes: an output module for outputting test data; a receiving module for receiving feedback results corresponding to the test data, wherein the feedback results are used to characterize the results obtained by modifying the test data; the testing module is also used to test the data interaction between multiple test devices based on the test data and the feedback results.
[0021] According to one embodiment of the present invention, a non-volatile storage medium is provided, in which a computer program is stored. The computer program is configured to execute any of the above-mentioned data interaction test methods when running.
[0022] According to one embodiment of the present invention, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute any of the above-mentioned data interaction testing methods.
[0023] In at least some embodiments of the present invention, a real interaction data set can be collected, and after determining the transmission protocol structure between multiple test devices, data can be obtained from the real interaction data set based on the transmission protocol structure to construct test data. The data obtained from the real data set can further be used to perform a data interaction test process, thereby achieving the test purpose of data interaction between multiple test devices. It is easy to notice that since the test data is automatically obtained from the real interaction data set, not only does it not need to be manually written, but more comprehensive and real test data can be obtained, and online problems encountered in self-inspection and testing can be avoided as much as possible, thereby achieving the technical effect of improving test efficiency and accuracy and reducing labor costs, thereby solving the technical problem of low test efficiency and accuracy of data interaction testing methods in related technologies. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0025] Figure 1 This is a hardware structure block diagram of a mobile terminal for a data interaction testing method according to an embodiment of the present invention;
[0026] Figure 2 is a flow chart of a data interaction testing method according to one embodiment of the present invention;
[0027] Figure 3a is a schematic diagram of a tree structure of the format of data sent from a client to a server according to one embodiment of the present invention;
[0028] Figure 3b is a schematic diagram of a tree structure of the format of data sent from a server to a client according to one embodiment of the present invention;
[0029] Figure 4 is a flow chart of an optional data interaction testing method according to one embodiment of the present invention;
[0030] Figure 5 It is a structural block diagram of a data interaction testing device according to one embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the embodiments described are only 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 making creative efforts should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] At present, the joint debugging work of the client and server mainly relies on the purely manual method of constructing test data on the server and client. However, there are the following problems with manually writing test data: for reused test data, each joint debugging needs to be manually written, which is repetitive, time-consuming, and inefficient; test data is sometimes written unreasonably and deviates from the actual situation, resulting in the omission of some interface layout performance problems; for tasks that rely on props and equipment from previous tasks, manual writing will result in omissions, resulting in the task being unable to execute normally and requiring re-modification, which consumes a lot of time; for test data whose display length is affected by fonts, the test data is often small in size and does not cover all situations, resulting in unreasonable layout of the graphical user interface and affecting the normal viewing of players; due to the high degree of mutual dependence between the server and client, sudden changes in the project are affected.
[0034] To address the above problems, the present invention provides a data interaction testing solution. By collecting actual interaction data and constructing test data according to the transmission protocol format, there is no need to manually write test data. The data volume is large and more in line with real scenarios, allowing developers to focus on function implementation rather than repeated confirmation of test data.
[0035] According to one embodiment of the present invention, a method for testing data interaction is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0036] The method embodiment can be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking running on a mobile terminal as an example, the mobile terminal can be a smartphone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, a game console, or other terminal devices. Figure 1 FIG. 1 is a hardware structure diagram of a mobile terminal for testing a data interaction method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 (the processor 102 may include but is not limited to a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microprocessor (MCU), a field-programmable logic device (FPGA), a neural network processor (NPU), a tensor processing unit (TPU), an artificial intelligence (AI) type processor, etc.) and a memory 104 for storing data. Optionally, the mobile terminal may further include a transmission device 106 for communication functions, an input and output device 108, and a display device 110. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0037] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the data interaction test method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above-mentioned data interaction test method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the mobile terminal 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.
[0038] The transmission device 106 is used to receive or send data via a network. A specific example of the aforementioned network may include a wireless network provided by the mobile terminal's communications provider. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0039] Inputs to the input / output devices 108 can come from a variety of human interface devices (HIDs). Examples include keyboards and mice, game controllers, and other specialized game controllers (e.g., steering wheels, fishing rods, dance mats, remote controls, etc.). Some HIDs provide not only input but also output, such as force feedback and vibration on game controllers and audio output on controllers.
[0040] The display device 110 may be, for example, a head-up display (HUD), a touch-screen liquid crystal display (LCD), and a touch display (also referred to as a "touch screen" or "touch display"). The LCD may enable a user to interact with the user interface of the mobile terminal. In some embodiments, the mobile terminal may have a graphical user interface (GUI), and the user may interact with the GUI by finger contacts and / or gestures on the touch-sensitive surface. The human-computer interaction functions herein may optionally include the following interactions: creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, sending and receiving emails, call interfaces, playing digital videos, playing digital music, and / or web browsing, etc. The executable instructions for executing the above-mentioned human-computer interaction functions are configured / stored in a computer program product or readable storage medium executable by one or more processors.
[0041] In a possible implementation, an embodiment of the present invention provides a data interaction testing method. Figure 2 FIG. 1 is a flow chart of a data interaction testing method according to one embodiment of the present invention. Figure 2 As shown, the method includes the following steps:
[0042] Step S202 : collecting a real interaction data set, wherein the real interaction data set is used to represent real interaction data occurring between multiple test devices.
[0043] The multiple test devices mentioned in the above steps can refer to data interaction that occurs in a real environment and requires joint debugging of the data interaction process. Generally, data interaction is performed between two or more devices. Therefore, the multiple test devices mentioned in the above steps can refer to two or more test devices. In a real environment, many types of devices need to be jointly debugged. The types of multiple test devices can be the same or different, such as clients or servers. In addition, the functions implemented by different test devices in different test scenarios are often different. For example, in a game development scenario, the multiple test devices mentioned above can be a game server and a game client, respectively.
[0044] The interaction data in the above steps can be specific data for data interaction between multiple test devices in a real environment. In different application scenarios, the specific types of interaction data are different. For example, still taking the game development scenario as an example, the above interaction data can be data for conventional game logic. For example, for game login, transaction, team formation and leaving, the corresponding interaction data can include player account, player name, item number, team size, etc.; the interaction data can also be data for different game play. For example, for a balloon popping game, the corresponding interaction data can include game score, game time, number of games, etc.; the interaction data can also be data for system messages. For example, for activity rewards sent by the system, the corresponding interaction data can include item number, money, quantity, etc.
[0045] To ensure that joint debugging is more realistic and avoid the various problems associated with manually written test data, in an embodiment of the present invention, when multiple test devices interact with each other in a real environment, the actual interaction data can be collected and stored in a database to facilitate subsequent joint debugging of multiple test devices. For example, using the game development scenario as an example, when the server is acting as a live server providing game services to the client, the interaction data between the server and the client can be downloaded and collected to construct a real interaction dataset.
[0046] Step S204: determining the transmission protocol structure between the multiple test devices.
[0047] The transmission protocol structure described in the preceding steps can be the protocol structure used to implement data exchange during joint debugging of multiple test devices. Joint debugging of multiple test devices often involves testing different functions, and different protocol structures are often specified for data exchange. To ensure that joint debugging is more realistic, the appropriate transmission protocol structure can be determined based on actual testing needs in different test scenarios.
[0048] In an optional embodiment, multiple test devices may negotiate a transmission protocol before interacting with each other. Each test device may store the agreed-upon communication protocol in a protocol table. The protocol table may be a description table of the communication protocol, and the multiple test devices may execute according to the table when interacting with each other. For example, still using the game development scenario as an example, the protocol table is shown in Table 1 below:
[0049] Table 1
[0050] Agreement Number Data format Returned protocol number 99001 LOGIN:{uid:string,password:string} 12345
[0051] The protocol number and data format here may be the number and structure corresponding to the protocol structure adopted by the received interactive data, and the returned protocol number may be the protocol format adopted by the data to be returned for the received data.
[0052] Step S206: Acquire test data from the real interaction data set based on the transmission protocol structure.
[0053] In an optional embodiment, different transmission protocol structures apply different interaction data. Therefore, based on the transmission protocol structure, interaction data with the same protocol structure can be obtained from the collected real interaction data set as test data. For example, using the protocol table shown in Table 1 above as an example, test data can be obtained from the real interaction data set based on the returned protocol number.
[0054] Step S208: testing the data interaction between the multiple test devices based on the test data.
[0055] In an optional embodiment, after obtaining test data from a real interaction data set, specific tests can be performed based on the test data, that is, interaction data can be directly constructed based on the test data and data interaction can be realized, and the corresponding test results can be further determined based on whether different test devices feed back expected data.
[0056] By adopting the above-mentioned embodiment of the present invention, a real interaction data set can be collected, and after determining the transmission protocol structure between multiple test devices, data can be obtained from the real interaction data set based on the transmission protocol structure to construct test data. The data obtained from the real data set can further be used to perform a data interaction test process, thereby achieving the test purpose of data interaction between multiple test devices. It is easy to notice that since the test data is automatically obtained from the real interaction data set, not only does it not need to be manually written, but more comprehensive and real test data can be obtained, and online problems encountered in self-testing and testing can be avoided as much as possible, thereby achieving the technical effect of improving test efficiency and accuracy and reducing labor costs, thereby solving the technical problem of low test efficiency and accuracy of data interaction testing methods in related technologies.
[0057] Optionally, based on the transmission protocol structure, obtaining test data from the real interaction data set includes: determining the data structure of each real interaction data in the real interaction data set; matching the data structure of each real interaction data with the transmission protocol structure to obtain successfully matched interaction data; and determining the successfully matched interaction data as test data.
[0058] Real interaction datasets contain a large amount of interaction data, and different interaction data have different protocol structures. To obtain more accurate test data, after determining the transmission protocol structure, we can use protocol structure matching to obtain test data from the real interaction dataset for data interaction testing. Matching here can mean that the protocol format is the same, or the protocol format similarity exceeds a certain threshold.
[0059] In one optional embodiment, to achieve rapid matching, the protocol structure corresponding to each interaction data in the real interaction dataset can be pre-determined, and the corresponding numbers can then be stored according to the protocol encoding. However, this solution requires the analysis and processing of a large amount of data in the real interaction dataset beforehand, followed by its re-storage. In another optional embodiment, to avoid re-storing the real interaction dataset, a different tree structure, called a format tree, can be constructed for each data format of the real interaction data. The transmission protocol structure can also be constructed as a tree structure. Based on this, the distance between different tree structures can be calculated using a tree edit distance algorithm, and the successfully matched interaction data can be determined based on this distance.
[0060] Optionally, matching the data structure of each real interaction data with the transmission protocol structure to obtain successfully matched interaction data includes: converting the data structure of each real interaction data into a tree structure to obtain a first format tree corresponding to each real interaction data; converting the transmission protocol structure into a tree structure to obtain a second format tree; and obtaining successfully matched interaction data based on the distance between the first format tree and the second format tree corresponding to each real interaction data.
[0061] After collecting a set of real interaction data, we can analyze the real interaction data and perform statistics based on the data structure to obtain interaction data with different data structures. Then, we can convert different data structures into format trees. For example, taking the data structure of a login operation as an example, the data structure starts with the LOGIN keyword and contains sub-keywords account password: password and role ID: uid. The corresponding format tree is realized as two nodes named uid and password connected under the LOGIN keyword.
[0062] For the first format tree and the second format tree, the difference between the two trees can be calculated using a tree edit distance algorithm known in related art. Specifically, the distance between the first format tree and the second format tree is calculated, with a closer distance indicating a smaller difference. In an optional embodiment, the 5% of second format trees with the smallest distances can be selected from all first format trees, and the actual interaction data corresponding to these selected second format trees is used as the successfully matched interaction data.
[0063] Through the above solution, the data structure and transmission protocol structure of the real interaction data can be converted into a format tree, and the successfully matched interaction data can be determined based on the distance between the format trees, so as to improve the data matching efficiency and reduce labor costs.
[0064] Optionally, based on the distance between the first format tree and the second format tree corresponding to each real interaction data, obtaining the successfully matched interaction data includes: determining the degree of difference corresponding to each real interaction data based on the distance between the first format tree and the second format tree corresponding to each real interaction data, wherein the degree of difference is used to characterize the degree of difference between the data structure of each real interaction data and the transmission protocol structure; sorting each real interaction data in ascending order of the degree of difference to obtain sorted interaction data; and determining that a plurality of interaction data ranked at the top in the sorted interaction data are the successfully matched interaction data.
[0065] The number of the top-ranked interaction data in the above step can be determined according to actual needs, for example, it can be 5% of the total number of all real interaction data, but is not limited thereto.
[0066] In an optional embodiment, after calculating the distance between two formatted trees using a tree edit distance algorithm, the degree of difference between the two formatted trees can be determined based on this distance, where a smaller distance indicates a lower degree of difference, and a larger distance indicates a higher degree of difference. Furthermore, the trees can be sorted in ascending order of degree of difference, and the top-ranked interaction data can be selected as the successfully matched interaction data. That is, the interaction data with the smallest degree of difference can be selected as the successfully matched interaction data, and then used as test data for testing.
[0067] For example, still taking the game development scenario as an example, the server and client formulate protocols, including C2S (client-to-server) protocols sent by the client to the server and S2C (server-to-client) protocols sent by the server to the client, as shown in Table 2 and Table 3 respectively. Table 2 is the C2S protocol and Table 3 is the S2C protocol:
[0068] Table 2
[0069]
[0070] Table 3
[0071]
[0072] The contents of the above agreement are explained as follows:
[0073] 99001 means: the format of the data sent from the client to the server is represented by a tree structure. Figure 3a As shown;
[0074] 77001 indicates the format of the data sent from the server to the client, which is represented by a tree structure. Figure 3b shown.
[0075] Through the above scheme, the degree of difference is determined by the distance between the format trees, and multiple interaction data with the smallest degree of difference are screened out as test data, thereby achieving the effect of improving the accuracy of test data determination.
[0076] Optionally, testing data interaction between multiple test devices based on test data includes: receiving a request data packet sent by a target device among the multiple test devices; obtaining target test data in the test data that matches the request data packet; generating a response data packet corresponding to the request data packet based on the target test data; and sending the response data packet to the target device.
[0077] In order to reduce the degree of coupling between multiple test devices, enable multiple test devices to independently develop and self-test, improve the saturation of team work tasks, and reduce the time coordination problems caused by disproportionate personnel ratios in the team, in an optional embodiment, an automatically called service can be pre-built. The principle of this service is to intercept the data sent by any test device (i.e., the above-mentioned target device), and then search for the corresponding reply protocol number in the protocol table corresponding to the test device according to the protocol number of the data, and then extract the corresponding target test data from the test data based on the reply protocol number, and finally directly return the response data packet generated based on the target test data in the local program to simulate the data interaction process between multiple test devices.
[0078] For example, let's continue with the game development scenario. Assuming the target device is the client, a data interaction test proceeds as follows: the client sends data for Protocol A, and the server returns data for Protocol B. A virtual service can be built locally on the client. When the client sends data for Protocol A, it first sends it to the virtual service. After receiving the data for Protocol A, the virtual service can query the protocol table based on the protocol number to determine which data for Protocol B needs to be returned. This allows Protocol B data to be constructed based on the actual interaction data and returned directly to the client, eliminating the need to send Protocol A data to the server and wait for the server to return Protocol B data.
[0079] Optionally, obtaining target test data in the test data that matches the request data packet includes: determining a first protocol structure corresponding to the request data packet; and obtaining target test data in the test data, wherein the data structure of the target test data successfully matches the first protocol structure.
[0080] In an optional embodiment, the request data packet can be parsed to determine the first protocol structure corresponding to the request data packet, and then the corresponding protocol number can be determined. The second protocol structure of the data to be returned can be further determined by querying the protocol table, and the target test data that meets the protocol structure can be filtered out from the test data.
[0081] Through the above solution, the target test data is screened by determining the first protocol structure corresponding to the request data packet, thereby achieving the effect of improving the screening efficiency and screening accuracy of the target test data.
[0082] Optionally, generating a response data packet corresponding to the request data packet based on the target test data includes: determining a second protocol structure corresponding to the response data packet based on a protocol table corresponding to the target device; and encapsulating the target test data according to the second protocol structure to generate a response data packet.
[0083] The protocol table in the above steps may be a protocol table as shown in Table 1 to Table 3, but is not limited thereto. All communication protocols used by multiple test devices for data interaction may be stored.
[0084] In an optional embodiment, the second protocol structure corresponding to the response data packet to be returned can be determined by querying the protocol tables shown in Tables 1 to 3 above, and the filtered target test data can be encapsulated according to the protocol structure to obtain the final response data packet and return it to the target device.
[0085] Through the above scheme, the second protocol structure is determined through the protocol table, and the second protocol structure is used for data encapsulation, which can reduce the uncertainty caused by joint debugging, avoid arbitrary modification of protocol data, and generate a response data packet that is more in line with the actual situation, thereby achieving the effect of improving the accuracy of the response data packet.
[0086] Optionally, after obtaining test data from a real interaction data set based on a transmission protocol structure, the method further includes: outputting the test data; receiving feedback results corresponding to the test data, wherein the feedback results are used to characterize the results obtained by modifying the test data; and testing the data interaction between multiple test devices based on the test data and the feedback results.
[0087] In an optional embodiment, in order to ensure more comprehensive coverage of the test data, the screened test data can be output to the test user for review, and the test user can edit it according to actual needs to obtain feedback results. Further testing can be performed based on the unmodified test data and the modified feedback results.
[0088] For example, still taking the game development scenario as an example, for the login operation protocol, the corresponding test data is as follows:
[0089]
[0090] Test users can confirm and modify the above data.
[0091] The following combination Figure 4 , still taking the game development scenario as an example, a preferred embodiment of the present invention is described in detail. Figure 4 As shown in the figure, the specific process is as follows: download the real interaction data of the official server to the database; organize the data stored in the database according to the data structure to obtain data with different data structures; parse the protocol tables of the server and client, and filter out data with the same or similar structures from the database as test data based on the established protocol structure; after the test starts, when the server or client sends protocol data, the protocol call service can connect the protocol data, find the corresponding callback protocol in the protocol table according to the sent protocol, and then extract the test data of this callback protocol, and then directly return the callback protocol data to simulate the communication between the client or server, thereby breaking away from the dependence of the client or server on each other.
[0092] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this 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, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0093] This embodiment also provides a data interaction test device, which is used to implement the above-mentioned embodiments and preferred embodiments. Details already described will not be repeated here. As used below, the terms "unit" and "module" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0094] Figure 5 FIG. 1 is a structural block diagram of a data interaction test device according to one embodiment of the present invention. Figure 5 As shown, the device includes:
[0095] The collection module 52 is configured to collect a real interaction data set, wherein the real interaction data set is used to represent the interaction data actually sent between multiple test devices.
[0096] The determination module 54 is configured to determine a transmission protocol structure between multiple test devices.
[0097] The acquisition module 56 is configured to acquire test data from a real interaction data set based on a transmission protocol structure.
[0098] The testing module 58 is configured to test data interaction between multiple testing devices based on the test data.
[0099] Optionally, the acquisition module includes: a structure determination unit, used to determine the data structure of each real interaction data in the real interaction data set; a matching unit, used to match the data structure of each real interaction data with the transmission protocol structure to obtain successfully matched interaction data; and a data determination unit, used to determine that the successfully matched interaction data is test data.
[0100] Optionally, the matching unit includes: a first conversion subunit, used to convert the data structure of each real interaction data into a tree structure to obtain a first format tree corresponding to each real interaction data; a second conversion subunit, used to convert the transmission protocol structure into a tree structure to obtain a second format tree; a matching subunit, used to obtain successfully matched interaction data based on the distance between the first format tree and the second format tree corresponding to each real interaction data.
[0101] Optionally, the matching sub-unit is also used to: determine the degree of difference corresponding to each real interaction data based on the distance between the first format tree and the second format tree corresponding to each real interaction data, wherein the degree of difference is used to characterize the degree of difference between the data structure of each real interaction data and the transmission protocol structure; sort each real interaction data in order from small to large according to the degree of difference to obtain sorted interaction data; and determine that the top multiple interaction data in the sorted interaction data are the interaction data with successful matching.
[0102] Optionally, the test module includes: a receiving unit for receiving a request data packet sent by a target device among multiple test devices; an acquiring unit for acquiring target test data in the test data that matches the request data packet; a generating unit for generating a response data packet corresponding to the request data packet based on the target test data; and a sending unit for sending the response data packet to the target device.
[0103] Optionally, the acquisition unit includes: a first determination subunit, used to determine a first protocol structure corresponding to the request data packet; and an acquisition subunit, used to acquire target test data in the test data, wherein the data structure of the target test data successfully matches the first protocol structure.
[0104] Optionally, the generation unit includes: a second determination subunit, used to determine the second protocol structure corresponding to the response data packet based on the protocol table corresponding to the target device; and a generation subunit, used to encapsulate the target test data according to the second protocol structure and generate a response data packet.
[0105] Optionally, the device also includes: an output module for outputting test data; a receiving module for receiving feedback results corresponding to the test data, wherein the feedback results are used to characterize the results obtained by modifying the test data; the testing module is also used to test the data interaction between multiple test devices based on the test data and the feedback results.
[0106] It should be noted that the above-mentioned modules, units, and sub-units can be implemented through software or hardware. For the latter, it can be implemented in the following ways, but not limited to this: the above-mentioned modules, units, and sub-units are all located in the same processor; or the above-mentioned modules, units, and sub-units are located in different processors in any combination.
[0107] An embodiment of the present invention further provides a non-volatile storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when running.
[0108] Optionally, in this embodiment, the non-volatile storage medium may be configured to store a computer program for executing the following steps:
[0109] S1, collecting a real interaction dataset, where the real interaction dataset is used to represent the actual interaction data between multiple test devices;
[0110] S2, determining a transmission protocol structure between multiple test devices;
[0111] S3, based on the transmission protocol structure, obtains test data from real interaction datasets;
[0112] S4, testing the data interaction between the multiple test devices based on the test data.
[0113] Optionally, in this embodiment, the above-mentioned non-volatile storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0114] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0115] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0116] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0117] S1, collecting a real interaction dataset, where the real interaction dataset is used to represent the actual interaction data between multiple test devices;
[0118] S2, determining a transmission protocol structure between multiple test devices;
[0119] S3, based on the transmission protocol structure, obtains test data from real interaction datasets;
[0120] S4, testing the data interaction between the multiple test devices based on the test data.
[0121] Optionally, specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0122] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0123] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0124] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0125] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0126] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc. Various media that can store program codes.
[0127] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A data interaction testing method, characterized in that: include: Collecting a real interaction data set, wherein the real interaction data set is used to represent actual interaction data occurring between a plurality of test devices, the plurality of test devices including at least a client and a server, and the interaction data between the plurality of test devices is used to represent interaction data between the client and the server; Determining a transmission protocol structure between the multiple test devices, wherein the transmission protocol structure is used to represent a protocol structure used to implement data interaction during joint debugging between the client and the server, wherein different functions of the joint debugging tests during joint debugging between the client and the server specify different transmission protocol structures for data interaction, and the different transmission protocol structures use different interaction data; Based on the transmission protocol structure, test data is obtained from the real interaction data set, wherein the test data is interaction data obtained from the real interaction data set and has the same protocol structure as the transmission protocol structure; Testing data interaction between the multiple test devices based on the test data to perform joint debugging on the client and the server; Among them, testing the data interaction between the multiple test devices based on the test data includes: receiving a request data packet sent by a target device among the multiple test devices, and the target device is used to represent the client or the server; obtaining target test data in the test data that matches the request data packet; based on the target test data, generating a response data packet corresponding to the request data packet; and sending the response data packet to the target device.
2. The method according to claim 1, characterized in that Based on the transmission protocol structure, obtaining the test data from the real interaction data set includes: Determining a data structure of each real interaction data in the real interaction data set; Matching the data structure of each real interaction data with the transmission protocol structure to obtain successfully matched interaction data; The successfully matched interaction data is determined to be the test data.
3. The method according to claim 2, characterized in that Matching the data structure of each real interaction data with the transmission protocol structure to obtain the successfully matched interaction data includes: Converting the data structure of each real interaction data into a tree structure to obtain a first format tree corresponding to each real interaction data; Converting the transmission protocol structure into a tree structure to obtain a second format tree; The successfully matched interaction data is obtained based on the distance between the first format tree and the second format tree corresponding to each real interaction data.
4. The method according to claim 3, characterized in that Obtaining the successfully matched interaction data based on the distance between the first format tree and the second format tree corresponding to each real interaction data includes: Based on the distance between the first format tree and the second format tree corresponding to each real interaction data, the difference degree corresponding to each real interaction data is determined, wherein the difference degree is used to represent the difference degree between the data structure of each real interaction data and the transmission protocol structure sorting each of the real interaction data in ascending order of the degree of difference to obtain sorted interaction data; Determine that a plurality of interaction data items that are ranked high among the sorted interaction data items are the successfully matched interaction data items.
5. The method according to claim 1, wherein Acquiring the target test data matching the request data packet from the test data includes: Determining a first protocol structure corresponding to the request data packet; The target test data in the test data is acquired, wherein a data structure of the target test data successfully matches the first protocol structure.
6. The method according to claim 1, characterized in that Generating a response data packet corresponding to the request data packet based on the target test data includes: Determining a second protocol structure corresponding to the response data packet based on a protocol table corresponding to the target device; The target test data is encapsulated according to the second protocol structure to generate the response data packet.
7. The method according to any one of claims 1 to 6, characterized in that After acquiring the test data from the real interaction data set based on the transmission protocol structure, the method further includes: outputting the test data; receiving a feedback result corresponding to the test data, wherein the feedback result is used to represent a result obtained by modifying the test data; Based on the test data and the feedback result, data interaction between the multiple test devices is tested.
8. A data interaction testing device, characterized in that: include: A collection module, configured to collect a real interaction data set, wherein the real interaction data set is used to represent interaction data actually sent between a plurality of test devices, the plurality of test devices including at least a client and a server, and the interaction data between the plurality of test devices is used to represent interaction data between the client and the server; a determination module, configured to determine a transmission protocol structure between the plurality of test devices, wherein the transmission protocol structure is used to represent a protocol structure used to implement data interaction during joint debugging between the client and the server, wherein different functions of the joint debugging tests during joint debugging between the client and the server specify different transmission protocol structures for data interaction, and the different transmission protocol structures apply different interaction data; an acquisition module, configured to acquire test data from the real interaction dataset based on the transmission protocol structure, wherein the test data is interaction data acquired from the real interaction dataset and having the same protocol structure as the transmission protocol structure; A testing module, configured to test data interaction between the plurality of test devices based on the test data, so as to perform joint debugging on the client and the server; Among them, the test module is also used to receive a request data packet sent by a target device among the multiple test devices, and the target device is used to represent the client or the server; obtain target test data in the test data that matches the request data packet; based on the target test data, generate a response data packet corresponding to the request data packet; and send the response data packet to the target device.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, wherein the computer program is configured to execute the data interaction testing method according to any one of claims 1 to 7 when running.
10. An electronic device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to run the computer program to execute the data interaction testing method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Test method and system for network application software
CN101001183A