A mock data return method and device for different scenarios

By setting a preset scenario identifier in the mock data interface and returning different mock data according to the requested identifier, the problem of single test scenario in the existing technology is solved, and the test efficiency and accuracy are improved.

CN114281678BActive Publication Date: 2025-10-03GUANGZHOU PINWEI SOFTWARE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111441012.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-30
Publication Date
2025-10-03
Estimated Expiration
2041-11-30

AI Technical Summary

Technical Problem

Existing mock solutions are difficult to support complex business scenarios, resulting in overly simple test scenarios, increasing staff workload and reducing testing efficiency.

Method used

By setting a preset scenario identifier in the mock data interface, different mock data is returned according to the requested identifier, so that the requested data can be identified, suitable for different scenarios, and improve testing efficiency.

Benefits of technology

It realizes the return of different mock data according to the different request identifiers of the user side, improves the test efficiency and accuracy, ensures the one-to-one correspondence between the preset scenarios and the actual requests, and adapts to complex and changing scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114281678B_ABST
    Figure CN114281678B_ABST
Patent Text Reader

Abstract

The present invention discloses a mock data return method for different scenarios, relates to the technical field of data processing, and includes the following steps: setting a preset scenario identifier on a mock data interface; receiving a data request from a user end, obtaining an actual request identifier corresponding to the data request; comparing the actual request identifier with the preset scenario identifier, and if they are consistent, obtaining mock data corresponding to the preset scenario identifier; receiving the mock data corresponding to the preset scenario identifier, and sending the mock data to the user end. The present invention can identify the requested data and return different mock data according to different requested identifiers, thereby realizing that the mock data return method of this solution is applicable to different scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a mock data return method and device for complex scenarios. Background Art

[0002] As we all know, the development of a project requires the cooperation of the front-end and the back-end. The back-end programmer needs to provide API interfaces for the front-end development, and then the front-end can use these interfaces to realize the expected functions of the project. Due to the complex nature of the software development process, it is often necessary to call some complex services and interfaces. Moreover, these interfaces are difficult to configure and the data is not easy to construct, so simulation construction (mock) is needed for testing.

[0003] In actual use, existing technologies have found that the same interface cannot return different data based on different request scenarios. In other words, existing mock solutions are difficult to support complex business scenarios, making existing test scenarios too simplistic. If an interface only corresponds to one scenario, different mock interfaces must be set up for different scenarios. This operation method greatly increases the workload of staff and reduces testing efficiency. Summary of the Invention

[0004] In order to solve at least one of the problems mentioned in the above background technology, the present invention provides a mock data return method and device for complex scenarios, which can identify the requested data and return different mock data according to different request identifiers. This makes the mock data return method of this solution applicable to different scenarios and improves testing efficiency.

[0005] The specific technical solutions provided by the embodiments of the present invention are as follows:

[0006] First, a mock data return method for different scenarios is provided, specifically including:

[0007] Set the preset scene identifier in the mock data interface;

[0008] Receive a data request from a user terminal and obtain an actual request identifier corresponding to the data request;

[0009] Compare the actual request identifier with the preset scenario identifier to see if they are consistent. If they are consistent, obtain the mock data corresponding to the preset scenario identifier;

[0010] The mock data corresponding to the preset scene identifier is received, and the mock data is sent to the user terminal.

[0011] Furthermore, the preset scene identifier includes one or more of a mock data tag value, a key field of the scene, and a key field of the mock data.

[0012] Furthermore, a data request from the user terminal is received and verified, and the actual request identifier is obtained after the verification is passed.

[0013] Furthermore, based on the preset scenario identifier, the input parameters of the function in the key field of the scenario are extracted;

[0014] Splitting the preset scene identifier according to the input parameter to obtain key field parameters;

[0015] Combining the key field parameters with the preset scenario identifier to generate a verification program;

[0016] The verification program verifies the data request, and obtains the actual request identifier after the verification is passed.

[0017] Furthermore, the actual request identifier is compared with the preset scenario identifier. If they are consistent, the mock data corresponding to the actual request identifier is obtained, which specifically includes:

[0018] Set the mock data tag value in the preset scene identifier;

[0019] Query the actual value of the mock data in the actual request identifier;

[0020] Determine whether the mock data tag value is consistent with the actual value of the mock data;

[0021] If they are consistent, the mock data corresponding to the preset scene identifier is obtained.

[0022] Furthermore, before comparing the actual request identifier with the preset scenario identifier, the method further includes:

[0023] Querying the preset scene identification record to determine whether the preset scene identification exists;

[0024] If it exists, then updating the preset scene identifier to the preset scene identifier, or;

[0025] If it does not exist, a new preset scene identifier is added as the preset scene identifier.

[0026] Furthermore, the preset scene identifier includes a first tag, the mock data includes a second tag, and the first tag corresponds to the second tag content.

[0027] Furthermore, the mock data includes a data interface, and the data interface is used to read the first tag and return the mock data corresponding to the preset scene identifier.

[0028] In a second aspect, a mock data return device for different scenarios is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the mock data return method for different scenarios as described above is implemented.

[0029] In a third aspect, a computer-readable storage medium is provided, storing computer-executable instructions, wherein the computer-executable instructions are used to execute the mock data return method for different scenarios as described in any one of the above claims.

[0030] The embodiments of the present invention have the following beneficial effects:

[0031] 1. By setting a preset scenario identifier in the mock data interface, then obtaining the actual request identifier from the user end, comparing the actual request identifier with the preset scenario identifier, if they are consistent, obtaining the mock data corresponding to the preset scenario identifier, and returning the mock data to the user end. By marking different scenarios and setting different mock data corresponding to different scenarios, different mock data can be returned according to the different request identifiers of the user end. This makes the mock data return method of this solution applicable to different scenarios, greatly improving testing efficiency.

[0032] 2. When comparing the actual request identifier with the preset scene identifier, by setting an index value corresponding to the preset scene identifier and an index value corresponding to the actual request identifier, it is determined whether the mock data tag value is consistent with the actual value of the mock data. If they are consistent, the data corresponding to the preset scene identifier is obtained, thereby improving the accuracy of the user-side request to obtain the corresponding mock data;

[0033] 3. Before comparing the actual request identifier with the preset request identifier, it also includes querying and judging whether the preset scene identifier exists. If it exists, the preset scene identifier is updated. If it does not exist, a new preset scene identifier is added as the preset scene identifier; the preset scene identifier is realized to be able to adapt to complex and changeable scenarios, ensuring a one-to-one correspondence between the preset scene and the actual request. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0035] Figure 1 This is a schematic diagram of a mock data return method for different scenarios provided by an embodiment of the present application;

[0036] Figure 2 is a schematic diagram of an information analysis module provided in an embodiment of the present application;

[0037] Figure 3 is a schematic diagram of an exemplary system that can be used to implement the present application. DETAILED DESCRIPTION

[0038] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0039] In the development process of a project, the cooperation of the front end and the back end is required to complete the project by calling some complex services and interfaces. However, these interfaces are difficult to configure and the data is not easy to construct. Therefore, it is necessary to test the project through mock data. The prior art has found in use that the same interface cannot return different data according to the different scenarios of the request, that is, the existing mock scheme is difficult to support complex business scenarios, making the existing test scenarios too simple. If an interface only corresponds to one scenario, different mock interfaces need to be set for different scenarios. This operation mode greatly increases the workload of the staff and makes the testing efficiency of the staff low. Based on the above problems, the inventor of the present application has proposed a mock data return method and device for different scenarios, which can identify the requested data and return different mock data according to the different identifiers of the request. The mock data return method of the present solution is applicable to different scenarios and improves testing efficiency.

[0040] Example 1

[0041] Provides a mock data return method for different scenarios, such as Figure 1 and 2 As shown, the specific steps include:

[0042] S1: Set the preset scene identifier in the mock data interface.

[0043] Specifically, a preset scene identifier is added to the proxy code, that is, different scenes are marked separately, and a preset scene identifier is set for each scene. For example, for complex scenes, they can be divided according to business types. First, they are divided into business system A, business system B, business system C, etc. from the business system perspective. Then, they are further divided according to different nodes in the business system. For example, the different storage nodes in business system A are divided into node 1, node 2, node 3, node 4, node 5, etc., and then divided according to the sub-nodes under the storage node. For example, node 1 can be specifically divided into node 101, node 102, node 103, and node 104, etc., and node 2 can be specifically divided into node 201, node 202, node 203, and node 204, etc. Through the above division method, preset scene identifiers are set for different request scenarios.

[0044] S2: Receive a data request from the user end, and obtain an actual request identifier corresponding to the data request.

[0045] Specifically, the preset scene identifier includes a mock data tag value, a key field of the scene, and a key field of the mock data.

[0046] To ensure that data requests from the user end can be matched to their corresponding preset scene identification information, a verification program is set up to receive data requests from the user end and verify the data requests. Only after the verification is passed can the corresponding actual request identification be obtained. Only after the verification is passed can subsequent matching be performed.

[0047] Specifically, based on the preset scenario identifier, the function input parameters within the scenario's key fields are extracted; the preset scenario identifier is split according to the input parameters to obtain the key field parameters; the key field parameters are combined with the preset scenario identifier to generate a verification program; the verification program is used to verify the data request. If the verification passes, the actual request identifier is obtained. If the verification fails, the actual request identifier cannot be obtained.

[0048] Specifically, a data request is received from a user terminal, a second input parameter is obtained from the data request, the input parameter is split, and parsed by a parsing module in the database. The parsed input parameter and the parsed result are matched according to a verification program. If the match is successful, verification is successful, that is, the data request matches the content of the preset scene identifier, and the actual request identifier can be obtained. If the match is not successful, verification fails, and the actual request identifier cannot be obtained.

[0049] S3: Compare the actual request identifier with the preset scenario identifier to see if they are consistent. If they are consistent, obtain the mock data corresponding to the preset scenario identifier.

[0050] Specifically, in order to further ensure the accuracy of the mock data obtained according to the data request, the actual request identifier and the preset scene identifier are also verified, including: setting the mock data tag value in the preset scene identifier; querying the actual value of the mock data in the actual request identifier; judging whether the actual value of the mock data is consistent with the mock data tag value; if they are consistent, obtaining the mock data corresponding to the preset scene identifier.

[0051] Specifically, the mock data tag value and the mock data actual value are represented by the index value. For example, if the mock data tag value is set to Index(C2:C11,3), it represents the content corresponding to the third cell in the column from C2 to C11. If the mock data actual value is set to Index(C2:C11,3), when the mock data actual value is equal to the mock data tag value, the mock data corresponding to the preset scene identifier is obtained. If the mock data actual value is Index(A2:E2,2) and the mock data actual value is not equal to the mock data tag value, the mock data corresponding to the preset scene identifier cannot be obtained.

[0052] Furthermore, to ensure that the data request from the user end can find the corresponding preset scene identifier in the database, before comparing the actual request identifier with the preset scene identifier, the process also includes: querying the preset scene identifier record to determine whether the preset scene identifier exists; if so, updating the preset scene identifier to the preset scene identifier; or, if not, adding a new preset scene identifier to the preset scene identifier. Through the above settings, the preset scene identifier in the database is updated and modified, ensuring that it can be accurately called when needed.

[0053] S4: Receive the mock data corresponding to the preset scene identifier and send the mock data to the user end.

[0054] To ensure the accuracy of the acquired mock data, a preset request identifier includes a first tag, and the mock data includes a second tag. The first tag corresponds to the second tag content. A data interface is used to read the first tag and return the mock data corresponding to the preset request identifier. By setting the first tag and the second tag, the mock data includes a data interface, ensuring that the preset request identifier corresponds to its unique mock data, thereby ensuring the accuracy of the acquired data.

[0055] Example 2

[0056] Corresponding to the above embodiments, the present application provides a mock data return device for different scenarios, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the mock data return method for different scenarios described above is implemented. Specifically, the processor includes an information receiving module, an information analyzing module, and an information sending module.

[0057] First, set the preset scene identifier for the mock data interface.

[0058] The information receiving module is used for data requests from the user end, and after passing the verification procedure, obtains the actual request identifier corresponding to the data request.

[0059] The information analysis module is used to compare and analyze whether the actual request identifier is consistent with the preset scenario identifier. If they are consistent, the mock data corresponding to the preset scenario identifier is obtained.

[0060] The information sending module is used to send mock data to the user end.

[0061] Specifically, first, a preset scene identifier is set in the mock data interface; the input parameters of the function in the key field of the scene are extracted; the preset scene identifier is split according to the input parameters to obtain the key field parameters; the key field parameters are combined into the preset scene identifier to generate a verification program; the verification program is used to verify the data request, and after the verification passes, the actual request identifier is obtained; in order to further ensure the accuracy of the mock data obtained according to the data request, the actual request identifier and the preset scene identifier are also verified, including: setting the mock data tag value in the preset scene identifier; querying the actual value of the mock data in the actual request identifier; judging whether the actual value of the mock data is consistent with the mock data tag value; if consistent, obtaining the mock data corresponding to the preset scene identifier. The mock data corresponding to the preset scene identifier is received and sent to the user end.

[0062] Specifically, the memory may also store the preset scene identifier and specific data in the first embodiment.

[0063] like Figure 3 The example system in this embodiment is shown.

[0064] like Figure 3As shown, the system can serve as the above-mentioned device of any of the mock data return methods in the above-mentioned embodiments. Specifically, the system may include one or more computer-readable media (e.g., system memory or NVM / storage device) having instructions and one or more processors (e.g., (one or more) processors) coupled to the one or more computer-readable media and configured to execute instructions to implement the module to perform the actions described in this application.

[0065] For one embodiment, the system control module may include any suitable interface controller to provide any suitable interface to at least one of the processor(s) and / or any suitable device or component in communication with the system control module.

[0066] The system control module may include a memory controller module to provide an interface to the system memory. The memory controller module may be a hardware module, a software module, and / or a firmware module.

[0067] The system memory can be used, for example, to load and store data and / or instructions for the system. For one embodiment, the system memory can include any suitable volatile memory, such as a suitable DRAM. In some embodiments, the system memory can include double data rate type four synchronous dynamic random access memory (DDR4 SDRAM).

[0068] For one embodiment, the system control module may include one or more input / output (I / O) controllers to provide interfaces to the NVM / storage devices and communication interface(s).

[0069] For example, NVM / storage devices may be used to store data and / or instructions. The NVM / storage devices may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives (HDDs), one or more compact disk (CD) drives, and / or one or more digital versatile disk (DVD) drives).

[0070] The NVM / storage device may include storage resources that are physically part of the device on which the system is installed, or it may be accessible to the device without being part of the device. For example, the NVM / storage device may be accessible over a network via (one or more) communication interfaces.

[0071] The communication interface(s) may provide an interface for the system to communicate over one or more networks and / or with any other suitable devices. The system may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols.

[0072] For one embodiment, at least one of the processor(s) may be packaged together with the logic of one or more controllers of a system control module (e.g., a memory controller module). For one embodiment, at least one of the processor(s) may be packaged together with the logic of one or more controllers of a system control module to form a system-in-package (SiP). For one embodiment, at least one of the processor(s) may be integrated on the same die with the logic of one or more controllers of a system control module. For one embodiment, at least one of the processor(s) may be integrated on the same die with the logic of one or more controllers of a system control module to form a system-on-chip (SoC).

[0073] In various embodiments, the system may be, but is not limited to, a server, a workstation, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). In various embodiments, the system may have more or fewer components and / or a different architecture. For example, in some embodiments, the system includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.

[0074] It should be noted that the application can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the application can be executed by a processor to realize the steps or functions described above. Similarly, the software program of the application (including relevant data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the application can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.

[0075] In addition, a part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present application through the operation of the computer. Those skilled in the art should understand that the form in which the computer program instruction exists in a computer-readable medium includes but is not limited to a source file, an executable file, an installation package file, etc. Accordingly, the way in which the computer program instruction is executed by the computer includes but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium that can be accessed by the computer.

[0076] Communication media include media by which communication signals containing, for example, computer-readable instructions, data structures, program modules, or other data are transmitted from one system to another. Communication media may include guided transmission media such as cables and wires (e.g., fiber optic, coaxial, etc.) and wireless (unguided transmission) media capable of propagating energy waves, such as acoustic, electromagnetic, RF, microwave, and infrared. Computer-readable instructions, data structures, program modules, or other data may be embodied as, for example, a modulated data signal in a wireless medium such as a carrier wave or similar mechanism such as that embodied as part of spread spectrum technology. The term "modulated data signal" refers to a signal that has one or more of its characteristics changed or set in such a manner as to encode information in the signal. Modulation may be analog, digital, or a hybrid modulation technique.

[0077] Here, according to one embodiment of the present application, a device is included, which includes a memory for storing computer program instructions and a processor for executing the program instructions, wherein, when the computer program instructions are executed by the processor, the device is triggered to run the methods and / or technical solutions based on the aforementioned multiple embodiments of the present application.

[0078] Example 3

[0079] Corresponding to the above embodiment, a computer-readable storage medium is provided, which stores computer-executable instructions, and the computer-executable instructions are used to execute the order full-link timeliness monitoring method as described above. In this embodiment, the computer-readable storage medium may include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. For example, computer-readable storage media include, but are not limited to, volatile memories such as random access memories (RAM, DRAM, SRAM); and non-volatile memories such as flash memory, various read-only memories (ROM, PROM, EPROM, EEPROM), magnetic and ferromagnetic / ferroelectric memories (MRAM, FeRAM); and magnetic and optical storage devices (hard disks, tapes, CDs, DVDs); or other currently known media or future developed media capable of storing computer-readable information / data for use by computer systems.

[0080] Although the preferred embodiment of the present invention has been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiment and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0081] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.

Claims

1. A mock data return method for different scenarios, characterized in that: Specifically include: Set the preset scene identifier in the mock data interface; Receive a data request from the user end, verify the data request, and obtain the actual request identifier corresponding to the data request after the verification is passed, including: based on the preset scene identifier, extract the input parameters of the function in the key field of the scene; split the preset scene identifier according to the input parameters to obtain the key field parameters; combine the key field parameters into the preset scene identifier to generate a verification program; obtain a second input parameter from the data request, split the input parameter, and parse it through a parsing module in the database, the verification program verifies the data request, and matches the parsed input parameter and the parsed result according to the verification program. If the match is successful, the verification is successful, that is, the data request matches the content of the preset scene identifier, and the actual request identifier is obtained; if the match is not successful, the verification fails, and the actual request identifier cannot be obtained; Comparing the actual request identifier with the preset scene identifier to see if they are consistent, and if so, obtaining mock data corresponding to the preset scene identifier, including: setting a mock data tag value in the preset scene identifier; querying the actual value of the mock data in the actual request identifier; determining whether the actual value of the mock data is consistent with the mock data tag value; if so, obtaining the mock data corresponding to the preset scene identifier; Receive the mock data corresponding to the preset scene identifier and send the mock data to the user end.

2. The mock data return method for different scenarios according to claim 1, characterized in that: The preset scene identifier includes one or more of a mock data tag value, a key field of the scene, and a key field of the mock data.

3. The mock data return method for different scenarios according to claim 1, characterized in that: Before comparing the actual request identifier with the preset scenario identifier, the method further includes: Querying the preset scene identification record to determine whether the preset scene identification exists; If it exists, then updating the preset scene identifier to the preset scene identifier, or; If it does not exist, a new preset scene identifier is added as the preset scene identifier.

4. The mock data return method for different scenarios according to claim 1, characterized in that: The preset request identifier is set to include a first tag, the mock data includes a second tag, and the first tag corresponds to the second tag content.

5. The mock data return method for different scenarios according to claim 4, characterized in that: The mock data includes a data interface, and the data interface is used to read the first tag and return the mock data corresponding to the preset request identifier.

6. A mock data return device for different scenarios, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the mock data return method for different scenarios according to any one of claims 1 to 5 is implemented.

7. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the mock data return method for different scenarios according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Mock data returning method and device

    CN111124873A