CN111555935A - Data communication method, device, electronic equipment and storage medium - Google Patents
Data communication method, device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN111555935A CN111555935A CN202010341874.9A CN202010341874A CN111555935A CN 111555935 A CN111555935 A CN 111555935A CN 202010341874 A CN202010341874 A CN 202010341874A CN 111555935 A CN111555935 A CN 111555935A
- Authority
- CN
- China
- Prior art keywords
- communication data
- application
- data
- abnormal
- communication
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/08—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
- H04L43/0823—Errors, e.g. transmission errors
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/14—Arrangements for monitoring or testing data switching networks using software, i.e. software packages
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Environmental & Geological Engineering (AREA)
- Computer Security & Cryptography (AREA)
- Debugging And Monitoring (AREA)
Abstract
The embodiment of the application provides a data communication method, a data communication device, electronic equipment and a storage medium, wherein the method comprises the following steps: intercepting communication data sent by a first application to a second application; modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data; and sending the mock data to the second application. According to the data communication method, parameters in the communication data are modified, the abnormal communication data can be directly obtained, the efficiency of function testing can be increased, automatic mock of the communication data is achieved, the workload of testers is reduced, the influence of subjective factors of the testers is reduced, and the comprehensiveness of abnormal data verification is improved.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data communication method and apparatus, an electronic device, and a storage medium.
Background
At each stage of software development, communication between processes may agree on a fixed data format, which is usually mainly in a JSON (JavaScript Object Notation) format. For example, the server uses Java language, the client uses C language, the intermediate data format for the client to communicate with the server generally uses JSON format; furthermore, when communicating across platform applications in the same terminal, the format of the intermediate data also typically uses JSON format, where cross platform application communication refers to communication between applications of different language protocols. This fixed data format has formed the default specification in development.
The client needs to communicate with the server, and for data responded by the server, the client has different processing modes, for example, the roles of users in the application are divided into tourists, common users and member users, and for users with different identities, the corresponding functions in the client are also different, and most of the functions are stored by the server. However, in the process of converting communication data into JSON-format data, due to a problem of script compatibility, a problem of script editing, a problem of packet loss of communication data, and the like, a converted JSON-format data may be wrong, and if the JSON data responded by the server is wrong, a response abnormality, such as a breakdown, an abnormal page display, an error in on-terminal data, and the like may occur in the function of the client. The above abnormal situation may also occur when a cross-platform application communicates in the same terminal, for example, a Native (local) client communicates with a Hyper Text Markup Language (HTML) page.
If the abnormal response condition frequently occurs after the product is on line, the use experience of the user can be reduced, and the user loss is caused. Therefore, in order to reduce the cases of responding to the exception, it is desirable to make a correct response even if the JSON-format data has a problem, which requires that the collection of response data for the exception JSON-format data be completed in a functional test stage. However, in the functional test stage, only the general process of communication is simulated, and it is difficult to simulate the situation that the JSON format data has problems, resulting in low functional test efficiency.
Disclosure of Invention
An object of the embodiments of the present application is to provide a data communication method, an apparatus, an electronic device, and a storage medium, so as to increase efficiency of a function test. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a data communication method, where the method includes:
intercepting communication data sent by a first application to a second application, wherein the first application and the second application are applications in different terminals;
modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data; the preset mock rule is used for modifying parameters in the communication data;
sending the anomalous communication data to the second application.
Optionally, the intercepting communication data sent by the first application to the second application includes:
intercepting communication data in a JSON format sent from a first application to a second application by using a preset packet capturing tool, wherein the preset packet capturing tool is a Charles tool.
Optionally, the preset mock rule is used to modify at least one of an array, an object, a character type, and a boolean type in the communication data.
Optionally, the method further includes:
establishing a mapping relation between the generated abnormal communication data and the identifier of the communication data corresponding to the abnormal communication data, and storing the mapping relation and the abnormal communication data;
after intercepting communication data sent by the first application to the second application, the method further comprises:
judging whether abnormal communication data corresponding to the intercepted communication data are stored or not according to the identification of the intercepted communication data;
according to a preset mock rule, modifying parameters in the communication data to obtain abnormal communication data, wherein the method comprises the following steps:
and modifying parameters in the intercepted communication data according to a preset mock rule under the condition that the abnormal communication data corresponding to the intercepted communication data is not stored, so as to obtain the abnormal communication data.
Optionally, after determining whether the abnormal communication data corresponding to the currently intercepted communication data is stored according to the identifier of the currently intercepted communication data, the method further includes:
and if the abnormal communication data corresponding to the currently intercepted communication data is stored, sending the abnormal communication data corresponding to the currently intercepted communication data to the second application.
Optionally, after the sending the abnormal communication data to the second application, the method further includes:
and acquiring response data returned by the second application according to the abnormal communication data, and writing the response data into a log to perform abnormal analysis.
In a second aspect, an embodiment of the present application provides a data communication method, where the method includes:
intercepting communication data before a first application sends the communication data to a second application in a preset bridge communication mode, wherein the first application and the second application are applications on different platforms in the same terminal;
modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data, wherein the preset mock rule is used for modifying the parameters in the communication data;
and sending the abnormal communication data to the second application in the preset bridge communication mode.
Optionally, the preset mock rule is used to modify at least one of a parameter type, a parameter value, and a request time in the communication data.
Optionally, after the sending the abnormal communication data to the second application in the preset bridge communication manner, the method further includes:
and writing result data of the abnormal communication data executed by the second application into a log so as to perform abnormal analysis.
In a third aspect, an embodiment of the present application provides a data communication apparatus, where the apparatus includes:
the device comprises a communication data packet capturing module, a first application and a second application, wherein the communication data packet capturing module is used for intercepting communication data sent by the first application to the second application, and the first application and the second application are applications in different terminals;
the abnormal communication data generation module is used for modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data; the preset mock rule is used for modifying parameters in the communication data;
and the abnormal communication data sending module is used for sending the abnormal communication data to the second application.
Optionally, the communication data packet capturing module is specifically configured to intercept, by using a preset packet capturing tool, communication data in a JSON format sent by a first application to a second application, where the preset packet capturing tool is a Charles tool.
Optionally, the preset mock rule is used to modify at least one of an array, an object, a character type, and a boolean type in the communication data.
Optionally, the apparatus further comprises:
the abnormal communication data storage module is used for establishing a mapping relation between the generated abnormal communication data and the identifier of the communication data corresponding to the abnormal communication data, and storing the mapping relation and the abnormal communication data;
the data identification detection module is used for judging whether abnormal communication data corresponding to the intercepted communication data are stored or not according to the identification of the intercepted communication data;
the abnormal communication data generating module 702 is specifically configured to, when the abnormal communication data corresponding to the intercepted communication data is not stored, modify parameters in the intercepted communication data according to a preset mock rule to obtain the abnormal communication data.
Optionally, the apparatus further comprises: and the abnormal communication data acquisition module is used for sending the abnormal communication data corresponding to the currently intercepted communication data to the second application if the abnormal communication data corresponding to the currently intercepted communication data is stored.
Optionally, the apparatus further comprises: and the log acquisition module is used for acquiring response data returned by the second application according to the abnormal communication data and writing the response data into a log so as to perform abnormal analysis.
In a fourth aspect, an embodiment of the present application provides a data communication apparatus, where the apparatus includes:
the communication interception module is used for intercepting communication data before the first application sends the communication data to a second application in a preset bridge communication mode, wherein the first application and the second application are applications on different platforms in the same terminal;
the parameter modification module is used for modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data, wherein the preset mock rule is used for modifying the parameters in the communication data;
and the data sending module is used for sending the abnormal communication data to the second application in the preset bridge communication mode.
Optionally, the communication data is data in JSON format.
Optionally, the preset mock rule is used to modify at least one of an array, an object, a character type, and a boolean type in the communication data.
Optionally, the apparatus further comprises: and the log generation module is used for writing result data of the abnormal communication data executed by the second application into a log, wherein the log is used for subsequent abnormal analysis.
In a fifth aspect, an embodiment of the present application provides an electronic device, including a processor and a memory;
the memory is used for storing a computer program;
the processor is configured to implement any of the above data communication methods when executing the program stored in the memory.
In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and the computer program, when executed by a processor, implements any of the data communication methods described above.
The data communication method, the data communication device, the electronic equipment and the storage medium provided by the embodiment of the application intercept communication data sent from a first application to a second application; modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data; and sending the abnormal communication data to the second application. Parameters in the communication data are modified, and abnormal communication data can be directly obtained, so that the efficiency of function test can be increased, automatic mock (imitation) of the communication data is realized, the workload of testers is reduced, the influence of subjective factors of the testers is reduced, and the comprehensiveness of abnormal data verification is increased. Of course, not all advantages described above need to be achieved at the same time in the practice of any one product or method of the present application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a first schematic diagram of a data communication method according to an embodiment of the present application;
fig. 2 is a second schematic diagram of a data communication method according to an embodiment of the present application;
fig. 3 is a third schematic diagram of a data communication method according to an embodiment of the present application;
fig. 4 is a fourth schematic diagram of a data communication method according to an embodiment of the present application;
fig. 5 is a fifth schematic diagram of a data communication method according to an embodiment of the present application;
fig. 6 is a sixth schematic diagram of a data communication method according to an embodiment of the present application;
fig. 7 is a seventh schematic diagram of a data communication method according to an embodiment of the present application;
fig. 8 is an eighth schematic diagram of a data communication method according to an embodiment of the present application;
fig. 9a is a first schematic diagram of a data communication device according to an embodiment of the present application;
FIG. 9b is a second schematic diagram of a data communication device according to an embodiment of the present application;
fig. 10 is a schematic diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the prior art, in the development and test process, only a general communication process is simulated, so that the condition that JSON format data has problems is difficult to simulate, and the functional test efficiency is low. In view of this, an embodiment of the present application provides a data communication method for applications in different terminals, where the method includes: intercepting communication data sent by a first application to a second application, wherein the first application and the second application are applications in different terminals; modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data; the preset mock rule is used for modifying parameters in the communication data; and sending the abnormal communication data to the second application.
In the embodiment of the application, aiming at the applications in different terminals, parameters in the communication data are modified through the preset mock rule, so that the automatic mock of the communication data is realized, the workload of testers is reduced, the influence of subjective factors of the testers is reduced, and the comprehensiveness of abnormal data verification is increased.
Aiming at the application of different platforms in the same terminal, the embodiment of the application provides a data communication method, which comprises the following steps: intercepting communication data before the first application sends the communication data to the second application in a preset bridge communication mode, wherein the first application and the second application are applications on different platforms in the same terminal; modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data, wherein the preset mock rule is used for modifying the parameters in the communication data; and sending abnormal communication data to the second application in a preset bridge communication mode.
In the embodiment of the application, aiming at the application of different platforms in the same terminal, parameters in the communication data are modified through the preset mock rule, and abnormal communication data can be directly obtained, so that the efficiency of function test can be increased, the automatic mock of the communication data is realized, the workload of testers is reduced, the influence of subjective factors of the testers is reduced, and the comprehensiveness of abnormal data verification is increased.
The following is a detailed description:
an embodiment of the present application provides a data communication method, and referring to fig. 1, the method includes:
s101, communication data sent by a first application to a second application are intercepted, wherein the first application and the second application are applications in different terminals.
The data communication method of the embodiment of the application can be implemented by electronic equipment, and specifically, in a test scenario for a client and a server, the electronic equipment may be client equipment, server equipment, routing equipment, or the like.
The first application and the second application are applications in different terminals, for example, the first application is an application in a client, and the second application is an application in a server; or the first application is an application in the server, the second application is an application in the client, and the like. The communication data sent from the first application to the second application may be intercepted by a predetermined packet capturing tool, which may be any one of Fiddler, Wireshark, Charles, and the like. Optionally, after intercepting the communication data sent by the first application to the second application, the first application suspends the sending of the communication data, so as to prevent the first application from repeatedly sending the communication data for multiple times because the first application does not receive the response of the second application.
S102, modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data; the preset mock rule is used for modifying parameters in the communication data.
In one possible implementation, the communication data may be data in JSON format. And analyzing and traversing JSON string parameters in the communication data, and modifying the specified parameters according to a preset mock rule, thereby obtaining abnormal communication data.
The preset mock rule can be set in a user-defined mode, optionally, the preset mock rule is used for modifying at least one of a parameter type, a parameter value and request time in the communication data, and the modified data is called abnormal communication data. The modification may be random modification or modification according to a preset mapping rule. Generally, the preset mock rule includes, but is not limited to, modifying a designated node to be null, modifying keywords of data, such as ID, Class, int, and the like; modifying the range of data, such as character string length compatibility, int type compatibility and double type compatibility; and modifying the type of the data, such as converting from int to long type precision loss, converting from string to int type and the like.
S103, sending abnormal communication data to the second application.
And sending the abnormal communication data obtained by modification to a second application, thereby realizing automatic mock of the communication data.
In the embodiment of the application, communication data are intercepted and parameters in the communication data are modified through a preset mock rule aiming at a first application and a second application in different terminals, and abnormal communication data can be directly obtained, so that the efficiency of function test can be increased, the automatic mock of the communication data is realized, the workload of testers is reduced, the influence of subjective factors of the testers is reduced, and the comprehensiveness of abnormal data verification is increased.
In a possible manner, the intercepting communication data sent by the first application to the second application includes:
and intercepting communication data in the JSON format sent from the first application to the second application by using a preset packet capturing tool, wherein the preset packet capturing tool is a Charles tool.
The preset mock rule is used for modifying parameters in the communication data, and any parameter in the communication data can be modified. For communication data in JSON format, in a possible manner, the preset mock rule is used to modify at least one of an array, an object, a character type and a boolean type in the communication data.
When the communication data is data in JSON format, the modified parameter types may be: array, object, character type, boolean type. Specifically, in the practice of client test engineering, it is often verified that data is null and data is abnormally protected, for example, data of a page of a mobile phone terminal is sent by a second application, data transmitted by the second application is null when a certain picture is loaded, and at this time, all pictures in communication data in a JSON format can be nulled or misplaced mock. The specific modification mode is formulated by a specific business module, for example, an application homepage responsible for a baseline research and development team can convert all arrays in the transmitted data into character types; data of the object type may be left empty in some services, etc.
In one possible approach, referring to fig. 2, the method further comprises:
s201, establishing a mapping relation between the generated abnormal communication data and the identification of the communication data corresponding to the abnormal communication data, and storing the mapping relation and the abnormal communication data.
The identification of the communication data is used to uniquely identify the communication data. The identifier of the communication data may be a name or an address of the communication data, and specifically, the identifier of the communication data is a URL (Uniform Resource Locator) of the communication data. The mapping relationship between the abnormal communication data and the identifier of the corresponding communication data can be established in a form of table, pointer or index.
After intercepting communication data sent by the first application to the second application, the method further comprises:
s202, judging whether abnormal communication data corresponding to the intercepted communication data are stored or not according to the identification of the intercepted communication data.
And inquiring the stored mapping relation according to the identifier of the currently intercepted communication data, and judging whether the abnormal communication data corresponding to the currently intercepted communication data is stored.
The above modifying the parameters in the communication data according to the preset mock rule to obtain the abnormal communication data includes:
and S203, modifying parameters in the intercepted communication data according to a preset mock rule under the condition that the abnormal communication data corresponding to the intercepted communication data is not stored, so as to obtain the abnormal communication data.
In a possible manner, referring to fig. 3, after determining whether the abnormal communication data corresponding to the currently intercepted communication data is stored according to the identifier of the currently intercepted communication data, the method further includes:
and S204, if the abnormal communication data corresponding to the currently intercepted communication data is stored, sending the abnormal communication data corresponding to the currently intercepted communication data to the second application.
In the embodiment of the application, the generated mock data is stored, when the same communication data is sent again, the stored mock data is directly obtained, and different mock data are generated again, so that the system resources can be saved.
In one possible approach, referring to fig. 4, after sending the anomalous communication data to the second application, the method further comprises:
s301, response data returned by the second application according to the abnormal communication data are obtained, and the response data are written into the log so as to perform abnormal analysis.
And intercepting response data of the second application and writing the response data into a log, wherein the log can also comprise request time, request parameters and the like, so that a developer can conveniently perform problem positioning and abnormity analysis according to the log.
In a possible implementation manner, the data communication method according to the embodiment of the present application may be applied to a terminal where a first application is located, and referring to fig. 5, the data communication method according to the embodiment of the present application includes:
step one, before a first application sends communication data to a second application, the communication data is obtained, wherein the first application and the second application are applications in different terminals.
And step two, inquiring the mapping relation according to the URL of the current communication data, and judging whether the abnormal communication data corresponding to the current communication data is stored.
And step three, if the abnormal communication data corresponding to the currently intercepted communication data are stored, directly reading the abnormal communication data to obtain the abnormal communication data.
And step four, if the abnormal communication data corresponding to the currently intercepted request data is not stored, intercepting the communication data sent from the first application to the second application by using a preset packet capturing tool, such as a Charles tool.
And step five, modifying parameters in the JSON character string of the currently intercepted communication data according to a preset mock rule, and storing the parameters as abnormal communication data.
And step six, sending abnormal communication data to the second application.
And step seven, acquiring response data returned by the second application according to the abnormal communication data, and writing the response data into the log.
In the embodiment of the application, aiming at the first application and the second application in different terminals, the communication data are intercepted, and parameters in the communication data are modified through the preset mock rule, so that the automatic mock of the communication data is realized, the workload of testers is reduced, the influence of subjective factors of the testers is reduced, and the comprehensiveness of abnormal data verification is increased.
Referring to fig. 6, the following specifically describes a test scenario of cross-platform application in the same terminal, and an embodiment of the present application further provides a data communication method, including:
s601, before the first application sends communication data to the second application in a preset bridge communication mode, intercepting the communication data, wherein the first application and the second application are applications on different platforms in the same terminal.
The data communication method of the embodiment of the application is applied to different platforms in the same terminal, and therefore the data communication method can be specifically realized through the terminal.
In the same terminal, different platform applications generally communicate with each other through a bridge communication method, and the communication method between the first application and the second application is called a preset bridge communication method. The communication data can be intercepted in a buried point mode after the first application generates the communication data and before the communication data is sent to the second application in a preset bridge communication mode.
S602, modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data, wherein the preset mock rule is used for modifying the parameters in the communication data.
And optionally, the preset mock rule is used for modifying at least one of the parameter type, the parameter value and the request time in the communication data, and the modified data is called abnormal communication data. The modification may be random modification or modification according to a preset mapping rule. Generally, for data in the JSON format, the preset mock rule includes, but is not limited to, modifying a specified node to be null, modifying keywords of the data, such as ID, Class, int, and the like; modifying the range of data, such as character string length compatibility, int type compatibility and double type compatibility; and modifying the type of the data, such as converting from int to long type precision loss, converting from string to int type and the like.
And S603, sending abnormal communication data to the second application in a preset bridge communication mode.
And after the abnormal communication data are obtained, transmitting mock data to the second application in a preset bridge communication mode.
In the embodiment of the application, aiming at the application of different platforms in the same terminal, parameters in the communication data are modified through the preset mock rule, so that the automatic mock of the communication data is realized, the workload of testers is reduced, the influence of subjective factors of the testers is reduced, and the comprehensiveness of abnormal data verification is increased.
In a possible implementation manner, referring to fig. 7, after sending the abnormal communication data to the second application in the preset bridge communication manner, the method further includes:
s604, writing result data of the abnormal communication data executed by the second application into a log so as to perform abnormal analysis.
And after executing the abnormal communication data, the second application in the terminal writes the execution result data into the log so as to facilitate the developer to perform problem positioning and abnormal analysis according to the log. Specifically, the result data may include a page display result, and the like. The log may also include abnormal communication data, request time for abnormal communication data, and the like.
In the following, a test scenario of cross-platform application in the same terminal is exemplified, and referring to fig. 8, a preset mock rule in the present application is injected into a terminal in advance for a point burying in a bridge communication manner. After the first application generates communication data, the communication data is sent to the second application in a bridge communication mode, the communication data is intercepted in a preset embedded point mode, parameters of the communication data are modified according to a preset mock rule, and the communication data are stored as abnormal communication data. And sending abnormal communication data to the second application by using a bridge communication mode. And writing the result data of the abnormal communication data executed by the second application into the log so as to facilitate the subsequent abnormal analysis.
An embodiment of the present application further provides an abnormal communication data generating apparatus, referring to fig. 9a, the apparatus includes:
a communication data packet capturing module 701, configured to intercept communication data sent by a first application to a second application, where the first application and the second application are applications in different terminals;
an abnormal communication data generation module 702, configured to modify parameters in the communication data according to a preset mock rule, to obtain abnormal communication data; the preset mock rule is used for modifying parameters in the communication data;
an abnormal communication data sending module 703, configured to send the abnormal communication data to the second application.
In a possible implementation manner, the communication data packet capturing module 701 is specifically configured to intercept, by using a preset packet capturing tool, communication data in a JSON format sent from a first application to a second application, where the preset packet capturing tool is a Charles tool.
In a possible embodiment, the preset mock rule is used for modifying at least one of an array, an object, a character type and a boolean type in the communication data.
In a possible embodiment, the apparatus further comprises:
the abnormal communication data storage module is used for establishing a mapping relation between the generated abnormal communication data and the identifier of the communication data corresponding to the abnormal communication data, and storing the mapping relation and the abnormal communication data;
the data identification detection module is used for judging whether abnormal communication data corresponding to the intercepted communication data are stored or not according to the identification of the intercepted communication data;
the abnormal communication data generating module 702 is specifically configured to, when the abnormal communication data corresponding to the intercepted communication data is not stored, modify parameters in the intercepted communication data according to a preset mock rule to obtain the abnormal communication data.
In a possible embodiment, the apparatus further comprises: and the abnormal communication data acquisition module is used for sending the abnormal communication data corresponding to the currently intercepted communication data to the second application if the abnormal communication data corresponding to the currently intercepted communication data is stored.
In a possible embodiment, the apparatus further comprises: and the log acquisition module is used for acquiring response data returned by the second application according to the abnormal communication data and writing the response data into a log so as to perform abnormal analysis.
An embodiment of the present application further provides an abnormal communication data generating apparatus, referring to fig. 9b, the apparatus includes:
a communication interception module 801, configured to intercept communication data before a first application sends the communication data to a second application in a preset bridge communication manner, where the first application and the second application are applications on different platforms in the same terminal;
a parameter modification module 802, configured to modify parameters in the communication data according to a preset mock rule to obtain abnormal communication data, where the preset mock rule is used to modify parameters in the communication data;
a data sending module 803, configured to send the abnormal communication data to the second application through the preset bridge communication mode.
In one possible embodiment, the communication data is data in JSON format.
In a possible embodiment, the preset mock rule is used for modifying at least one of an array, an object, a character type and a boolean type in the communication data.
In a possible embodiment, the apparatus further comprises: and the log generation module is used for writing result data of the abnormal communication data executed by the second application into a log, wherein the log is used for subsequent abnormal analysis.
An embodiment of the present application further provides an electronic device, including: a processor and a memory;
the memory is used for storing computer programs;
the processor is configured to implement any of the data communication methods described above when executing the computer program stored in the memory.
Optionally, referring to fig. 10, the electronic device according to the embodiment of the present application further includes a communication interface 902 and a communication bus 904, where the processor 901, the communication interface 902, and the memory 903 complete communication with each other through the communication bus 904.
The communication bus mentioned in the electronic device may be a PCI (Peripheral component interconnect) bus, an EISA (Extended Industry standard architecture) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a RAM (Random Access Memory) or an NVM (Non-Volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also a DSP (Digital Signal Processing), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the computer program implements any of the data communication methods.
It should be noted that, in this document, the technical features in the various alternatives can be combined to form the scheme as long as the technical features are not contradictory, and the scheme is within the scope of the disclosure of the present application. Relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the embodiments of the apparatus, the electronic device, and the storage medium, since they are substantially similar to the method embodiments, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiments.
The above description is only for the preferred embodiment of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims (11)
1. A method of data communication, the method comprising:
intercepting communication data sent by a first application to a second application, wherein the first application and the second application are applications in different terminals;
modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data; the preset mock rule is used for modifying parameters in the communication data;
sending the anomalous communication data to the second application.
2. The method of claim 1, further comprising:
establishing a mapping relation between the generated abnormal communication data and the identifier of the communication data corresponding to the abnormal communication data, and storing the mapping relation and the abnormal communication data;
after intercepting communication data sent by the first application to the second application, the method further comprises:
judging whether abnormal communication data corresponding to the intercepted communication data are stored or not according to the identification of the intercepted communication data;
according to a preset mock rule, modifying parameters in the communication data to obtain abnormal communication data, wherein the method comprises the following steps:
and modifying parameters in the intercepted communication data according to a preset mock rule under the condition that the abnormal communication data corresponding to the intercepted communication data is not stored, so as to obtain the abnormal communication data.
3. The method according to claim 2, wherein after determining whether the abnormal communication data corresponding to the currently intercepted communication data is stored according to the identifier of the currently intercepted communication data, the method further comprises:
and if the abnormal communication data corresponding to the currently intercepted communication data is stored, sending the abnormal communication data corresponding to the currently intercepted communication data to the second application.
4. The method of claim 1, wherein intercepting communication data sent by a first application to a second application comprises:
intercepting communication data in a JSON format sent from a first application to a second application by using a preset packet capturing tool, wherein the preset packet capturing tool is a Charles tool.
5. The method of any of claims 1-4, wherein after said sending said anomalous communication data to said second application, said method further comprises:
and acquiring response data returned by the second application according to the abnormal communication data, and writing the response data into a log to perform abnormal analysis.
6. A method of data communication, the method comprising:
intercepting communication data before a first application sends the communication data to a second application in a preset bridge communication mode, wherein the first application and the second application are applications on different platforms in the same terminal;
modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data, wherein the preset mock rule is used for modifying the parameters in the communication data;
and sending the abnormal communication data to the second application in the preset bridge communication mode.
7. The method according to claim 6, wherein after the sending the abnormal communication data to the second application through the preset bridge communication manner, the method further comprises:
and writing result data of the abnormal communication data executed by the second application into a log so as to perform abnormal analysis.
8. A data communication apparatus, characterized in that the apparatus comprises:
the device comprises a communication data packet capturing module, a first application and a second application, wherein the communication data packet capturing module is used for intercepting communication data sent by the first application to the second application, and the first application and the second application are applications in different terminals;
the abnormal communication data generation module is used for modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data; the preset mock rule is used for modifying parameters in the communication data;
and the abnormal communication data sending module is used for sending the abnormal communication data to the second application.
9. A data communication apparatus, characterized in that the apparatus comprises:
the communication interception module is used for intercepting communication data before the first application sends the communication data to a second application in a preset bridge communication mode, wherein the first application and the second application are applications on different platforms in the same terminal;
the parameter modification module is used for modifying parameters in the communication data according to a preset mock rule to obtain abnormal communication data, wherein the preset mock rule is used for modifying the parameters in the communication data;
and the data sending module is used for sending the abnormal communication data to the second application in the preset bridge communication mode.
10. An electronic device comprising a processor and a memory;
the memory is used for storing a computer program;
the processor is configured to implement the data communication method according to any one of claims 1 to 7 when executing the program stored in the memory.
11. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the data communication method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010341874.9A CN111555935A (en) | 2020-04-27 | 2020-04-27 | Data communication method, device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010341874.9A CN111555935A (en) | 2020-04-27 | 2020-04-27 | Data communication method, device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111555935A true CN111555935A (en) | 2020-08-18 |
Family
ID=72007699
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010341874.9A Pending CN111555935A (en) | 2020-04-27 | 2020-04-27 | Data communication method, device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111555935A (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010016646A1 (en) * | 1998-03-20 | 2001-08-23 | David C. Rueger | Osteogenic devices and methods of use thereof for repair of endochondral bone, osteochondral and chondral defects |
US20020135991A1 (en) * | 2000-12-28 | 2002-09-26 | Yutaka Doi | Layered circuit boards and methods of production thereof |
CN107368405A (en) * | 2016-05-11 | 2017-11-21 | 腾讯科技(北京)有限公司 | Test system, method of testing, mock platforms, blocker and client |
CN107547312A (en) * | 2017-09-21 | 2018-01-05 | 广州四三九九信息科技有限公司 | Applied program testing method and system |
CN107729246A (en) * | 2017-10-13 | 2018-02-23 | 广州阿里巴巴文学信息技术有限公司 | For the auxiliary test methods of intended application, device, equipment and storage medium |
CN108199921A (en) * | 2017-12-29 | 2018-06-22 | 上海瑞家信息技术有限公司 | The method, apparatus and storage medium of a kind of simulation test |
CN109542758A (en) * | 2018-09-29 | 2019-03-29 | 中国平安人寿保险股份有限公司 | Application program fault-tolerant ability test method, device, computer readable storage medium |
-
2020
- 2020-04-27 CN CN202010341874.9A patent/CN111555935A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010016646A1 (en) * | 1998-03-20 | 2001-08-23 | David C. Rueger | Osteogenic devices and methods of use thereof for repair of endochondral bone, osteochondral and chondral defects |
US20020135991A1 (en) * | 2000-12-28 | 2002-09-26 | Yutaka Doi | Layered circuit boards and methods of production thereof |
CN107368405A (en) * | 2016-05-11 | 2017-11-21 | 腾讯科技(北京)有限公司 | Test system, method of testing, mock platforms, blocker and client |
CN107547312A (en) * | 2017-09-21 | 2018-01-05 | 广州四三九九信息科技有限公司 | Applied program testing method and system |
CN107729246A (en) * | 2017-10-13 | 2018-02-23 | 广州阿里巴巴文学信息技术有限公司 | For the auxiliary test methods of intended application, device, equipment and storage medium |
CN108199921A (en) * | 2017-12-29 | 2018-06-22 | 上海瑞家信息技术有限公司 | The method, apparatus and storage medium of a kind of simulation test |
CN109542758A (en) * | 2018-09-29 | 2019-03-29 | 中国平安人寿保险股份有限公司 | Application program fault-tolerant ability test method, device, computer readable storage medium |
Non-Patent Citations (1)
Title |
---|
萧竹: "《51esting软件测试网采编》", 22 March 2017 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110798380B (en) | Data acquisition method, system, device, test equipment and test server | |
CN112199300B (en) | Interface testing method and device, electronic equipment and storage medium | |
CN110955409B (en) | Method and device for creating resources on cloud platform | |
CN109683997B (en) | Method for accessing application program interface through sandbox, sandbox and sandbox equipment | |
CN110716743B (en) | Aggregation API development method and system suitable for multiparty collaborative development | |
CN111309593A (en) | JSON interface verification method, device and equipment and computer readable storage medium | |
CN111694550A (en) | Page display control method, device and system | |
CN110716912B (en) | SQL performance detection method and server | |
CN110838929B (en) | System error checking method and system error checking device | |
CN112671574B (en) | Front-end and back-end joint debugging method and device, proxy equipment and storage medium | |
CN111597020B (en) | Application programming interface API debugging method and debugging terminal | |
CN115705190A (en) | Method and device for determining dependence degree | |
CN112612706A (en) | Automated testing method, computer device and storage medium | |
CN117499287A (en) | Web testing method, device, storage medium and proxy server | |
CN116185825A (en) | Front-end self-test method, front-end device, and computer-readable storage medium | |
CN111555935A (en) | Data communication method, device, electronic equipment and storage medium | |
CN114567543A (en) | Problem interface positioning method and device, electronic equipment and storage medium | |
CN113031995B (en) | Rule updating method and device, storage medium and electronic equipment | |
CN110740134B (en) | URL authentication test method, device, equipment and medium | |
CN113886216A (en) | Interface test and tool configuration method, device, electronic equipment and storage medium | |
CN112559930B (en) | Webpage integration method, webpage integration device, computer equipment and storage medium | |
CN116048969A (en) | Test environment configuration method, system and device | |
CN114398189A (en) | Method and device for returning analog interface data, electronic equipment and storage medium | |
CN112015666A (en) | Web testing method and device based on contextPath | |
CN116594867A (en) | Interface testing method, system, device and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200818 |