CN108345535B - mock testing method, device and equipment - Google Patents

mock testing method, device and equipment Download PDF

Info

Publication number
CN108345535B
CN108345535B CN201711428013.9A CN201711428013A CN108345535B CN 108345535 B CN108345535 B CN 108345535B CN 201711428013 A CN201711428013 A CN 201711428013A CN 108345535 B CN108345535 B CN 108345535B
Authority
CN
China
Prior art keywords
request
mock
container interface
server
return
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.)
Active
Application number
CN201711428013.9A
Other languages
Chinese (zh)
Other versions
CN108345535A (en
Inventor
李旭东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Advanced New Technologies Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Advanced New Technologies Co Ltd filed Critical Advanced New Technologies Co Ltd
Priority to CN201711428013.9A priority Critical patent/CN108345535B/en
Publication of CN108345535A publication Critical patent/CN108345535A/en
Application granted granted Critical
Publication of CN108345535B publication Critical patent/CN108345535B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3648Software debugging using additional hardware
    • G06F11/3656Software debugging using additional hardware using a specific debug interface

Abstract

The embodiment of the specification discloses a mock testing method, a mock testing device and mock testing equipment. The mock script is automatically injected into the client through the server (for example, directly injected when an access request sent by the client is received), then the request of the application to be tested for calling the container interface is intercepted through the script, the server is forwarded, and whether the returned result is a real result or a mock response result is determined through a mock configuration file in the server, so that various business tests are carried out.

Description

mock testing method, device and equipment
Technical Field
The specification relates to the technical field of computers, in particular to a mock testing method, a mock testing device and mock testing equipment.
Background
The mock test is a test method which is created by using a virtual object for some objects which are not easy to construct or obtain in the test process.
In the prior art, since the result returned by the test is affected by software, hardware, system environment and other aspects, and various return results are required to be normal and abnormal during development and test, it is necessary to perform corresponding configuration on the test equipment (for example, a user mobile phone) or perform corresponding maintenance in the local service code to perform mock test, and the local service code is brought online after the test is successful.
Based on this, a more convenient mock testing protocol is needed.
Disclosure of Invention
The embodiment of the specification provides a mock testing method, a mock testing device and mock testing equipment, which are used for solving the following problems: to provide a more convenient mock testing protocol.
Based on this, the embodiments of the present specification provide a mock testing method, including:
the client initiates a request for calling a container interface;
intercepting the request and sending the request to a server so that the server can respond to the request and return a corresponding mock response result or return the request to the container interface;
and receiving a return result of the server side, and performing service processing.
Meanwhile, an embodiment of the present specification further provides another mock testing method, including:
the server receives a request of calling a container interface from the client, wherein the request is intercepted by a mock script;
responding to the request, and determining to return a corresponding mock response result or return the request to the container interface;
and sending a return result of the request to the client.
Meanwhile, an embodiment of the present specification further provides a mock testing device, including:
the client initiates a request for calling the container interface;
the intercepting module intercepts the request and sends the request to the server so that the server can respond to the request and return a corresponding mock response result or return the request to the container interface;
and the receiving module is used for receiving the returned result of the server and processing the service.
Meanwhile, embodiments of the present specification also provide another mock testing device, including:
the server receives a request of calling a container interface from the client, wherein the request is intercepted by a mock script;
the determining module is used for responding to the request and determining to return a corresponding mock response result or return the request to the container interface;
and the sending module is used for sending the returned result of the request to the client.
Correspondingly, the embodiment of the present specification further provides a mock test device, including:
the memory stores a mock test program;
and the processor calls the mock test program in the memory and executes the following steps:
the client initiates a request for calling a container interface;
intercepting the request and sending the request to a server so that the server can respond to the request and return a corresponding mock response result or return the request to the container interface;
and receiving a return result of the server side, and performing service processing.
Correspondingly, the embodiment of the present specification further provides another mock testing device, including:
the memory stores a mock test program;
and the processor calls the mock test program in the memory and executes the following steps:
the server receives a request of calling a container interface from the client, wherein the request is intercepted by a mock script;
responding to the request, and determining to return a corresponding mock response result or return the request to the container interface;
and sending a return result of the request to the client.
Correspondingly, embodiments of the present specification also provide a non-volatile computer storage medium storing computer-executable instructions configured to:
the client initiates a request for calling a container interface;
intercepting the request and sending the request to a server so that the server can respond to the request and return a corresponding mock response result or return the request to the container interface;
and receiving a return result of the server side, and performing service processing.
Correspondingly, embodiments of the present description also provide another non-volatile computer storage medium storing computer-executable instructions configured to:
the server receives a request of calling a container interface from the client, wherein the request is intercepted by a mock script;
responding to the request, and determining to return a corresponding mock response result or return the request to the container interface;
and sending a return result of the request to the client.
The embodiment of the specification adopts at least one technical scheme which can achieve the following beneficial effects:
in the embodiment of the description, a mock script is automatically injected into a client through a server (for example, direct injection is performed when an access request sent by the client is received), then a request for calling a container interface by an application to be tested is intercepted through the script, the server is forwarded, and whether a result returned this time is a real result or a mock response result is determined through a mock configuration file in the server, so as to perform various service tests. In the test process, the user terminal can directly access the page provided by the local development server without any configuration, so that other people can conveniently test and verify; whether the return is real return or mock return is flexibly controlled through the configuration file, the flexibility is strong, dynamic change is achieved, and self-maintenance and expansion are facilitated. In addition, the product is on-line after the test is successful, the service code is not changed, and the corresponding configuration file is not required to be modified in the service code, so that the on-line fault caused by forgetting to switch the code when the product is on-line is fundamentally solved; by using the local server, the condition that the remote service cannot be used to cause incapability can be effectively avoided.
Drawings
FIG. 1 is a block diagram of an architecture according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a mock testing method on the client side according to an embodiment of the present specification;
fig. 3 is a schematic flowchart of a mock testing method in the aspect of a server according to an embodiment of the present disclosure;
FIG. 4 is a diagram illustrating an online actual invocation of a product after it comes online in accordance with an embodiment of the present disclosure;
FIG. 5 is a schematic structural diagram of a mock testing device on the client side according to an embodiment of the present specification;
fig. 6 is a schematic structural diagram of a mock testing device in the aspect of a server according to an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification without any inventive step are within the scope of the present application.
An HTML5 (HyperText Markup Language fifth generation standard, HTML5) application (also referred to as H5 application for short) is a web page or web application embedded in a Native App of a mobile phone, an HTML5 application needs to call a function provided by the Native App of the mobile phone, and the Native App loads an HTML5 application through an HTML5 application container, so that the HTML5 application is monitored through the HTML5 application container to complete a specific function and return a required result.
Therefore, when the HTML5 application is developed and tested, development and testing personnel are required to simulate the return result of the HTML5 application container, and the process is called mock. The methods for performing mock in the prior art are various as follows: the mock is realized by a method of directly modifying the service code, so that the service intrusion is large; the mock is carried out in a network agent mode, and network agent configuration is needed during verification, so that the method is very complicated; the content returned by the remote service is called as mock data, the mock data is not flexible enough, the returned content cannot be changed quickly, and the development and test work of the remote service can be influenced once the remote service is hung. In addition, the return result of the HTML5 application container is influenced by various aspects such as software, hardware, system environment, etc., and various returns such as normal and abnormal may be required for development and testing.
Based on this, the embodiments of the present specification provide a mock testing scheme, where a mock script is automatically injected into a client in a development server, so as to intercept a call request of an application to a container interface, and then forward the server. And then, a return result is determined through a mock configuration file local to the server side, so that more convenient test work is realized.
Fig. 1 is a schematic diagram of an architecture according to an embodiment of the present disclosure. In an embodiment of the present disclosure, the mock testing method may adopt a structure as shown in fig. 1, in which the client may be installed on a user terminal, such as a smart phone, a tablet computer, and the server may provide an address (e.g., a Uniform Resource Locator (URL)) for the user terminal to connect to. Since the present solution is generally used in development and testing, the service end is generally a testing service end. In other words, it should be a different server from the online server when the product is online.
The mock testing method provided in the embodiment of the present specification will be described in detail below based on the architecture shown in fig. 1, where the method specifically includes two aspects, namely a client and a server, and specifically includes the following steps for an execution flow in the aspect of the client, as shown in fig. 2, and fig. 2 is a schematic flow diagram of the mock testing method in the aspect of the client provided in the embodiment of the present specification, and includes:
s201, the client side initiates a request for calling the container interface.
As mentioned above, the application to be tested calls the native functions of the handset through the container interface, where the container interface may be one or more according to the service content of the application to be tested. Such call requests may occur frequently during execution of non-native applications. For example, some web applications cannot invoke hardware devices (voice, camera, gravity sensing, etc.) of a cell phone terminal, thereby enabling these hardware devices by invoking the native application container interface of the user terminal. In other words, the request to invoke the container interface may be a functional request or a page access request.
S203, intercepting the request and sending the request to the server so that the server can respond to the request and return a corresponding mock response result or return the request to the container interface.
Interception of the interface call request may be achieved in a number of ways, for example, using a Spring interceptor when the interface is called. After intercepting the call request, the request is directly sent to a server (also called a test server), and the server decides to return by using a mock response result or pass through to a container real interface.
In practical application, a program file (i.e. mock object) for mock can be created according to preset test content, and a corresponding mock response result is generated according to a corresponding request. The Mock object is mainly used for simulating an object which is not easy to construct or complex in application so as to carry out testing.
And testing by inputting a mock object in the server in advance. Then, by determining in advance (which may be implemented by a configuration file or by a logic code), whether a real result (that is, a transparent transmission request to a container interface, the container interface calls a mobile phone native function, and returned real data) or a mock response result (that is, mock data obtained after the request is sent to a mock object) is to be returned in the test, if the content of the test is to be changed to perform different tests, it is only necessary to modify the mock object correspondingly or configure the script.
For example, a certain webpage provides a shopping function at9 points per day, if a real object is adopted, the test can be performed only by waiting for 9 points per day, and if a mock test object is adopted, the test can be performed only by simulating the time to 9 points. If the testing time is modified to be 20 points, the modification can be easily carried out in the mock object, so that the whole testing process is more flexible.
For another example, the mock object A function returns detailed information of the commodity according to the received commodity name; the mock object B has the function of popping up suggestive page information (for example, 20 points and 55 points each day, a pop-up prompt is given, and a certain commodity enters a quick shot at 21 points) at the set system time, so that if a user needs to test, the mock objects A and B can be injected into a local server in advance, and the function A and/or the function B of the test can be determined through a predetermined configuration file. And after the client sends a page request, determining the called object according to the configuration file through intercepting the request, and acquiring a result. The result here includes a return result of the mock object or a container interface that passes through the request to the client so that the container interface performs the calling function locally at the user terminal according to the request. For the same container interface call request, only one of the two (mock response result or transparent transmission request to the container interface) is returned.
And S205, receiving a return result of the server and performing service processing.
As described above, the return result of the server may be a mock response result to the request response, or the server may return the request to the container interface. Under the condition that the server transparently transmits the request to the container interface, the container interface further executes corresponding service processing according to the request, for example, some hardware functions of a local mobile phone are called, or the server requests page access and the like, so that a real corresponding result is obtained.
The result of the application request process is influenced by software, hardware, system environment and other aspects, which is also the purpose of service test. And combining the mock corresponding result and/or the real response result to obtain the final service processing result requested by the client, wherein if the final service processing result is consistent with the expected result, the service code operates normally. If the returned result is not in accordance with the expectation, that is, the test result is abnormal, the debugging is required to be carried out again.
In the scheme, the request of calling the container interface by the application to be tested is intercepted, the server is forwarded, and whether the returned result is a real result or a mock response result is determined through a mock configuration file in the server, so that various service tests are performed. In the test process, the user terminal can directly access the page provided by the development server without configuration, so that other people can conveniently test and verify; the product is on-line after the test is successful, the service code is not changed, and the corresponding configuration file is not required to be modified in the service code, so that the on-line fault caused by forgetting to switch the code when the product is on-line is fundamentally solved.
In a specific embodiment, in the process of performing application development and test, as for a manner of intercepting the request, the following method may be adopted: and intercepting the request and sending the request to a server through a pre-injected mock script.
The pre-injection mode can be that the injection is manually performed to the client by a user; but it is more convenient, or it may be automatically injected to the client through the server, for example, when the client accesses the address provided by the server for the first time, a pre-written mock script is injected to the client to intercept the call request of the container interface.
In this way, the injected mock script disables the capacity of the original container processing interface, the request is still sent out in the container, but because the mock script is injected, the container loses the direct control of the request, the request is intercepted and directly sent to the server, and the server determines to return the mock response result or transmit the mock response result to the real container interface to return the real response result, so that the dynamic change can be realized, and the test is more convenient.
As a specific embodiment, the aforementioned request comprises an HTML5 page request, and the container interface comprises an HTML5 application container interface. In other words, the native applications in the system are tested for the function of loading web pages or web applications through the HTML5 container, which is the most common content to be tested in developing HTML5 applications. In this case, the mock object includes a simulation of the HTML5 application container.
In practical applications, the HTML5 application needs to call the interface provided by the HTML5 container to call the functions provided by the native mobile phone system. The Mock test object also describes the object using an interface through which the object is referenced during the test. In other words, during the test process, the client does not know whether the object accessed this time is the real test object or the mock test object.
The above description is mainly a description of an execution flow in the client side, and the execution flow in the server side specifically includes the following steps, as shown in fig. 3, fig. 3 is a schematic flow diagram of a mock testing method in the server side provided in the embodiment of the present specification, and includes:
s301, a server receives a request of a client for calling a container interface, wherein the request is intercepted by a mock script;
s303, responding to the request, and determining to return a corresponding mock response result or return the request to the container interface;
s305, sending the return result of the request to the client.
As a specific implementation manner, in the implementation process, the server may further automatically inject a mock script for interception into the client, including: and injecting a mock script into the client, wherein the mock script is used for intercepting a request for calling a container interface sent by the client and forwarding the request to the server. The script is automatically injected into the client through the server, so that the test can be conveniently carried out through various different terminal devices during the test without additional setting.
The server may be implemented based on predefined logic code when determining to return a result in response to a request. Further, the logic code may also be displayed in a configuration file, and a response result of the request is determined through the configuration file (including accessing the mock object to obtain a mock response result, or transparently transmitting the request to a container interface of the client, so that the container interface further performs service processing to obtain a real result). Usually, the code corresponding to the part of the logic code or configuration file is isolated from the service code.
In practical applications, a plurality of container interfaces may need to be called for a request, so that in the testing process, it can be determined according to actual needs which contents are tested, whether the request needs to be transparently transmitted or not, and the degree of the transparent transmission. In other words, by setting in the configuration file in advance to determine the result returned this time, it is possible to flexibly configure whether mock data or real data is returned. Specifically, the following three modes can be included:
determining that all returned results of the request are transparent transmission of the request to the container interface, wherein in the mode, all requests of the client side are transparent transmission; alternatively, the first and second electrodes may be,
determining that all returned results of the request are the mock response results; alternatively, the first and second electrodes may be,
and determining that the part of the returned result of the request is the mock response result, and the rest part of the returned result is the transparent transmission of the request to the container interface.
In practical application, most of the returned results during testing are the mock response results, and the rest of the returned results are transparent transmission of the request to the container interface (in one test request, multiple interfaces may be called to access multiple objects, and partial real tests are often required). That is, the server performs partial transparent transmission on the request through the configuration file to perform corresponding testing, and in this embodiment, the part of the interface call request which is not transmitted through jumps to the mock object, so that the returned result of the client is the returned result of the real HTML5 container interface in part and the returned result of the mock object in part.
Certainly, in practical application, if the test is successful, the server side should realize complete transparent transmission after the product is on line without problems. After the product is online, the product is deployed in an online server (i.e., not a test server for testing), and the client accesses the online server or accesses an offline package page at this time. Because the entries are different, the client cannot access the above-mentioned test server, so that the aforementioned process of automatically injecting scripts, even no interception process, and obviously the above-mentioned process of jumping to mock test objects are not possible, all requests are directly passed through to the real container interface, and the return results are also the return of the real HTML5 container. As shown in fig. 4, fig. 4 is a schematic diagram of an actual online call after a product is online according to an embodiment of the present disclosure.
In the scheme, the server side flexibly controls whether the returned return is real return or mock return through the configuration file, and the flexibility is strong, so that dynamic change is realized, and self-maintenance and expansion are facilitated. In addition, the server side automatically injects the mock script into the client side, and the user terminal can test by directly accessing the page provided by the local development server without any configuration, so that other people can conveniently test and verify; the product is on-line after the test is successful, the service code is not changed, and the corresponding configuration file is not required to be modified in the service code, so that the problem of on-line fault caused by forgetting to switch the code when the product is on-line is fundamentally solved
In the testing process, the mock script or the configuration file thereof is required to be modified, the service code is not changed, and the corresponding configuration file is not required to be modified in the service code, so that the flexibility is strong, and the self-maintenance and the expansion are convenient.
Different test contents can be realized through different mock scripts. For the same application to be tested, the user can also decide whether to use the interface of the real HTML5 container to return or the mock object to return by modifying the configuration file, so that the test is more flexible and convenient, and the following method can be specifically adopted: receiving an instruction of a user to modify the configuration file; and determining the object accessed this time according to the modified configuration file and the request.
As a specific implementation mode, the client and the server are both located locally, and the local server and the client are adopted for testing, so that modification and configuration can be conveniently carried out, and the condition that the remote service cannot work due to unavailability can be effectively avoided.
In the embodiment of the present specification, whether the server side or the mock script can be implemented in various ways. Js, the mock script is developed through a JavaScript language, and in the development process, codes of a configuration file of the mock script are isolated from service codes and codes of a mock object.
As a particular embodiment, the request comprises an HTML5 page request and the container interface comprises an HTML5 application container interface.
Based on the same idea, the present invention further provides a mock testing device, as shown in fig. 5, where fig. 5 is a schematic structural diagram of the mock testing device in the client side provided in the embodiment of the present specification, and the mock testing device includes:
a request initiating module 501, where a client initiates a request for calling a container interface;
the intercepting module 503 intercepts the request and sends the request to the server, so that the server responds to the request and returns a corresponding mock response result or returns the request to the container interface;
and the receiving module 505 is configured to receive a return result of the server and perform service processing.
Further, if the server returns the request to the container interface, the receiving module 505 obtains a real response result obtained by processing the request returned by the server through the container interface; and performing service processing according to the real response result.
Further, the intercepting module 503 intercepts the request through a pre-injected mock script and sends the request to the server.
Further, the request comprises an HTML5 page request, and the container interface comprises an HTML5 application container interface.
Based on the same idea, the present invention further provides another mock testing device, as shown in fig. 6, where fig. 6 is a schematic structural diagram of a mock testing device in the aspect of a server side provided in the embodiments of the present specification, and the schematic structural diagram includes:
a receiving module 601, where a server receives a request for a client to call a container interface, and the request is intercepted by a mock script;
the determining module 603, configured to determine to return a corresponding mock response result or return the request to the container interface in response to the request;
the sending module 605 sends the returned result of the request to the client.
Further, the apparatus further includes an injection module 607, which is configured to inject a mock script into the client, where the mock script is used to intercept a request sent by the client to call the container interface, and forward the request to the server.
Further, the determining module 603, based on a preset configuration file, determines to return a corresponding mock response result or return the request to the container interface in response to the request
Further, the determining module 603 determines that all returned results of the current request are the mock response result; or, determining that all return results of the request are to return the request to the container interface; or, determining that part of the returned result of the request is the mock response result, and the rest is returning the request to the container interface.
Further, the receiving module 601 is further configured to receive an instruction of a user to modify the configuration file; the determining module 603, responding to the request according to the modified configuration file, determining a return result of the request
Further, the server and the mock script are based on JavaScript.
Further, the client and the server are both located locally
Further, the request comprises an HTML5 page request, and the container interface comprises an HTML5 application container interface.
Correspondingly, the embodiment of the present application further provides a mock test device, where the mock test device includes:
the memory stores a mock test program;
and the processor calls the mock test program in the memory and executes the following steps:
the client initiates a request for calling a container interface;
intercepting the request and sending the request to a server so that the server can respond to the request and return a corresponding mock response result or return the request to the container interface;
and receiving a return result of the server side, and performing service processing.
Correspondingly, an embodiment of the present application further provides another mock test device, where the device includes:
the memory stores a mock test program;
and the processor calls the mock test program in the memory and executes the following steps:
the server receives a request of calling a container interface from the client, wherein the request is intercepted by a mock script;
responding to the request, and determining to return a corresponding mock response result or return the request to the container interface;
and sending a return result of the request to the client.
Based on the same inventive concept, embodiments of the present specification further provide a non-volatile computer storage medium storing computer-executable instructions configured to:
the client initiates a request for calling a container interface;
intercepting the request and sending the request to a server so that the server can respond to the request and return a corresponding mock response result or return the request to the container interface;
and receiving a return result of the server side, and performing service processing.
Based on the same inventive concept, embodiments of the present specification further provide another non-volatile computer storage medium storing computer-executable instructions configured to:
the server receives a request of calling a container interface from the client, wherein the request is intercepted by a mock script;
responding to the request, and determining to return a corresponding mock response result or return the request to the container interface;
and sending a return result of the request to the client.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. Especially, as for the device, apparatus and medium type embodiments, since they are basically similar to the method embodiments, the description is simple, and the related points may refer to part of the description of the method embodiments, which is not repeated here.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps or modules recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functions of the units may be implemented in the same software and/or hardware or in one or more pieces of software and/or hardware when implementing the embodiments of the present description.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include transitory computer readable media (transient media) such as modulated data signal numbers and carrier waves.
It should also be noted that 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 like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
Embodiments of the present description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular transactions or implement particular abstract data types. Embodiments of the present description may also be practiced in distributed computing environments where transactions are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present specification, and is not intended to limit the present application. Various modifications and changes may occur to the embodiments described herein, as will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of the present specification should be included in the scope of the claims of the present application.

Claims (22)

1. A mock testing method, comprising:
a client initiates a request for calling a container interface, wherein the request is for calling the native container interface of a user terminal where the client is located;
intercepting the request by using a mock script injected by the server and sending the request to the server so that the server can respond to the request, and determining to return a corresponding mock response result or return the request to the container interface through a mock configuration file in the server;
receiving a return result of the server side, and performing service processing;
if the server returns the request to the container interface, the server receives a return result of the server, and performs service processing, including:
acquiring a real response result obtained by processing the request returned by the server through the container interface;
and performing service processing according to the real response result, wherein the real response result is real data returned by transmitting a request to a container interface and calling and executing the native function of the mobile phone by the container interface.
2. The method of claim 1, wherein intercepting the request and sending the request to a server comprises:
and intercepting the request and sending the request to a server through a pre-injected mock script.
3. The method of any of claims 1 to 2, the request comprising an HTML5 page request, the container interface comprising an HTML5 application container interface.
4. A mock testing method, comprising:
the server receives a request of calling a container interface from the client, wherein the request is intercepted by a mock script;
responding to the request, and determining to return a corresponding mock response result or return the request to the container interface;
sending a return result of the request to the client;
determining to return a corresponding mock response result or return the request to the container interface based on the request, including:
responding to the request based on a preset configuration file, and determining to return a corresponding mock response result or return the request to the container interface;
the sending of the returned result of the request to the client specifically includes:
acquiring a real response result obtained by processing the request returned by the server through the container interface;
and performing service processing according to the real response result, wherein the real response result is real data returned by transmitting a request to a container interface and calling and executing the native function of the mobile phone by the container interface.
5. The method of claim 4, further comprising:
and injecting a mock script into the client, wherein the mock script is used for intercepting a request for calling a container interface sent by the client and forwarding the request to the server.
6. The method of claim 4, the determining to return a corresponding mock response result or return the request to the container interface, comprising:
determining that all returned results of the request are the mock response results; alternatively, the first and second electrodes may be,
determining that all returned results of the request are returned to the container interface; alternatively, the first and second electrodes may be,
and determining that the part of the returned result of the request is the mock response result, and the rest part is the returned result of the request to the container interface.
7. The method of claim 4, further comprising:
receiving an instruction of a user to modify the configuration file;
and responding to the request according to the modified configuration file, and determining a return result of the request.
8. The method of claim 4, the server and the mock script being based on JavaScript.
9. The method of claim 4, wherein the client and the server are both locally located.
10. The method of any of claims 4 to 9, the request comprising an HTML5 page request, the container interface comprising an HTML5 application container interface.
11. A mock testing device comprising:
the client initiates a request for calling a container interface, wherein the request is for calling the native container interface of a user terminal where the client is located;
the intercepting module intercepts the request by utilizing a mock script injected by the server and sends the request to the server so that the server can respond to the request, and determines to return a corresponding mock response result or return the request to the container interface through a mock configuration file in the server;
the receiving module is used for receiving a return result of the server and processing the service;
if the server side returns the request to the container interface, the receiving module acquires a real response result obtained by processing the request returned by the server side through the container interface; and performing service processing according to the real response result, wherein the real response result is real data returned by transmitting a request to a container interface and calling and executing the native function of the mobile phone by the container interface.
12. The apparatus of claim 11, wherein the intercepting module intercepts the request through a pre-injected mock script and sends the request to the server.
13. The apparatus of any of claims 11 to 12, the request comprising an HTML5 page request, the container interface comprising an HTML5 application container interface.
14. A mock testing device comprising:
the server receives a request of calling a container interface from the client, wherein the request is intercepted by a mock script;
the determining module is used for responding to the request and determining to return a corresponding mock response result or return the request to the container interface;
the sending module is used for sending a return result of the request to the client;
the determining module responds to the request based on a preset configuration file, and determines to return a corresponding mock response result or return the request to the container interface;
the sending of the returned result of the request to the client specifically includes:
acquiring a real response result obtained by processing the request returned by the server through the container interface;
and performing service processing according to the real response result, wherein the real response result is real data returned by transmitting a request to a container interface and calling and executing the native function of the mobile phone by the container interface.
15. The apparatus of claim 14, further comprising an injection module that injects a mock script into the client, the mock script being configured to intercept a request sent by the client to call the container interface and forward the request to the server.
16. The apparatus according to claim 14, wherein the determining module determines that all returned results of the current request are the mock response result; or, determining that all return results of the request are to return the request to the container interface; or, determining that part of the returned result of the request is the mock response result, and the rest is returning the request to the container interface.
17. The apparatus of claim 16, the receiving module further configured to receive a user's instruction to modify the configuration file; and the determining module responds to the request according to the modified configuration file and determines a return result of the request.
18. The apparatus of claim 14, the server and the mock script based on JavaScript.
19. The apparatus of claim 14, the client and the server both located locally.
20. The apparatus of any of claims 14 to 19, the request comprising an HTML5 page request, the container interface comprising an HTML5 application container interface.
21. A mock test device comprising:
the memory stores a mock test program;
and the processor calls the mock test program in the memory and executes the following steps:
a client initiates a request for calling a container interface, wherein the request is for calling the native container interface of a user terminal where the client is located;
intercepting the request by using a mock script injected by the server and sending the request to the server so that the server can respond to the request, and determining to return a corresponding mock response result or return the request to the container interface through a mock configuration file in the server;
receiving a return result of the server side, and performing service processing;
if the server returns the request to the container interface, the server receives a return result of the server, and performs service processing, including:
acquiring a real response result obtained by processing the request returned by the server through the container interface;
and performing service processing according to the real response result, wherein the real response result is real data returned by transmitting a request to a container interface and calling and executing the native function of the mobile phone by the container interface.
22. A mock test device comprising:
the memory stores a mock test program;
and the processor calls the mock test program in the memory and executes the following steps:
the server receives a request of calling a container interface from the client, wherein the request is intercepted by a mock script;
responding to the request, and determining to return a corresponding mock response result or return the request to the container interface;
sending a return result of the request to the client;
responding to the request based on a preset configuration file, and determining to return a corresponding mock response result or return the request to the container interface;
the sending of the returned result of the request to the client specifically includes:
acquiring a real response result obtained by processing the request returned by the server through the container interface;
and performing service processing according to the real response result, wherein the real response result is real data returned by transmitting a request to a container interface and calling and executing the native function of the mobile phone by the container interface.
CN201711428013.9A 2017-12-26 2017-12-26 mock testing method, device and equipment Active CN108345535B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711428013.9A CN108345535B (en) 2017-12-26 2017-12-26 mock testing method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711428013.9A CN108345535B (en) 2017-12-26 2017-12-26 mock testing method, device and equipment

Publications (2)

Publication Number Publication Date
CN108345535A CN108345535A (en) 2018-07-31
CN108345535B true CN108345535B (en) 2022-03-04

Family

ID=62962334

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711428013.9A Active CN108345535B (en) 2017-12-26 2017-12-26 mock testing method, device and equipment

Country Status (1)

Country Link
CN (1) CN108345535B (en)

Families Citing this family (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109165168A (en) * 2018-09-14 2019-01-08 杭州云创共享网络科技有限公司 A kind of method for testing pressure, device, equipment and medium
CN109660472B (en) * 2018-10-16 2022-04-22 深圳壹账通智能科技有限公司 Intelligent routing function verification method and device for wiring board and computer equipment
CN109344075A (en) * 2018-10-19 2019-02-15 网宿科技股份有限公司 Configuration method, test method, configuration server and service node device
CN109491689A (en) * 2018-11-20 2019-03-19 中国建设银行股份有限公司 Client process method, apparatus and system
CN109542791B (en) * 2018-11-27 2019-11-29 湖南智擎科技有限公司 A kind of program large-scale concurrent evaluating method based on container technique
CN109873735B (en) * 2018-12-14 2021-09-21 深圳壹账通智能科技有限公司 Performance test method and device for H5 page and computer equipment
CN109743222A (en) * 2018-12-25 2019-05-10 瑞庭网络技术(上海)有限公司 A kind of data test method and relevant device
CN111666199B (en) * 2019-03-05 2022-01-11 中国银联股份有限公司 Debugging method executed on intelligent terminal and software debugger
CN110188296B (en) * 2019-05-13 2021-07-13 北京百度网讯科技有限公司 Application program embedded page processing method, browser, equipment and storage medium
CN110147326B (en) * 2019-05-23 2023-05-26 四川新网银行股份有限公司 Microservice automatic test method based on Redis database
CN111198824B (en) * 2019-07-17 2022-03-25 广州市有车以后信息科技有限公司 Mock testing arrangement based on middle person agent technique
CN110750463B (en) * 2019-10-29 2023-06-23 百度在线网络技术(北京)有限公司 Method, device, system, equipment and medium for testing small program
CN111026672A (en) * 2019-12-16 2020-04-17 广州品唯软件有限公司 Test method, terminal equipment and mock server
CN111367803A (en) * 2020-03-03 2020-07-03 北京九州云动科技有限公司 Method and system for improving testing efficiency of client software
CN111797020A (en) * 2020-07-03 2020-10-20 北京每日优鲜电子商务有限公司 Mock data method and device based on dynamic bytecode
CN112162925A (en) * 2020-09-29 2021-01-01 新华三大数据技术有限公司 Test method and system based on service virtualization
CN112650689A (en) * 2020-12-31 2021-04-13 五八有限公司 Test method, test device, electronic equipment and storage medium
CN113452575B (en) * 2021-06-24 2022-11-22 河北幸福消费金融股份有限公司 Service test method, system, device and storage medium
CN115102874B (en) * 2022-06-27 2024-03-08 中国工商银行股份有限公司 Gateway system performance testing method and device and electronic equipment

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102982130A (en) * 2012-11-16 2013-03-20 深圳市融创天下科技股份有限公司 Synchronized method for not only structured query language (NOSQL) and relational database management system (RDBMS) database and system thereof
CN103729294A (en) * 2013-12-30 2014-04-16 金蝶软件(中国)有限公司 Method and device for testing performance script of application software
CN104220993A (en) * 2012-04-20 2014-12-17 惠普发展公司,有限责任合伙企业 Testing system for an integrated software system
CN106506548A (en) * 2016-12-23 2017-03-15 努比亚技术有限公司 The defence installation of cross-site scripting attack and method
CN106528400A (en) * 2016-09-22 2017-03-22 深圳峰创智诚科技有限公司 MOCK testing method and device
CN106875184A (en) * 2016-08-10 2017-06-20 阿里巴巴集团控股有限公司 Abnormal scene analogy method, device and equipment
CN106970873A (en) * 2017-01-10 2017-07-21 阿里巴巴集团控股有限公司 Mock method of testings, apparatus and system on line
CN107368405A (en) * 2016-05-11 2017-11-21 腾讯科技(北京)有限公司 Test system, method of testing, mock platforms, blocker and client

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103297475B (en) * 2012-03-01 2017-03-01 阿里巴巴集团控股有限公司 Mock service system and the processing method of Mock service
CN103634338B (en) * 2012-08-21 2017-04-12 北京亿赞普网络技术有限公司 Method for modifying primary domain name of webpage online, data processing device and system
US9146841B2 (en) * 2013-03-15 2015-09-29 Vmware, Inc. Proxy server assisted product testing
CN104410542A (en) * 2014-11-18 2015-03-11 小米科技有限责任公司 Method and device for simulation test
CN104461903B (en) * 2014-12-26 2017-07-28 北京奇虎科技有限公司 The method and apparatus of test client based on browser
CN106648556B (en) * 2015-10-28 2019-12-24 北京国双科技有限公司 Method and device for front-end and back-end integrated development test
CN105338115A (en) * 2015-11-26 2016-02-17 上海晶赞科技发展有限公司 Data server
CN105354143A (en) * 2015-12-02 2016-02-24 北京奇虎科技有限公司 Test method and device for application programs
US20170300402A1 (en) * 2016-04-19 2017-10-19 Sap Se Mock server and extensions for application testing
CN106790007A (en) * 2016-12-13 2017-05-31 武汉虹旭信息技术有限责任公司 Web attack defending systems and its method based on XSS and CSRF
CN106681922B (en) * 2016-12-27 2021-03-02 上海品顺信息科技有限公司 Response method and system of simulation server
CN107133180B (en) * 2017-06-07 2021-03-23 腾讯科技(深圳)有限公司 Dynamic page testing method, testing device and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104220993A (en) * 2012-04-20 2014-12-17 惠普发展公司,有限责任合伙企业 Testing system for an integrated software system
CN102982130A (en) * 2012-11-16 2013-03-20 深圳市融创天下科技股份有限公司 Synchronized method for not only structured query language (NOSQL) and relational database management system (RDBMS) database and system thereof
CN103729294A (en) * 2013-12-30 2014-04-16 金蝶软件(中国)有限公司 Method and device for testing performance script of application software
CN107368405A (en) * 2016-05-11 2017-11-21 腾讯科技(北京)有限公司 Test system, method of testing, mock platforms, blocker and client
CN106875184A (en) * 2016-08-10 2017-06-20 阿里巴巴集团控股有限公司 Abnormal scene analogy method, device and equipment
CN106528400A (en) * 2016-09-22 2017-03-22 深圳峰创智诚科技有限公司 MOCK testing method and device
CN106506548A (en) * 2016-12-23 2017-03-15 努比亚技术有限公司 The defence installation of cross-site scripting attack and method
CN106970873A (en) * 2017-01-10 2017-07-21 阿里巴巴集团控股有限公司 Mock method of testings, apparatus and system on line

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
单元测试中mock技术的研究和创新;伍向前;《中国优秀硕士学位论文全文数据库 信息科技辑》;20100415(第4期);第I138-183页 *

Also Published As

Publication number Publication date
CN108345535A (en) 2018-07-31

Similar Documents

Publication Publication Date Title
CN108345535B (en) mock testing method, device and equipment
CN106970873B (en) On-line mock testing method, device and system
US10565098B2 (en) Mock server for testing
CN108345531B (en) Test method, device and system
CN109144615B (en) Information publishing method, device, equipment and storage medium
CN106648556B (en) Method and device for front-end and back-end integrated development test
EP3550788A1 (en) Data acquisition method and device
CN108108219B (en) Application program running method and device, computer equipment and storage medium
CN107479868B (en) Interface loading method, device and equipment
US10803166B1 (en) Automated determination of application privileges
Adetunji et al. Dawning of progressive web applications (pwa): Edging out the pitfalls of traditional mobile development
US10705858B2 (en) Automatic import of third party analytics
CN105022620A (en) Application software development method based on mobile platform
US11853752B2 (en) Migration of web applications between different web application frameworks
CN106557411B (en) Method and system for testing Hybrid application in Android system
CN109902003B (en) Test script generation method and device
CN108304313B (en) Device, client and method for data testing
CN109857963A (en) Local resource access method, device and electronic equipment
US20190197754A1 (en) Method and Apparatus for Implementing Animation in Client Application and Animation Script Framework
CN106970872B (en) Information point burying method and device
US20130110798A1 (en) Intercepting and processing database commands
CN112650689A (en) Test method, test device, electronic equipment and storage medium
CN113157274B (en) Software development method and device based on micro front end, electronic equipment and storage medium
CN114238934A (en) Equipment information acquisition method, device, equipment and medium
CN112988604A (en) Object testing method, testing system, electronic device and readable storage medium

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 1257384

Country of ref document: HK

TA01 Transfer of patent application right

Effective date of registration: 20201020

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20201020

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant