CN117909237A - Test data preparation method, device and storage medium - Google Patents
Test data preparation method, device and storage medium Download PDFInfo
- Publication number
- CN117909237A CN117909237A CN202410083190.1A CN202410083190A CN117909237A CN 117909237 A CN117909237 A CN 117909237A CN 202410083190 A CN202410083190 A CN 202410083190A CN 117909237 A CN117909237 A CN 117909237A
- Authority
- CN
- China
- Prior art keywords
- interface
- tested
- test data
- data preparation
- target application
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 166
- 238000002360 preparation method Methods 0.000 title claims abstract description 124
- 238000003860 storage Methods 0.000 title claims abstract description 25
- 238000000034 method Methods 0.000 claims abstract description 315
- 238000004891 communication Methods 0.000 claims abstract description 20
- 238000012544 monitoring process Methods 0.000 claims abstract description 13
- 238000012545 processing Methods 0.000 claims description 22
- 238000004590 computer program Methods 0.000 claims description 6
- 230000008569 process Effects 0.000 abstract description 17
- 230000006870 function Effects 0.000 description 15
- 238000010586 diagram Methods 0.000 description 8
- 230000009471 action Effects 0.000 description 7
- 230000009286 beneficial effect Effects 0.000 description 5
- 238000013461 design Methods 0.000 description 5
- 230000003993 interaction Effects 0.000 description 5
- 230000003287 optical effect Effects 0.000 description 4
- 230000002159 abnormal effect Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 238000013507 mapping Methods 0.000 description 3
- 239000002699 waste material Substances 0.000 description 3
- 230000003190 augmentative effect Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000002347 injection Methods 0.000 description 2
- 239000007924 injection Substances 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 239000000470 constituent Substances 0.000 description 1
- 239000011521 glass Substances 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000012797 qualification Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000004984 smart glass Substances 0.000 description 1
- 239000000243 solution Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000001356 surgical procedure Methods 0.000 description 1
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application provides a test data preparation method, a device and a storage medium, relates to the technical field of communication, and can improve test data preparation efficiency. The method comprises the following steps: acquiring identification information of a target application and an interface method to be tested; the interface method to be tested is a method on a target application interface; monitoring a target application based on the identification information of the target application; when the interface method to be tested is called, determining and executing a key method corresponding to the interface method to be tested; the key method is used for assisting the interface method to be tested in completing the interface test. The method is applied to the process of test data preparation.
Description
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method and apparatus for preparing test data, and a storage medium.
Background
In the interface test process, when a target interface is called, test data preparation work needs to be finished first. When the test data is ready to be completed and accurate, the test accuracy of the target interface can be improved.
In the related art, during the preparation of test data, a server may call all methods in a target interface. However, the number of all methods within the target interface is large, and the server executing all methods in turn increases the load on the server. In addition, the logic relationship between the methods in the target interface is complex, and when a certain method is abnormal, the server may not execute the method associated with the method, reducing the efficiency of test data preparation. Therefore, how to improve the test data preparation efficiency is a technical problem yet to be solved.
Disclosure of Invention
The application provides a test data preparation method, a device and a storage medium, which can improve test data preparation efficiency.
In order to achieve the above purpose, the application adopts the following technical scheme:
In a first aspect, the present application provides a test data preparation method, the method comprising: the test data preparation device acquires identification information of a target application and an interface method to be tested; the interface method to be tested is a method on a target application interface; the test data is prepared based on the identification information of the target application, and whether an interface method to be tested in the target application is called or not is monitored; when the interface method to be tested is called, the test data is ready to determine and execute the key method corresponding to the interface method to be tested; the key method is used for assisting the interface method to be tested in completing the interface test.
In one possible implementation, basic information of a key method is acquired; the basic information includes: class path, method name and method entry; based on the basic information, a key method is performed.
In one possible implementation, the class object is obtained by reflecting the value of the class path; determining an instance object based on the class object; determining a method object based on the value of the method name and the class object; and taking the values of the method input parameters and the instance objects as input parameters, and executing a target algorithm of the method objects.
In one possible implementation, the method object is security checked.
In one possible implementation, the target algorithm includes an invoke method.
In one possible implementation, the class path includes a packet name and a class name.
In a second aspect, the present application provides a test data preparation device comprising: an acquisition unit and a processing unit; the acquisition unit is used for acquiring the identification information of the target application and the interface method to be tested; the interface method to be tested is a method on a target application interface; the processing unit is used for monitoring whether an interface method to be tested in the target application is called or not based on the identification information of the target application; the processing unit is also used for determining and executing a key method corresponding to the interface method to be tested when the interface method to be tested is called; the key method is used for assisting the interface method to be tested in completing the interface test.
In a possible implementation manner, the obtaining unit is further configured to obtain basic information of the key method; the basic information includes: class path, method name and method entry; and the processing unit is used for executing the key method based on the basic information.
In a possible implementation, the processing unit is further configured to: obtaining a class object by reflecting the numerical value of the class path; determining an instance object based on the class object; determining a method object based on the value of the method name and the class object; and taking the values of the method input parameters and the instance objects as input parameters, and executing a target algorithm of the method objects.
In a possible implementation, the processing unit is further configured to perform a security check on the method object.
In one possible implementation, the target algorithm includes an invoke method.
In one possible implementation, the class path includes a packet name and a class name.
In a third aspect, the present application provides a test data preparation apparatus comprising: a processor and a communication interface; the communication interface is coupled to a processor for running a computer program or instructions to implement the test data preparation method as described in any one of the possible implementations of the first aspect and the first aspect.
In a fourth aspect, the present application provides a computer readable storage medium having instructions stored therein which, when run on a terminal, cause the terminal to perform a test data preparation method as described in any one of the possible implementations of the first aspect and the first aspect.
In a fifth aspect, the present application provides a computer program product comprising instructions which, when run on a test data preparation device, cause the test data preparation device to perform the test data preparation method as described in any one of the possible implementations of the first aspect and the first aspect.
In a sixth aspect, the present application provides a chip comprising a processor and a communications interface, the communications interface and the processor being coupled, the processor being for running a computer program or instructions to implement a test data preparation method as described in any one of the possible implementations of the first aspect and the first aspect.
In particular, the chip provided in the present application further includes a memory for storing a computer program or instructions.
In the test data preparation method provided by the embodiment of the application, the test data preparation device acquires the identification information of the target application and the interface method to be tested on the target application interface. In this way, the test data preparation device can monitor whether the interface method to be tested in the target application is called or not according to the identification information of the target application. When the interface to be tested in the target application is about to be called, the test data preparation device determines a key method corresponding to the interface method to be tested. Because the key method can assist the interface method to be tested to complete the interface test, the key method of the test data preparation device can accurately complete the preparation work of the test data. Compared with the prior art, the server needs to execute all methods in the target interface to realize the preparation work of the test data, and when the interface method to be tested is called, the method can realize the preparation work of the test data by executing the key method. Therefore, the application can improve the test data preparation efficiency.
Drawings
FIG. 1 is a schematic diagram of a test data preparation system according to an embodiment of the present application;
Fig. 2 is a schematic structural diagram of a test data preparing device according to an embodiment of the present application;
FIG. 3 is a flowchart of a test data preparation method according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a test data preparation page according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a test data preparation interface according to an embodiment of the present application;
FIG. 6 is a flowchart of another test data preparation method according to an embodiment of the present application;
FIG. 7 is a schematic diagram of a test data preparation page according to an embodiment of the present application;
FIG. 8 is a flowchart of another test data preparation method according to an embodiment of the present application;
FIG. 9 is a flowchart of another test data preparation method according to an embodiment of the present application;
Fig. 10 is a schematic structural diagram of another test data preparing apparatus according to an embodiment of the present application.
Detailed Description
The test data preparation method, the test data preparation device and the storage medium provided by the embodiment of the application are described in detail below with reference to the accompanying drawings.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone.
The terms "first" and "second" and the like in the description and in the drawings are used for distinguishing between different objects or between different processes of the same object and not for describing a particular order of objects.
Furthermore, references to the terms "comprising" and "having" and any variations thereof in the description of the present application are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed but may optionally include other steps or elements not listed or inherent to such process, method, article, or apparatus.
It should be noted that, in the embodiments of the present application, words such as "exemplary" or "such as" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "e.g." in an embodiment should not be taken as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
In the interface test process, when a target interface is called, test data preparation work needs to be finished first. When the test data is ready to be completed and accurate, the test accuracy of the target interface can be improved.
In the related art, during the preparation of test data, a server may call all methods in a target interface. However, the number of all methods within the target interface is large, and the server executing all methods in turn increases the load on the server. In addition, the logic relationship between the methods in the target interface is complex, and when a certain method is abnormal, the server may not execute the method associated with the method, reducing the efficiency of test data preparation. Therefore, how to improve the test data preparation efficiency is a technical problem yet to be solved.
The example of fig. 1 is just a simple example, and in an actual business system, the interactions between services involved in the counting process are much more complex and the probability of being affected is much greater. In the counting process, the counting is often interrupted and failed due to some irrelevant interactions or codes, and if the key codes or methods (such as the direct execution method B-2) can be directly executed by skipping the irrelevant interactions and codes, the counting success rate is greatly improved.
The scheme at least brings the following beneficial effects: in the embodiment of the application, the test data preparation device acquires the identification information of the target application and the interface method to be tested on the target application interface. In this way, the test data preparing apparatus can monitor the target application based on the identification information of the target application. When the interface to be tested in the target application is about to be called, the test data preparation device determines a key method corresponding to the interface method to be tested. Because the key method can assist the interface method to be tested to complete the interface test, the key method of the test data preparation device can accurately complete the preparation work of the test data. Compared with the prior art, the server needs to execute all methods in the target interface to realize the preparation work of the test data, and when the interface method to be tested is called, the method can realize the preparation work of the test data by executing the key method. Therefore, the application can improve the test data preparation efficiency.
A test data preparation system 10 according to an embodiment of the present application will be described in detail below with reference to fig. 1, and as shown in fig. 1, the test data preparation system 10 includes: test data preparing device 11, terminal equipment 12.
A test data preparing device 11 configured to acquire identification information of a target application and an interface method to be tested; the interface method to be tested is a method on a target application interface; monitoring whether an interface method to be tested in the target application is called or not based on the identification information of the target application; when the interface method to be tested is called, determining and executing a key method corresponding to the interface method to be tested; the key method is used for assisting the interface method to be tested in completing the interface test.
A terminal device 12 configured to: the identification information of the target application and the interface method to be tested are sent to the test data preparation device 11.
It should be noted that the test data preparing apparatus 11 and the terminal device 12 are devices having a wireless communication function, and may be deployed on land, including indoor or outdoor, hand-held or vehicle-mounted. Can also be deployed on the water surface (such as a ship, etc.). But may also be deployed in the air (e.g., on aircraft, balloon, satellite, etc.). A user terminal, also known as a Mobile Station (MS), a terminal (MT), a terminal, etc., is a device that provides voice and/or data connectivity to a user. For example, the terminal includes a handheld device, an in-vehicle device, and the like having a wireless connection function. Currently, the terminal may be: a mobile phone), a tablet, a laptop, a palmtop, a mobile internet device (mobile INTERNET DEVICE, MID), a wearable device (e.g., a smart watch, a smart bracelet, a pedometer, etc.), a vehicle-mounted device (e.g., an automobile, a bicycle, an electric car, an airplane, a ship, a train, a high-speed rail, etc.), a Virtual Reality (VR) device, an augmented reality (augmented reality, AR) device, a wireless terminal in an industrial control (industrial control), a smart home device (e.g., a refrigerator, a television, an air conditioner, an electric meter, etc.), a smart robot, a workshop device, a wireless terminal in an unmanned (SELF DRIVING), a wireless terminal in a teleoperation (remote medical surgery), a wireless terminal in a smart grid (SMART GRID), a wireless terminal in a transportation security (transportation safety), a wireless terminal in a smart city (SMART CITY), or a wireless terminal in a smart home (smart home), a flying device (e.g., a smart robot, a hot balloon, an unmanned aerial vehicle, etc. In one possible application scenario of the application, the test data preparation device 11 and the terminal device 12 are terminal devices that are frequently operated on the ground, for example vehicle-mounted devices. In the present application, for convenience of description, a Chip disposed in the above-mentioned device, such as a System-On-a-Chip (SOC), a baseband Chip, etc., or other chips having a communication function may also be referred to as a user terminal.
Alternatively, the test data preparing device 11 and the terminal device 12 may be embedded communication devices, or may be handheld communication devices of users, including mobile phones, tablet computers, and the like.
As an example, in an embodiment of the present application, the test data preparation device 11 and the terminal device 12 may also be wearable devices. The wearable device can also be called as a wearable intelligent device, and is a generic name for intelligently designing daily wear by applying wearable technology and developing wearable devices, such as glasses, gloves, watches, clothes, shoes and the like. The wearable device is a portable device that is worn directly on the body or integrated into the clothing or accessories of the user. The wearable device is not only a hardware device, but also can realize a powerful function through software support, data interaction and cloud interaction. The generalized wearable intelligent device includes full functionality, large size, and may not rely on the smart phone to implement complete or partial functionality, such as: smart watches or smart glasses, etc., and focus on only certain types of application functions, and need to be used in combination with other devices, such as smart phones, for example, various smart bracelets, smart jewelry, etc. for physical sign monitoring.
An embodiment of the present application provides a test data preparation device, which is used for executing the test data preparation system provided by the embodiment of the present application, and fig. 2 is a schematic structural diagram of the test data preparation device provided by the embodiment of the present application. As shown in fig. 2, the test data preparation device 200 comprises at least one processor 201, a communication line 202, and at least one communication interface 204, and may further comprise a memory 203. The processor 201, the memory 203, and the communication interface 204 may be connected through a communication line 202.
Processor 201 may be a central processing unit (central processing unit, CPU), an Application SPECIFIC INTEGRATED Circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present application, such as: one or more digital signal processors (DIGITAL SIGNAL processors, dsps), or one or more field programmable gate arrays (field programmable GATE ARRAY, fpgas).
Communication line 202 may include a path for communicating information between the above-described components.
The communication interface 204, for communicating with other devices or communication networks, may use any transceiver-like device, such as ethernet, radio access network (radio access network, RAN), WLAN, etc.
The memory 203 may be, but is not limited to, a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (random access memory, RAM) or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (ELECTRICALLY ERASABLE PROGRAMMABLE READ-only memory, EEPROM), a compact disc read-only memory (compact disc read-only memory) or other optical disc storage, a compact disc storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to include or store the desired program code in the form of instructions or data structures and that can be accessed by a computer.
In a possible design, the memory 203 may exist separately from the processor 201, that is, the memory 203 may be a memory external to the processor 201, where the memory 203 may be connected to the processor 201 through a communication line 202 for storing execution instructions or application program codes, and the execution is controlled by the processor 201 to implement a test data preparation method provided by the embodiments of the present application described below. In yet another possible design, the memory 203 may be integrated with the processor 201, i.e., the memory 203 may be an internal memory of the processor 201, e.g., the memory 203 may be a cache, may be used to temporarily store some data and instruction information, etc.
In one example, processor 201 may include one or more CPUs, e.g., CPU0 and CPU1.
As an alternative implementation, the test data preparation device 200 includes a plurality of processors.
As an alternative implementation, the test data preparation apparatus 200 further comprises an output device and an input device. The output device is illustratively a display screen, speaker (speaker), etc., and the input device is a keyboard, mouse, microphone, or joystick, etc.
It should be noted that the test data preparation apparatus 200 may be a desktop computer, a portable computer, a web server, a mobile phone, a tablet computer, a wireless terminal, an embedded device, a chip system, or a device having a similar structure as in fig. 2. Furthermore, the constituent structures shown in fig. 2 do not constitute limitations on the respective apparatuses in fig. 1 and 2, and the respective apparatuses in fig. 1 and 2 may include more or less components than illustrated, or may combine some components, or may be arranged differently, in addition to the components shown in fig. 2.
In the embodiment of the application, the chip system can be composed of chips, and can also comprise chips and other discrete devices.
Further, actions, terms, and the like, which are referred to between embodiments of the present application, are not limited thereto. In the embodiment of the present application, the message identification information interacted between the devices or the parameter identification information in the message is only an example, and other identification information may be adopted in the specific implementation without limitation.
The test data preparing method provided by the embodiment of the application is described below with reference to the test data preparing system shown in fig. 1. In which the terms and the like related to the actions of the embodiments of the present application are mutually referred to, without limitation. In the embodiment of the present application, the message identification information interacted between the devices or the parameter identification information in the message is only an example, and other identification information may be adopted in the specific implementation without limitation. The actions involved in the embodiments of the present application are just an example, and other identification information may be adopted in the specific implementation, for example: the "included" of the embodiments of the present application may also be replaced by "carried on" or the like.
In order to solve the problems in the prior art, an embodiment of the present application provides a test data preparation method for implementing test data preparation. As shown in fig. 3, the method includes:
s301, the test data preparation device acquires identification information of a target application and an interface method to be tested.
The interface method to be tested is a method on the target application interface.
In a possible implementation manner, the test data preparation device sends first request information to a terminal device in the test data preparation device, where the first request information is used to request to obtain identification information of a target application and an interface method to be tested. The test data preparation device receives first response information of equipment brought into the terminal, wherein the first response information comprises identification information of a target application and an interface method to be tested.
It is understood that the tester (user) may input the identification information of the target application and the information of the interface method to be tested, etc. in the preset interface associated with the test data preparing device displayed by the terminal device.
Optionally, the preset interface may be an interface in the form of a web page, and the terminal device is an electronic device capable of displaying the web page, for example, a mobile phone, a computer, and other devices.
Alternatively, the terminal device may be a stand-alone device.
Optionally, the display interface of the terminal device includes an operation button, where the operation button includes at least one of the following: editing, deleting and adding. The identification information of the target application includes a name of the target application.
For example, as shown in fig. 4, the user may input information such as identification information (userService) of the target application, a method of interface to be tested (com.
S302, the test data preparation device monitors whether an interface method to be tested in the target application is called or not based on the identification information of the target application.
In one possible implementation manner, the test data preparation device sends first indication information to the terminal device, where the first indication information is used to trigger injection of the monitoring button, so as to achieve the purpose of monitoring the interface method to be tested in the target application.
For example, as shown in fig. 4, the test data preparation device sends first indication information to the terminal device, and the terminal device clicks the injection monitoring button based on the first indication information, so that the test data preparation device can be triggered to monitor the target application.
In another possible implementation manner, the test data preparation device sends second instruction information to the server to which the target application belongs, where the second instruction information is used to instruct the server to monitor the interface method to be tested in the target application.
It can be understood that after the server receives the second instruction information, the method of the interface to be tested in the target application is monitored, and the monitoring result is fed back to the test data preparation device in real time.
Optionally, after the test data preparation device monitors the interface method to be tested in the target application based on the identification information of the target application, the recording server may execute the second instruction information, and mount the second instruction information on the process of the target application.
Illustratively, the second indication information is: sh-p 6599-d 'service-monitor/startMonit', where 6599 is the progress of the target application (obtainable by ps-ef|grep-i xxx|awk '{ print $2}' command, xxx is the identification information of the target application). The sadbox.sh is a mounting monitoring start command of jvm-sandbox which is pre-installed on a server where a target application is located; service-monitor/startMonit refers to packet identification information of a logical packet implementing monitoring logic that is executed after the monitoring is mounted.
S303, when the interface method to be tested is called, the test data preparation device determines and executes the key method corresponding to the interface method to be tested.
The key method is used for assisting the interface method to be tested in completing the interface test.
In one possible implementation manner, when the interface method to be tested is detected to be called, the test data preparation device determines and executes the key method corresponding to the interface method to be tested based on the key method mapping table.
It should be explained that the test data preparation device inserts a listening code into the front end of the code of the interface method to be tested in the target application. When the interface method to be tested is called, the method calling device sequentially executes codes of the interface method to be tested. When the monitor code is executed, the test data preparation device can monitor that the interface method is called, thereby determining that the interface method to be tested is called. The method calling device may be a test data preparing device or other devices.
Optionally, the key method mapping table includes at least one interface method to be tested and a key method corresponding to each interface method to be tested. Any one of the at least one interface method to be tested is mapped with at least one key method.
Illustratively, the query interface method maps with methods B-1, B-2.
Illustratively, as shown in FIG. 5, the current network traffic is one second inactive and the current target interface is a second inactive query interface. The test scene is to test that when the user has preempted, the inquiry interface should return that the user has participated in the activity and is not allowed to participate in the preempting again, and the staff can inquire the participation qualification through logging in the activity page to further obtain the preempting activity. For this scenario, user data that has participated in the preemption needs to be constructed before the query interface is invoked. Under normal conditions, the server can call the first-time acquisition interface (carrying the user login session information) so that the user data is modified to be acquired, and then survey the inquiry interface (carrying the same user login session information), so that the test purpose can be achieved.
However, there may be cases where the preemption interface fails to execute. As shown in fig. 5, the preemption interface includes: code block A, code block B, code block C, code block B includes code block B-1 and code block B-2, code block B-1 is connected with other interfaces. The query interface comprises: code block D, code block E, code block F. Each code block corresponds to one method, namely, the method of the interface to be tested of the code block A is the method A, the method of the interface to be tested of the code block B is the method B, the method B comprises the method B-2, and the method of the interface to be tested of the code block C is the method C. The preemption is successful only if the user meets the active participation criteria (processed by code block B), where in code block B, method B-2 is performed to process the preemption logic if the user meets the participation criteria, to determine if the user meets the participation criteria, the method is obtained by requesting an interface of other services, if the other interface is abnormal, the subsequent method B-2 is not continuously executed, the processing of the robbery interface is failed, and the number of the manufacture is finally failed.
The scheme at least brings the following beneficial effects: in the embodiment of the application, the test data preparation device acquires the identification information of the target application and the interface method to be tested on the target application interface. In this way, the test data preparation device can monitor whether the interface method to be tested in the target application is called or not according to the identification information of the target application. When the interface to be tested in the target application is about to be called, the test data preparation device determines a key method corresponding to the interface method to be tested. Because the key method can assist the interface method to be tested to complete the interface test, the key method of the test data preparation device can accurately complete the preparation work of the test data. Compared with the prior art, the method has the advantages that the server needs to execute all methods in the target interface to realize the preparation work of the test data, and the method can realize the preparation work of the test data only by executing the key method when the method of the interface to be tested is called. Therefore, the application can improve the test data preparation efficiency.
In a possible implementation manner, as shown in fig. 6 in conjunction with fig. 3, when the interface method to be tested is called, S303, a process of determining and executing the key method corresponding to the interface method to be tested by the test data preparation device may be specifically implemented by following S601-S602.
S601, when an interface method to be tested is called, the test data preparation device acquires basic information of a key method.
Wherein the basic information includes: class path, method name and method entry; the class path includes a packet name and a class name.
In one possible implementation, the test data preparation device obtains basic information of each of the at least one key method.
It should be explained that the class path refers to the full path name of the class to which the method to be executed belongs; the method name refers to a method to be executed; method parametrization refers to parameters to be input to a method when executing a critical method.
Exemplary, as shown in fig. 7, the identification information (userService) of the target application, and the interface method to be tested (com. Xxx. Common. Controller. Action. Query), where the key methods corresponding to the interface method to be tested of the interface method to be tested include purchase and flush. The class path of the Purchase key method is com.xxx.com.action.operator, wherein com.xxx.com.action is packet name, operator is class name, and the method is incorporated into { "type": "01": "userld": "66523598412" }; the class path of the flush key method is com.xxx.common.utes.data, where com.xxx.common.utes.is the package name, data is the class name, and the method is incorporated as { "userld": "66523598412" }.
It should be noted that, as shown in fig. 7, each key method may be operated. Operations include editing and deleting. Therefore, the staff can modify the key method corresponding to the interface method to be tested according to the personal experience of the actual working scene.
Optionally, the test data preparation device may modify key method information corresponding to the interface method to be tested, and update the key method mapping table based on the modification result. Thus, the key method corresponding to the interface method to be tested can be accurately determined.
S602, the test data preparation device executes a key method based on the basic information.
In one possible implementation, the test data preparation device numbers each key method based on each key method in the acquired at least one key method. The test data preparing means sequentially executes the key methods based on the numbers of the key methods and the basic information of the key methods.
The scheme at least brings the following beneficial effects: in the embodiment of the application, the test data preparation device executes the key method based on the basic information of the key method, so that the key method can be ensured to be accurately executed when the interface method to be tested is called, the resource waste caused by executing the key method is avoided, and the test data preparation efficiency is improved.
In a possible implementation manner, as shown in fig. 8 in connection with fig. 6, the process of executing the key method by the test data preparing device based on the basic information in S602 may be implemented specifically by the following S801-S804.
S801, the test data preparation device obtains a class object by reflecting the numerical value of the class path.
Wherein the first value is used to characterize a class object, the instance object is transformed from the class object, and the class object is reflected from the first value.
In one possible implementation manner, the test data preparation device reads a first value of the class path, and performs reflection processing on the first value to obtain a class object represented by the first value.
Illustratively, the first value includes: com.xxx.com.action.operator or com.xxx.com.utels.data.
S802, the test data preparation device determines an instance object based on the class object.
In a possible implementation manner, the test data preparation device obtains a constructor object based on the class object, and obtains an instance object of the class through the constructor object.
S803, the test data preparation device determines a method object based on the numerical value of the method name and the class object.
In a possible implementation, the test data preparation device determines the method object based on the second value of the method name and the class object.
Illustratively, the second value includes: purchase or flush.
S804, the test data preparation device uses the values of the method input parameters and the example objects as input parameters, and executes the target algorithm of the method objects.
The target algorithm comprises an invoke method.
In a possible implementation, the test data preparation device uses the third value of the method parameter and the instance object as input parameters, and executes the target algorithm of the method object.
Illustratively, the second value includes: { "type": "01": "userld": "66523598412" } or { "userld": "66523598412" }.
The scheme at least brings the following beneficial effects: in the embodiment of the application, the test data preparation device executes the key method based on the basic information of the key method, so that the key method can be ensured to be accurately executed when the interface method to be tested is called, the resource waste caused by executing the key method is avoided, and the test data preparation efficiency is improved.
In a possible implementation manner, in conjunction with fig. 8, as shown in fig. 9, before S804, the test data preparation device uses the value of the method input parameter and the instance object as input parameters, and executes the target algorithm of the method object, the test data preparation device may further process the method object. The process by which the test data preparation apparatus can process the method object can also be realized specifically by the following S901.
S901, the test data preparation device performs security check on the method object.
In a possible implementation, the test data preparation device calls setAccessible (true) functions to execute the method object to enable security checking of the method object.
It should be explained that setAccessible (true) functions may prohibit checking access rights so that the test data preparation device may perform the proprietary method.
The scheme at least brings the following beneficial effects: in the embodiment of the application, the test data preparation device calls setAccessible (true) functions to execute the method objects, so that even if the key method is a private method in a certain class, the execution can be triggered independently. The method can ensure that the key method is accurately executed when the interface method to be tested is called, avoid the resource waste caused by executing the key method and improve the test data preparation efficiency.
It will be appreciated that the above-described test data preparation method may be implemented by a test data preparation device. The test data preparation device comprises corresponding hardware structures and/or software modules for executing the functions in order to realize the functions. Those of skill in the art will readily appreciate that the various illustrative modules and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments.
The embodiment of the disclosure may divide the functional modules according to the test data preparing apparatus generated by the method example described above, for example, each functional module may be divided corresponding to each function, or two or more functions may be integrated in one processing module. The integrated modules may be implemented in hardware or in software functional modules. It should be noted that, in the embodiment of the present application, the division of the modules is schematic, which is merely a logic function division, and other division manners may be implemented in actual implementation.
Fig. 10 is a schematic structural diagram of a test data preparing device according to an embodiment of the present invention. As shown in fig. 10, the test data preparing apparatus 100 may be used to perform the test data preparing methods shown in fig. 3, 6, 7, 8, and 9. The test data preparing apparatus 100 includes: an acquisition unit 1001 and a processing unit 1002.
An acquisition unit 1001 and a processing unit 1002; an obtaining unit 1001, configured to obtain identification information of a target application and an interface method to be tested; the interface method to be tested is a method on a target application interface; a processing unit 1002, configured to monitor whether an interface method to be tested in the target application is invoked based on the identification information of the target application; the processing unit 1002 is further configured to determine and execute a key method corresponding to the interface method to be tested when the interface method to be tested is called; the key method is used for assisting the interface method to be tested in completing the interface test.
In one possible implementation, the obtaining unit 1001 is further configured to obtain basic information of the key method; the basic information includes: class path, method name and method entry; the processing unit 1002 is configured to execute a key method based on the basic information.
In one possible implementation, the processing unit 1002 is further configured to: obtaining a class object by reflecting the numerical value of the class path; determining an instance object based on the class object; determining a method object based on the value of the method name and the class object; and taking the values of the method input parameters and the instance objects as input parameters, and executing a target algorithm of the method objects.
In a possible implementation, the processing unit 1002 is further configured to perform security checking on the method object.
In one possible implementation, the target algorithm includes an invoke method.
In one possible implementation, the class path includes a packet name and a class name.
From the foregoing description of the embodiments, it will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of functional modules is illustrated, and in practical application, the above-described functional allocation may be implemented by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to implement all or part of the functions described above. The specific working processes of the above-described systems, devices and units may refer to the corresponding processes in the foregoing method embodiments, which are not described herein.
The present disclosure also provides a computer-readable storage medium having instructions stored thereon that, when executed by a processor of an electronic device, enable the electronic device to perform the test data preparation method provided by the embodiments of the present disclosure described above.
The disclosed embodiments also provide a computer program product containing instructions that, when run on an electronic device, cause the electronic device to perform the test data preparation method provided by the disclosed embodiments described above.
The computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (Random Access Memory, RAM), a read-only memory (ROM), an erasable programmable read-only memory (Erasable Programmable Read Only Memory, EPROM), a register, a hard disk, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing, or any other form of computer readable storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an Application SPECIFIC INTEGRATED Circuit (ASIC). In embodiments of the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The present application is not limited to the above embodiments, and any changes or substitutions within the technical scope of the present application should be covered by the scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims (10)
1. A method of preparing test data, the method comprising:
Acquiring identification information of a target application and an interface method to be tested; the interface method to be tested is a method on the target application interface;
Monitoring whether the interface method to be tested in the target application is called or not based on the identification information of the target application;
When the interface method to be tested is called, determining and executing a key method corresponding to the interface method to be tested; the key method is used for assisting the interface method to be tested in completing interface test.
2. The method of claim 1, wherein the determining and executing the critical method comprises:
basic information of the key method is obtained; the basic information includes: class path, method name and method entry;
And executing the key method based on the basic information.
3. The method of claim 2, wherein the performing the critical method based on the base information comprises:
Obtaining a class object by reflecting the numerical value of the class path;
determining an instance object based on the class object;
Determining a method object based on the value of the method name and the class object;
And taking the values of the method input parameters and the instance objects as input parameters, and executing a target algorithm of the method objects.
4. A method according to claim 3, wherein prior to said referencing the third value of the method and said instance object as input parameters, the method further comprises:
and carrying out security check on the method object.
5. A method according to claim 3, wherein the target algorithm comprises an invoke method.
6. The method of any of claims 2-5, wherein the class path includes a packet name and a class name.
7. A test data preparation device, the device comprising: an acquisition unit and a processing unit;
the acquisition unit is used for acquiring the identification information of the target application and the interface method to be tested; the interface method to be tested is a method on the target application interface;
The processing unit is used for monitoring whether the interface method to be tested in the target application is called or not based on the identification information of the target application;
the processing unit is further used for determining and executing a key method corresponding to the interface method to be tested when the interface method to be tested is called; the key method is used for assisting the interface method to be tested in completing interface test.
8. The apparatus of claim 7, wherein the apparatus comprises:
the acquisition unit is also used for acquiring basic information of the key method; the basic information includes: class path, method name and method entry;
the processing unit is used for executing the key method based on the basic information.
9. A test data preparation device, comprising: a processor and a communication interface; the communication interface is coupled to the processor for running a computer program or instructions to implement the test data preparation method as claimed in any one of claims 1 to 6.
10. A computer readable storage medium having instructions stored therein, characterized in that when executed by a computer, the computer performs the test data preparation method as claimed in any one of the preceding claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410083190.1A CN117909237A (en) | 2024-01-19 | 2024-01-19 | Test data preparation method, device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410083190.1A CN117909237A (en) | 2024-01-19 | 2024-01-19 | Test data preparation method, device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117909237A true CN117909237A (en) | 2024-04-19 |
Family
ID=90696489
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410083190.1A Pending CN117909237A (en) | 2024-01-19 | 2024-01-19 | Test data preparation method, device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117909237A (en) |
-
2024
- 2024-01-19 CN CN202410083190.1A patent/CN117909237A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110532170B (en) | Method and device for building test environment, electronic equipment and medium | |
CN109379247A (en) | The method and device that the network delay of a kind of pair of application program is detected | |
CN110704324B (en) | Application debugging method, device and storage medium | |
CN111416756A (en) | Protocol testing method, device, computer equipment and storage medium | |
CN111897525A (en) | Big data processing method and system | |
CN111953811A (en) | Site access method, site registration method, device, equipment and storage medium | |
CN112905328B (en) | Task processing method, device and computer readable storage medium | |
CN112162843A (en) | Workflow execution method, device, equipment and storage medium | |
CN113138771B (en) | Data processing method, device, equipment and storage medium | |
CN111125436B (en) | Data management method, device and system | |
CN115604144B (en) | Test method and device, electronic equipment and storage medium | |
CN111866140A (en) | Fusion management apparatus, management system, service calling method, and medium | |
US11178506B2 (en) | Internet of Things implanted device | |
CN114417780B (en) | State synchronization method and device, electronic equipment and storage medium | |
CN110995842A (en) | Method, device and equipment for downloading service data and storage medium | |
CN117909237A (en) | Test data preparation method, device and storage medium | |
US20230070349A1 (en) | Positioning methods and cloud device | |
CN113691937B (en) | Method for determining position information, cloud mobile phone and terminal equipment | |
CN116244299A (en) | Method, device, electronic equipment and medium for determining service data path | |
CN112073505B (en) | Method for unloading on cloud server, control device and storage medium | |
CN111381979B (en) | Development verification method, device and system of neural network and storage medium | |
CN113392120A (en) | Method and device for acquiring execution information of SQLite | |
CN113312249A (en) | Log data generation method, log data display method and device | |
CN113220396B (en) | Embedded page management method and device, electronic equipment and storage medium | |
CN115348262B (en) | Cross-link operation execution method and network system based on cross-link protocol |
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 |