CN117909237A - Test data preparation method, device and storage medium - Google Patents

Test data preparation method, device and storage medium Download PDF

Info

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
key
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
Application number
CN202410083190.1A
Other languages
Chinese (zh)
Inventor
胡鹏强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China United Network Communications Group Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China United Network Communications Group Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202410083190.1A priority Critical patent/CN117909237A/en
Publication of CN117909237A publication Critical patent/CN117909237A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Energy 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

测试数据准备方法、装置及存储介质Test data preparation method, device and storage medium

技术领域Technical Field

本申请涉及通信技术领域,尤其涉及一种测试数据准备方法、装置及存储介质。The present application relates to the field of communication technology, and in particular to a test data preparation method, device and storage medium.

背景技术Background technique

接口测试的过程中,当目标接口被调用时,需要先完成测试数据准备工作。当测试数据准备完成且准确时,才能提高目标接口测试准确率。During the interface testing process, when the target interface is called, the test data preparation needs to be completed first. Only when the test data preparation is complete and accurate can the target interface test accuracy be improved.

相关技术中,在测试数据准备的过程中,服务器会调用目标接口中的所有方法。然而,目标接口内的所有方法数量多,服务器依次执行所有方法会增量服务器的负荷。另外,目标接口内的方法之间的逻辑关系复杂,当某一方法异常时,服务器可能无法执行与该方法关联的方法,降低了测试数据准备的效率。因此,如何提高测试数据准备效率是仍待解决的技术问题。In the related art, during the test data preparation process, the server will call all methods in the target interface. However, there are many methods in the target interface, and the server will increase the load if it executes all methods in sequence. In addition, the logical relationship between the methods in the target interface is complex. When a method is abnormal, the server may not be able to execute the method associated with the method, which reduces the efficiency of test data preparation. Therefore, how to improve the efficiency of test data preparation is a technical problem that needs to be solved.

发明内容Summary of the invention

本申请提供一种测试数据准备方法、装置及存储介质,能够提高测试数据准备效率。The present application provides a test data preparation method, device and storage medium, which can improve the test data preparation efficiency.

为达到上述目的,本申请采用如下技术方案:In order to achieve the above objectives, this application adopts the following technical solutions:

第一方面,本申请提供一种测试数据准备方法,该方法包括:测试数据准备装置获取目标应用的标识信息和待测接口方法;待测接口方法为目标应用接口上的方法;测试数据准备基于目标应用的标识信息,监控目标应用中的待测接口方法是否被调用;当待测接口方法被调用时,测试数据准备确定并执行待测接口方法对应的关键方法;关键方法用于协助待测接口方法完成接口测试。In a first aspect, the present application provides a test data preparation method, which includes: a test data preparation device obtains 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; the test data preparation is based on the identification information of the target application, and monitors whether the interface method to be tested in the target application is called; when the interface method to be tested is called, the test data preparation determines and executes a key method corresponding to the interface method to be tested; the key method is used to assist the interface method to be tested to complete the interface test.

在一种可能的实现方式中,获取关键方法的基础信息;基础信息包括:类路径、方法名以及方法入参;基于基础信息,执行关键方法。In a possible implementation, basic information of a key method is obtained; the basic information includes: a class path, a method name, and a method input parameter; and based on the basic information, the key method is executed.

在一种可能的实现方式中,通过对类路径的数值进行反射,得到类对象;基于类对象,确定实例对象;基于方法名的数值和类对象,确定方法对象;将方法入参的数值和实例对象作为输入参数,执行方法对象的目标算法。In one possible implementation, the class object is obtained by reflecting the value of the class path; based on the class object, the instance object is determined; based on the value of the method name and the class object, the method object is determined; and the target algorithm of the method object is executed using the value of the method input parameter and the instance object as input parameters.

在一种可能的实现方式中,对方法对象进行安全检查。In a possible implementation, a security check is performed on the method object.

在一种可能的实现方式中,目标算法包括invoke方法。In a possible implementation, the target algorithm includes an invoke method.

在一种可能的实现方式中,类路径包括包名和类名。In a possible implementation, the class path includes a package name and a class name.

第二方面,本申请提供一种测试数据准备装置,该装置包括:获取单元和处理单元;获取单元,用于获取目标应用的标识信息和待测接口方法;待测接口方法为目标应用接口上的方法;处理单元,用于基于目标应用的标识信息,监控目标应用中的待测接口方法是否被调用;处理单元,还用于当待测接口方法被调用时,确定并执行待测接口方法对应的关键方法;关键方法用于协助待测接口方法完成接口测试。In the second aspect, the present application provides a test data preparation device, which includes: an acquisition unit and a processing unit; the acquisition unit is used to acquire 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 to monitor whether the interface method to be tested in the target application is called based on the identification information of the target application; the processing unit is also used to determine and execute the key method corresponding to the interface method to be tested when the interface method to be tested is called; the key method is used to assist the interface method to be tested to complete the interface test.

在一种可能的实现方式中,获取单元,还用于获取关键方法的基础信息;基础信息包括:类路径、方法名以及方法入参;处理单元,用于基于基础信息,执行关键方法。In a possible implementation, the acquisition unit is further used to acquire basic information of the key method; the basic information includes: class path, method name and method input parameters; the processing unit is used to execute the key method based on the basic information.

在一种可能的实现方式中,处理单元,还用于:通过对类路径的数值进行反射,得到类对象;基于类对象,确定实例对象;基于方法名的数值和类对象,确定方法对象;将方法入参的数值和实例对象作为输入参数,执行方法对象的目标算法。In one possible implementation, the processing unit is also used to: obtain a class object by reflecting the value of the class path; determine the instance object based on the class object; determine the method object based on the value of the method name and the class object; and execute the target algorithm of the method object using the value of the method input parameter and the instance object as input parameters.

在一种可能的实现方式中,处理单元,还用于对方法对象进行安全检查。In a possible implementation, the processing unit is further configured to perform a security check on the method object.

在一种可能的实现方式中,目标算法包括invoke方法。In a possible implementation, the target algorithm includes an invoke method.

在一种可能的实现方式中,类路径包括包名和类名。In a possible implementation, the class path includes a package name and a class name.

第三方面,本申请提供了一种测试数据准备装置,该装置包括:处理器和通信接口;通信接口和处理器耦合,处理器用于运行计算机程序或指令,以实现如第一方面和第一方面的任一种可能的实现方式中所描述的测试数据准备方法。In a third aspect, the present application provides a test data preparation device, comprising: a processor and a communication interface; the communication interface and the processor are coupled, and the processor is used to run a computer program or instructions to implement the test data preparation method described in the first aspect and any possible implementation method of the first aspect.

第四方面,本申请提供了一种计算机可读存储介质,计算机可读存储介质中存储有指令,当指令在终端上运行时,使得终端执行如第一方面和第一方面的任一种可能的实现方式中描述的测试数据准备方法。In a fourth aspect, the present application provides a computer-readable storage medium, which stores instructions. When the instructions are executed on a terminal, the terminal executes the test data preparation method described in the first aspect and any possible implementation of the first aspect.

第五方面,本申请提供一种包含指令的计算机程序产品,当计算机程序产品在测试数据准备装置上运行时,使得测试数据准备装置执行如第一方面和第一方面的任一种可能的实现方式中所描述的测试数据准备方法。In a fifth aspect, the present application provides a computer program product comprising instructions, which, when executed on a test data preparation device, enables the test data preparation device to execute the test data preparation method as described in the first aspect and any possible implementation of the first aspect.

第六方面,本申请提供一种芯片,芯片包括处理器和通信接口,通信接口和处理器耦合,处理器用于运行计算机程序或指令,以实现如第一方面和第一方面的任一种可能的实现方式中所描述的测试数据准备方法。In a sixth aspect, the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run a computer program or instructions to implement the test data preparation method as described in the first aspect and any possible implementation method of the first aspect.

具体的,本申请中提供的芯片还包括存储器,用于存储计算机程序或指令。Specifically, the chip provided in the present application also includes a memory for storing computer programs or instructions.

本申请实施例提供的测试数据准备方法中,测试数据准备装置获取目标应用的标识信息和目标应用接口上的待测接口方法。这样,测试数据准备装置可根据目标应用的标识信息,监控目标应用中的待测接口方法是否被调用。当目标应用中的待测接口即将被调用时,测试数据准备装置确定待测接口方法对应的关键方法。由于关键方法可以协助待测接口方法完成接口测试,因此,测试数据准备装置关键方法可以准确地完成测试数据的准备工作。相比于现有技术中,服务器需要执行目标接口中的所有方法来实现测试数据的准备工作,本申请在待测接口方法被调用时,只需执行关键方法就可以实现测试数据的准备工作。因此,本申请能够提高测试数据准备效率。In the test data preparation method provided in the embodiment of the present application, the test data preparation device obtains 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 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 the key method corresponding to the interface method to be tested. Since 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 of the test data. Compared with the prior art, the server needs to execute all methods in the target interface to realize the preparation of the test data. In the present application, when the interface method to be tested is called, it only needs to execute the key method to realize the preparation of the test data. Therefore, the present application can improve the efficiency of test data preparation.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本申请实施例提供的一种测试数据准备系统的结构示意图;FIG1 is a schematic diagram of the structure of a test data preparation system provided in an embodiment of the present application;

图2为本申请实施例提供的一种测试数据准备装置的结构示意图;FIG2 is a schematic diagram of the structure of a test data preparation device provided in an embodiment of the present application;

图3为本申请实施例提供的一种测试数据准备方法的流程图;FIG3 is a flow chart of a test data preparation method provided in an embodiment of the present application;

图4为本申请实施例提供的一种测试数据准备页面的示意图;FIG4 is a schematic diagram of a test data preparation page provided in an embodiment of the present application;

图5为本申请实施例提供的一种测试数据准备接口的示意图;FIG5 is a schematic diagram of a test data preparation interface provided in an embodiment of the present application;

图6为本申请实施例提供的另一种测试数据准备方法的流程图;FIG6 is a flow chart of another test data preparation method provided in an embodiment of the present application;

图7为本申请实施例提供的一种测试数据准备页面的示意图;FIG7 is a schematic diagram of a test data preparation page provided in an embodiment of the present application;

图8为本申请实施例提供的另一种测试数据准备方法的流程图;FIG8 is a flow chart of another test data preparation method provided in an embodiment of the present application;

图9为本申请实施例提供的另一种测试数据准备方法的流程图;FIG9 is a flow chart of another test data preparation method provided in an embodiment of the present application;

图10为本申请实施例提供的另一种测试数据准备装置的结构示意图。FIG. 10 is a schematic diagram of the structure of another test data preparation device provided in an embodiment of the present application.

具体实施方式Detailed ways

下面结合附图对本申请实施例提供的测试数据准备方法、装置及存储介质进行详细地描述。The test data preparation method, device and storage medium provided in the embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。The term "and/or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and/or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

本申请的说明书以及附图中的术语“第一”和“第二”等是用于区别不同的对象,或者用于区别对同一对象的不同处理,而不是用于描述对象的特定顺序。The terms "first" and "second" and the like in the specification and drawings of this application are used to distinguish different objects, or to distinguish different processing of the same object, rather than to describe a specific order of objects.

此外,本申请的描述中所提到的术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括其他没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。In addition, the terms "including" and "having" and any variations thereof mentioned in the description of the present application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

需要说明的是,本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

接口测试的过程中,当目标接口被调用时,需要先完成测试数据准备工作。当测试数据准备完成且准确时,才能提高目标接口测试准确率。During the interface testing process, when the target interface is called, the test data preparation needs to be completed first. Only when the test data preparation is complete and accurate can the target interface test accuracy be improved.

相关技术中,在测试数据准备的过程中,服务器会调用目标接口中的所有方法。然而,目标接口内的所有方法数量多,服务器依次执行所有方法会增量服务器的负荷。另外,目标接口内的方法之间的逻辑关系复杂,当某一方法异常时,服务器可能无法执行与该方法关联的方法,降低了测试数据准备的效率。因此,如何提高测试数据准备效率是仍待解决的技术问题。In the related art, during the test data preparation process, the server will call all methods in the target interface. However, there are many methods in the target interface, and the server will increase the load if it executes all methods in sequence. In addition, the logical relationship between the methods in the target interface is complex. When a method is abnormal, the server may not be able to execute the method associated with the method, which reduces the efficiency of test data preparation. Therefore, how to improve the efficiency of test data preparation is a technical problem that needs to be solved.

上述图1的例子只是一个简单例子,在实际业务系统中,造数过程涉及的服务间的交互要复杂得多,受影响的可能性也会大得多。在造数过程中,往往会因为一些无关的交互或代码导致造数中断和失败,如果能够跳过这些无关的交互和代码,直接执行关键代码或方法(比如直接执行方法B-2),那么造数成功率将大大提升。The example in Figure 1 is just a simple example. In actual business systems, the interactions between services involved in the number-making process are much more complex and the possibility of being affected is much greater. In the number-making process, some irrelevant interactions or codes often cause number-making interruptions and failures. If these irrelevant interactions and codes can be skipped and the key code or method can be executed directly (such as directly executing method B-2), the success rate of number-making will be greatly improved.

上述方案至少带来以下有益效果:本申请实施例中,测试数据准备装置获取目标应用的标识信息和目标应用接口上的待测接口方法。这样,测试数据准备装置可根据目标应用的标识信息,监控目标应用。当目标应用中的待测接口即将被调用时,测试数据准备装置确定待测接口方法对应的关键方法。由于关键方法可以协助待测接口方法完成接口测试,因此,测试数据准备装置关键方法可以准确地完成测试数据的准备工作。相比于现有技术中,服务器需要执行目标接口中的所有方法来实现测试数据的准备工作,本申请在待测接口方法被调用时,只需执行关键方法就可以实现测试数据的准备工作。因此,本申请能够提高测试数据准备效率。The above scheme brings at least the following beneficial effects: In the embodiment of the present application, the test data preparation device obtains 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 the target application 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 the key method corresponding to the interface method to be tested. Since 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 of the test data. Compared with the prior art, the server needs to execute all methods in the target interface to realize the preparation of the test data. In the present application, when the interface method to be tested is called, it only needs to execute the key method to realize the preparation of the test data. Therefore, the present application can improve the efficiency of test data preparation.

以下,结合附图1对本申请实施例提供的一种测试数据准备系统10进行详细说明,如图1所示,该测试数据准备系统10包括:测试数据准备装置11、终端设备12。Hereinafter, a test data preparation system 10 provided in an embodiment of the present application will be described in detail in conjunction with FIG. 1 . As shown in FIG. 1 , the test data preparation system 10 includes: a test data preparation device 11 and a terminal device 12 .

测试数据准备装置11,被配置为获取目标应用的标识信息和待测接口方法;待测接口方法为目标应用接口上的方法;基于目标应用的标识信息,监控目标应用中的待测接口方法是否被调用;当待测接口方法被调用时,确定并执行待测接口方法对应的关键方法;关键方法用于协助待测接口方法完成接口测试。The test data preparation device 11 is configured to obtain the identification information of the target application and the interface method to be tested; the interface method to be tested is the method on the target application interface; based on the identification information of the target application, monitor whether the interface method to be tested in the target application is called; when the interface method to be tested is called, determine and execute the key method corresponding to the interface method to be tested; the key method is used to assist the interface method to be tested to complete the interface test.

终端设备12,被配置为:向测试数据准备装置11发送目标应用的标识信息和待测接口方法。The terminal device 12 is configured to send identification information of the target application and the interface method to be tested to the test data preparation device 11 .

本申请需要说明的是,测试数据准备装置11和终端设备12是一种具有无线通信功能的设备,可以部署在陆地上,包括室内或室外、手持或车载。也可以部署在水面上(如轮船等)。还可以部署在空中(例如飞机、气球和卫星上等)。用户终端又称之为移动台(mobilestation,MS)、终端(mobile terminal,MT)以及终端等,是一种向用户提供语音和/或数据连通性的设备。例如,终端包括具有无线连接功能的手持式设备、车载设备等。目前,终端可以是:手机(mobile phone)、平板电脑、笔记本电脑、掌上电脑、移动互联网设备(mobileinternet device,MID)、可穿戴设备(例如智能手表、智能手环、计步器等),车载设备(例如,汽车、自行车、电动车、飞机、船舶、火车、高铁等)、虚拟现实(virtual reality,VR)设备、增强现实(augmented reality,AR)设备、工业控制(industrial control)中的无线终端、智能家居设备(例如,冰箱、电视、空调、电表等)、智能机器人、车间设备、无人驾驶(selfdriving)中的无线终端、远程手术(remote medical surgery)中的无线终端、智能电网(smart grid)中的无线终端、运输安全(transportation safety)中的无线终端、智慧城市(smart city)中的无线终端,或智慧家庭(smart home)中的无线终端、飞行设备(例如,智能机器人、热气球、无人机、飞机)等。本申请一种可能的应用的场景中测试数据准备装置11和终端设备12为经常工作在地面的终端设备,例如车载设备。在本申请中,为了便于叙述,部署在上述设备中的芯片,例如片上系统(System-On-a-Chip,SOC)、基带芯片等,或者其他具备通信功能的芯片也可以称为用户终端。It should be noted that the test data preparation device 11 and the terminal device 12 are devices with wireless communication functions, which can be deployed on land, including indoors or outdoors, handheld or vehicle-mounted. It can also be deployed on the water surface (such as ships, etc.). It can also be deployed in the air (for example, on airplanes, balloons, and satellites, etc.). The user terminal is also called a mobile station (mobilestation, MS), a terminal (mobile terminal, MT), and a terminal, etc., which is a device that provides voice and/or data connectivity to users. For example, a terminal includes a handheld device with a wireless connection function, a vehicle-mounted device, etc. At present, the terminal can be: a mobile phone, a tablet computer, a laptop computer, a PDA, a mobile internet device (MID), a wearable device (such as a smart watch, a smart bracelet, a pedometer, etc.), an in-vehicle device (such as a car, a bicycle, an electric car, an airplane, a ship, a train, a high-speed train, etc.), a virtual reality (VR) device, an augmented reality (AR) device, a wireless terminal in industrial control, a smart home device (such as a refrigerator, a TV, an air conditioner, an electric meter, etc.), an intelligent robot, a workshop device, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in a smart grid, a wireless terminal in transportation safety, a wireless terminal in a smart city, or a wireless terminal in a smart home, a flying device (such as an intelligent robot, a hot air balloon, a drone, an airplane), etc. In a possible application scenario of the present application, the test data preparation device 11 and the terminal device 12 are terminal devices that often work on the ground, such as an in-vehicle device. In this application, for the sake of convenience, chips deployed in the above-mentioned devices, such as system-on-a-chip (SOC), baseband chips, etc., or other chips with communication functions may also be referred to as user terminals.

可选的,测试数据准备装置11和终端设备12可以是嵌入式通信装置,也可以是用户手持通信设备,包括手机,平板电脑等。Optionally, the test data preparation device 11 and the terminal device 12 may be embedded communication devices or user handheld communication devices, including mobile phones, tablet computers, etc.

作为示例,在本申请实施例中,该测试数据准备装置11和终端设备12还可以是可穿戴设备。可穿戴设备也可以称为穿戴式智能设备,是应用穿戴式技术对日常穿戴进行智能化设计、开发出可以穿戴的设备的总称,如眼镜、手套、手表、服饰及鞋等。可穿戴设备即直接穿在身上,或是整合到用户的衣服或配件的一种便携式设备。可穿戴设备不仅仅是一种硬件设备,更是通过软件支持以及数据交互、云端交互来实现强大的功能。广义穿戴式智能设备包括功能全、尺寸大、可不依赖智能手机实现完整或者部分的功能,例如:智能手表或智能眼镜等,以及只专注于某一类应用功能,需要和其它设备如智能手机配合使用,如各类进行体征监测的智能手环、智能首饰等。As an example, in an embodiment of the present application, the test data preparation device 11 and the terminal device 12 can also be wearable devices. Wearable devices can also be called wearable smart devices, which are a general term for wearable devices that use wearable technology to intelligently design and develop wearable devices for daily wear, such as glasses, gloves, watches, clothing and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also powerful functions achieved through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and independent of smartphones to achieve complete or partial functions, such as smart watches or smart glasses, as well as those that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for vital sign monitoring.

本申请实施例提供了一种测试数据准备装置,用于执行本申请实施例提供的测试数据准备系统,图2为本申请实施例提供的一种测试数据准备装置的结构示意图。如图2所示,该测试数据准备装置200包括至少一个处理器201,通信线路202,以及至少一个通信接口204,还可以包括存储器203。其中,处理器201,存储器203以及通信接口204三者之间可以通过通信线路202连接。The embodiment of the present application provides a test data preparation device for executing the test data preparation system provided by the embodiment of the present application. FIG2 is a schematic diagram of the structure of a test data preparation device provided by the embodiment of the present application. As shown in FIG2, the test data preparation device 200 includes at least one processor 201, a communication line 202, and at least one communication interface 204, and may also include a memory 203. Among them, the processor 201, the memory 203 and the communication interface 204 can be connected through the communication line 202.

处理器201可以是一个中央处理器(central processing unit,CPU),也可以是特定集成电路(application specific integrated circuit,ASIC),或者是被配置成实施本申请实施例的一个或多个集成电路,例如:一个或多数量字信号处理器(digital signalprocessor,DSP),或,一个或者多个现场可编程门阵列(field programmable gate array,FPGA)。The processor 201 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application, such as one or more digital signal processors (DSP), or one or more field programmable gate arrays (FPGA).

通信线路202可以包括一通路,用于在上述组件之间传送信息。The communication link 202 may include a pathway for transmitting information between the above-mentioned components.

通信接口204,用于与其他设备或通信网络通信,可以使用任何收发器一类的装置,如以太网,无线接入网(radio access network,RAN),WLAN等。The communication interface 204 is used to communicate with other devices or communication networks, and can use any transceiver-like device, such as Ethernet, radio access network (RAN), WLAN, etc.

存储器203可以是只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)或者可存储信息和指令的其他类型的动态存储设备,也可以是电可擦可编程只读存储器(electricallyerasable programmable read-only memory,EEPROM)、只读光盘(compact disc read-only memory,CD-ROM)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其他磁存储设备、或者能够用于包括或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。The memory 203 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compressed optical disc, a laser disc, an optical disc, a digital versatile disc, a 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 desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.

一种可能的设计中,存储器203可以独立于处理器201存在,即存储器203可以为处理器201外部的存储器,此时,存储器203可以通过通信线路202与处理器201相连接,用于存储执行指令或者应用程序代码,并由处理器201来控制执行,实现本申请下述实施例提供的测试数据准备方法。又一种可能的设计中,存储器203也可以和处理器201集成在一起,即存储器203可以为处理器201的内部存储器,例如,该存储器203为高速缓存,可以用于暂存一些数据和指令信息等。In one possible design, the memory 203 can exist independently of the processor 201, that is, the memory 203 can be a memory outside the processor 201. In this case, the memory 203 can be connected to the processor 201 through the communication line 202, and is used to store execution instructions or application code, and the execution is controlled by the processor 201 to implement the test data preparation method provided in the following embodiment of the present application. In another possible design, the memory 203 can also be integrated with the processor 201, that is, the memory 203 can be the internal memory of the processor 201, for example, the memory 203 is a high-speed cache, which can be used to temporarily store some data and instruction information, etc.

在一种示例中,处理器201可以包括一个或多个CPU,例如,CPU0和CPU1。In one example, the processor 201 may include one or more CPUs, for example, CPU0 and CPU1.

作为一种可选的实现方式,测试数据准备装置200包括多个处理器。As an optional implementation, the test data preparation device 200 includes multiple processors.

作为一种可选的实现方式,测试数据准备装置200还包括输出设备和输入设备。示例性地,输出设备是显示屏、扬声器(speaker)等设备,输入设备是键盘、鼠标、麦克风或操作杆等设备。As an optional implementation, the test data preparation device 200 further includes an output device and an input device. Exemplarily, the output device is a display screen, a speaker, and the like, and the input device is a keyboard, a mouse, a microphone, or a joystick, and the like.

需要指出的是,测试数据准备装置200可以是台式机、便携式电脑、网络服务器、移动手机、平板电脑、无线终端、嵌入式设备、芯片系统或有图2中类似结构的设备。此外,图2中示出的组成结构并不构成对该图1以及图2中的各个设备的限定,除图2所示部件之外,图1以及图2在的各个设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。It should be noted that the test data preparation device 200 may be a desktop computer, a portable computer, a network server, a mobile phone, a tablet computer, a wireless terminal, an embedded device, a chip system or a device having a similar structure as shown in FIG2. In addition, the composition structure shown in FIG2 does not constitute a limitation on the various devices in FIG1 and FIG2. In addition to the components shown in FIG2, the various devices in FIG1 and FIG2 may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

本申请实施例中,芯片系统可以由芯片构成,也可以包括芯片和其他分立器件。In the embodiment of the present application, the chip system may be composed of a chip, or may include a chip and other discrete devices.

此外,本申请的各实施例之间涉及的动作、术语等均可以相互参考,不予限制。本申请的实施例中各个设备之间交互的消息标识信息或消息中的参数标识信息等只是一个示例,具体实现中也可以采用其他的标识信息,不予限制。In addition, the actions, terms, etc. involved in the various embodiments of the present application can refer to each other without limitation. The message identification information or parameter identification information in the message exchanged between the various devices in the embodiments of the present application is only an example, and other identification information can also be used in the specific implementation without limitation.

下面结合图1所示测试数据准备系统,对本申请实施例提供的测试数据准备方法进行描述。其中,本申请各实施例之间涉及的动作,术语等均可以相互参考,不予限制。本申请的实施例中各个设备之间交互的消息标识信息或消息中的参数标识信息等只是一个示例,具体实现中也可以采用其他的标识信息,不予限制。本申请各实施例涉及的动作只是一个示例,具体实现中也可以采用其他的标识信息,如:本申请实施例的“包括在”还可以替换为“承载于”或者“携带在”等。The following describes the test data preparation method provided by the embodiment of the present application in conjunction with the test data preparation system shown in Figure 1. Among them, the actions, terms, etc. involved in the various embodiments of the present application can refer to each other without limitation. The message identification information exchanged between the various devices in the embodiment of the present application or the parameter identification information in the message is only an example, and other identification information can also be used in the specific implementation without limitation. The actions involved in the various embodiments of the present application are only an example, and other identification information can also be used in the specific implementation, such as: "included in" in the embodiment of the present application can also be replaced by "carried on" or "carried in", etc.

为了解决上述现有技术中存在的问题,本申请实施例提出了一种测试数据准备方法,用于实现测试数据准备。如图3所示,该方法包括:In order to solve the problems existing in the above-mentioned prior art, the embodiment of the present application proposes a test data preparation method for implementing test data preparation. As shown in FIG3 , the method includes:

S301、测试数据准备装置获取目标应用的标识信息和待测接口方法。S301. A test data preparation device obtains 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, the test data preparation device sends a first request message to a terminal device in the test data preparation device, the first request message is used to request to obtain the identification information of the target application and the interface method to be tested. The test data preparation device receives a first response message from the device that brings the terminal, the first response message including the identification information of the target application and the interface method to be tested.

可以理解的是,测试人员(用户)可以在终端设备显示的与测试数据准备装置相关联的预设界面中,输入目标应用的标识信息和待测接口方法等信息。It is understandable that the tester (user) can input the identification information of the target application and the interface method to be tested and other information in the preset interface associated with the test data preparation apparatus displayed on 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 that can display a web page, such as a mobile phone, a computer, or other device.

可选的,终端设备还可以为独立的设备。Optionally, the terminal device may also be an independent device.

可选的,终端设备的显示界面包括操作按钮,操作按钮包括以下至少一项:编辑、删除和添加。目标应用的标识信息包括目标应用的名称。Optionally, the display interface of the terminal device includes an operation button, and the operation button includes at least one of the following: edit, delete, and add. The identification information of the target application includes the name of the target application.

示例性的,如图4所示,用户可以在图4显示的界面中输入目标应用的标识信息(userService)、待测接口方法(com.xxx.common.controller.Action.query)等信息。Exemplarily, as shown in FIG. 4 , the user may input identification information (userService) of the target application, the interface method to be tested (com.xxx.common.controller.Action.query), and other information in the interface shown in FIG. 4 .

S302、测试数据准备装置基于目标应用的标识信息,监控目标应用中的待测接口方法是否被调用。S302: The test data preparation device monitors whether the interface method to be tested in the target application is called based on the identification information of the target application.

一种可能的实现方式中,测试数据准备装置向终端设备发送第一指示信息,第一指示信息用于触发注入监控按钮,实现监控目标应用中的待测接口方法的目的。In a possible implementation, the test data preparation apparatus sends first indication information to the terminal device, and the first indication information is used to trigger an injection monitoring button to achieve the purpose of monitoring the interface method to be tested in the target application.

示例性的,如图4所示,测试数据准备装置向终端设备发送第一指示信息,终端设备基于第一指示信息点击注入监控按钮,即可触发测试数据准备装置对目标应用进行监控。Exemplarily, as shown in FIG. 4 , the test data preparation apparatus sends first indication information to the terminal device, and the terminal device clicks an injection monitoring button based on the first indication information, thereby triggering the test data preparation apparatus to monitor the target application.

另一种可能的实现方式中,测试数据准备装置向目标应用所属的服务器发送第二指示信息,第二指示信息用于指示服务器监控目标应用中的待测接口方法。In another possible implementation, the test data preparation device sends second indication information to a server to which the target application belongs, where the second indication information is used to instruct the server to monitor the interface method to be tested in the target application.

可以理解的是,服务器接收到第二指示信息后,监控目标应用中的待测接口方法,并实时向测试数据准备装置反馈监视结果。It is understandable that after receiving the second indication information, the server monitors the interface method to be tested in the target application and feeds back the monitoring result 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 indication information and mount the second indication information to the process of the target application.

示例性的,第二指示信息为:./sandbox.sh-p 6599-d'service-monitor/startMonit',其中,6599是目标应用的进程(可以通过ps-ef|grep-i xxx|awk'{print$2}'命令获得,xxx是目标应用的标识信息)。sandbox.sh是预先安装在目标应用所在服务器上的jvm-sandbox的挂载监控启动命令;service-monitor/startMonit是指实现了挂载监控后所执行的监控逻辑的逻辑包的包标识信息。Exemplarily, the second instruction information is: ./sandbox.sh-p 6599-d'service-monitor/startMonit', where 6599 is the process of the target application (which can be obtained through the ps-ef|grep-i xxx|awk'{print$2}' command, and xxx is the identification information of the target application). sandbox.sh is the mount monitoring startup command of the jvm-sandbox pre-installed on the server where the target application is located; service-monitor/startMonit refers to the package identification information of the logical package that implements the monitoring logic executed after the mount monitoring.

S303、当待测接口方法被调用时,测试数据准备装置确定并执行待测接口方法对应的关键方法。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.

其中,关键方法用于协助待测接口方法完成接口测试。Among them, the key method is used to assist the interface method to be tested to complete the interface test.

一种可能的实现方式中,当检测待测接口方法即将被调用时,测试数据准备装置基于关键方法映射表,确定并执行待测接口方法对应的关键方法。In a possible implementation, when it is detected that the interface method to be tested is about 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 the monitoring 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 will execute the code of the interface method to be tested in sequence. When the monitoring code is executed, the test data preparation device can monitor the interface method being called, thereby determining that the interface method to be tested is called. The method calling device can be a test data preparation device or other equipment.

可选的,关键方法映射表包括至少一个待测接口方法以及每个待测接口方法对应的关键方法。至少一个待测接口方法中的任意一个待测接口方法映射有至少一个关键方法。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 to at least one key method.

示例性的,查询接口方法映射有方法B-1、方法B-2。Exemplarily, the query interface method mapping includes method B-1 and method B-2.

示例性的,如图5所示,当前网络业务是一个秒杀活动,当前目标接口是秒杀活动的查询接口。测试场景是为测试当用户已抢购过时,查询接口应返回用户已参与过活动不允许再次参与抢购,工作人员可以通过登录活动页,查询参与资格,进一步获得抢购活动。对于这个场景,在调用查询接口前,需要先构造已参与了抢购的用户数据。正常情况下,可以服务器先调用一次抢购接口(需携带用户登录态session信息),使得用户数据被修改为已抢购,然后再调查询接口(携带同一用户登录态session信息),这样就能达到测试目的。Exemplarily, as shown in FIG5 , the current network service is a flash sale activity, and the current target interface is the query interface for the flash sale activity. The test scenario is to test that when a user has already purchased something, the query interface should return that the user has participated in the activity and is not allowed to participate in the purchase again. The staff can log in to the activity page, query the participation qualifications, and further obtain the purchase activity. For this scenario, before calling the query interface, it is necessary to construct the user data that has participated in the purchase. Under normal circumstances, the server can first call the purchase interface (with the user's login session information) so that the user data is modified to have been purchased, and then call the query interface (with the same user's login session information), so that the test purpose can be achieved.

然而,抢购接口可能会存在执行失败的情况。如图5中所示,抢购接口包括:代码块A、代码块B、代码块C,代码块B包括代码块B-1和代码块B-2,代码块B-1与其他接口连接。查询接口包括:代码块D、代码块E、代码块F。每个代码块对应一个方法,即代码块A的待测接口方法为方法A,代码块B的待测接口方法为方法B,方法B包括方法B-2,代码块C的待测接口方法为方法C。只有当用户符合活动参与条件时才能抢购成功(由代码块B处理),其中在代码块B中,当用户符合参与条件时才会执行方法B-2来处理抢购逻辑,而判断用户是否符合参与条件,是需要请求一个其他服务的接口来获得的,如果这个其他接口异常,那么就不会继续执行后续的方法B-2,也就会导致抢购接口处理失败,最终导致造数失败。However, the snap-up interface may fail to execute. As shown in Figure 5, the snap-up interface includes: code block A, code block B, code block C, code block B includes code block B-1 and code block B-2, and code block B-1 is connected to other interfaces. The query interface includes: code block D, code block E, and code block F. Each code block corresponds to a method, that is, the interface method to be tested of code block A is method A, the interface method to be tested of code block B is method B, method B includes method B-2, and the interface method to be tested of code block C is method C. The snap-up can only be successful (processed by code block B) when the user meets the conditions for participating in the activity. In code block B, method B-2 will be executed to process the snap-up logic when the user meets the conditions for participating. To determine whether the user meets the conditions for participating, it is necessary to request an interface of another service to obtain it. If this other interface is abnormal, the subsequent method B-2 will not be executed, which will cause the snap-up interface processing to fail, and ultimately cause the number creation to fail.

上述方案至少带来以下有益效果:本申请实施例中,测试数据准备装置获取目标应用的标识信息和目标应用接口上的待测接口方法。这样,测试数据准备装置可根据目标应用的标识信息,监控目标应用中的待测接口方法是否被调用。当目标应用中的待测接口即将被调用时,测试数据准备装置确定待测接口方法对应的关键方法。由于关键方法可以协助待测接口方法完成接口测试,因此,测试数据准备装置关键方法可以准确地完成测试数据的准备工作。相比于现有技术中,服务器需要执行目标接口中的所有方法来实现测试数据的准备工作,本申请在待测接口方法被调用是,只需执行关键方法就可以实现测试数据的准备工作。因此,本申请能够提高测试数据准备效率。The above scheme brings at least the following beneficial effects: In the embodiment of the present application, the test data preparation device obtains 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 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 the key method corresponding to the interface method to be tested. Since 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 of the test data. Compared with the prior art, the server needs to execute all methods in the target interface to realize the preparation of the test data. In the present application, when the interface method to be tested is called, it only needs to execute the key method to realize the preparation of the test data. Therefore, the present application can improve the efficiency of test data preparation.

一种可能的实现方式中,结合图3,如图6所示,S303、当待测接口方法被调用时,测试数据准备装置确定并执行待测接口方法对应的关键方法的过程具体可以通过以下S601-S602实现。In a possible implementation, in combination with FIG. 3 , as shown in FIG. 6 , S303 , when the interface method to be tested is called, the process in which the test data preparation device determines and executes the key method corresponding to the interface method to be tested can be specifically implemented by the following S601 - S602 .

S601、当待测接口方法被调用时,测试数据准备装置获取关键方法的基础信息。S601. When the interface method to be tested is called, the test data preparation device obtains basic information of the key method.

其中,基础信息包括:类路径、方法名以及方法入参;类路径包括包名和类名。The basic information includes: class path, method name, and method input parameters; the class path includes package name and class name.

一种可能的实现方式中,测试数据准备装置获取至少一个关键方法中每个关键方法的基础信息。In a possible implementation manner, the test data preparation device obtains basic information of each key method in at least one key method.

需要解释的是,类路径指的是要执行的方法所属的类的全路径名;方法名指的是要执行的方法;方法入参指的是在执行关键方法时要给方法输入的参数。It needs to 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 the method to be executed; and the method input refers to the parameters to be input into the method when executing the key method.

示例性的,如图7所示,目标应用的标识信息(userService)、待测接口方法(com.xxx.common.controller.Action.query),该待测接口方法待测接口方法对应的关键方法包括purchase和flush。Purchase关键方法的类路径为com.xxx.common.action.Operator,其中com.xxx.common.action为包名,Operator为类名,方法入参为{“type”:“01”:“userld”:“66523598412”};flush关键方法的类路径为com.xxx.common.utils.Data,其中com.xxx.common.utils.为包名,Data为类名,方法入参为{“userld”:“66523598412”}。For example, as shown in FIG7 , the identification information of the target application (userService), the interface method to be tested (com.xxx.common.controller.Action.query), and the key methods corresponding to the interface method to be tested include purchase and flush. The class path of the purchase key method is com.xxx.common.action.Operator, where com.xxx.common.action is the package name, Operator is the class name, and the method input parameter is {"type":"01":"userld":"66523598412"}; the class path of the flush key method is com.xxx.common.utils.Data, where com.xxx.common.utils. is the package name, Data is the class name, and the method input parameter is {"userld":"66523598412"}.

需要说明的是,如图7所示,每个关键方法可以被操作。操作包括编辑和删除。这样,工作人员可以根据实际的工作场景已经个人经验对待测接口方法对应的关键方法进行修改。It should be noted that, as shown in FIG7 , each key method can be operated. The operations include editing and deleting. In this way, the staff can modify the key method corresponding to the interface method to be tested according to the actual working scenario and personal experience.

可选的,测试数据准备装置可以对待测接口方法对应的关键方法信息进行修改,并基于修改结果更新关键方法映射表。这样一来,以便准确地确定待测接口方法对应的关键方法。Optionally, the test data preparation device may modify the key method information corresponding to the interface method to be tested, and update the key method mapping table based on the modification result, so as to accurately determine the key method corresponding to the interface method to be tested.

S602、测试数据准备装置基于基础信息,执行关键方法。S602: The test data preparation device executes the key method based on the basic information.

一种可能的实现方式中,测试数据准备装置基于获取到的至少一个关键方法中每个关键方法顺,对每个关键方法进行编号。测试数据准备装置基于关键方法的编号和关键方法的基础信息,依次执行关键方法。In a possible implementation, the test data preparation device numbers each key method based on the sequence of each key method in the at least one key method obtained, and executes the key methods in sequence based on the key method numbers and basic information of the key methods.

上述方案至少带来以下有益效果:本申请实施例中,测试数据准备装置基于关键方法的基础信息执行关键方法,可以确保在调用待测接口方法准确地执行关键方法,避免执行费关键方法造成的资源浪费,提高了测试数据准备效率。The above scheme brings at least the following beneficial effects: In the embodiment of the present application, the test data preparation device executes the key method based on the basic information of the key method, which can ensure that the key method is accurately executed when calling the interface method to be tested, avoid the waste of resources caused by executing the key method, and improve the test data preparation efficiency.

一种可能的实现方式中,结合图6,如图8所示,S602、测试数据准备装置基于基础信息,执行关键方法的过程具体可以通过以下S801-S804实现。In a possible implementation, in combination with FIG. 6 , as shown in FIG. 8 , S602 , the process in which the test data preparation device executes the key method based on the basic information can be specifically implemented through the following S801 - S804 .

S801、测试数据准备装置通过对类路径的数值进行反射,得到类对象。S801. The test data preparation device obtains a class object by reflecting the value of the class path.

其中,第一数值用于表征类对象,实例对象是由类对象转换得到的,类对象是对第一数值反射得到的。The first value is used to represent the class object, the instance object is converted from the class object, and the class object is obtained by reflecting the first value.

一种可能的实现方式中,测试数据准备装置读取类路径的第一数值,对第一数值进行反射处理,得到第一数值所表示的类对象。In a possible implementation, the test data preparation device reads a first value of the class path, performs reflection processing on the first value, and obtains a class object represented by the first value.

示例性的,第一数值包括:com.xxx.common.action.Operator或com.xxx.common.utils.Data。Exemplarily, the first value includes: com.xxx.common.action.Operator or com.xxx.common.utils.Data.

S802、测试数据准备装置基于类对象,确定实例对象。S802: The test data preparation device determines an instance object based on the class object.

一种可能的实现方式中,测试数据准备装置基于类对象得到构造器对象,再通过构造器对象得到该类的一个实例对象。In a possible implementation, the test data preparation device obtains a constructor object based on the class object, and then obtains an instance object of the class through the constructor object.

S803、测试数据准备装置基于方法名的数值和类对象,确定方法对象。S803: The test data preparation device determines the method object based on the 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.

示例性的,第二数值包括:purchase或flush。Exemplarily, the second value includes: purchase or flush.

S804、测试数据准备装置将方法入参的数值和实例对象作为输入参数,执行方法对象的目标算法。S804. The test data preparation device uses the numerical value and instance object of the method input as input parameters to execute the target algorithm of the method object.

其中,目标算法包括invoke方法。Among them, the target algorithm includes the invoke method.

一种可能的实现方式中,测试数据准备装置将方法入参的第三数值和实例对象作为输入参数,执行方法对象的目标算法。In a possible implementation, the test data preparation device uses the third value and the instance object of the method input as input parameters to execute the target algorithm of the method object.

示例性的,第二数值包括:{“type”:“01”:“userld”:“66523598412”}或{“userld”:“66523598412”}。Exemplarily, the second value includes: {"type":"01":"userld":"66523598412"} or {"userld":"66523598412"}.

上述方案至少带来以下有益效果:本申请实施例中,测试数据准备装置基于关键方法的基础信息执行关键方法,可以确保在调用待测接口方法准确地执行关键方法,避免执行费关键方法造成的资源浪费,提高了测试数据准备效率。The above scheme brings at least the following beneficial effects: In the embodiment of the present application, the test data preparation device executes the key method based on the basic information of the key method, which can ensure that the key method is accurately executed when calling the interface method to be tested, avoid the waste of resources caused by executing the key method, and improve the test data preparation efficiency.

一种可能的实现方式中,结合图8,如图9所示,在S804、测试数据准备装置将方法入参的数值和实例对象作为输入参数,执行方法对象的目标算法之前,测试数据准备装置还可以对方法对象进行处理。测试数据准备装置还可以对方法对象进行处理的过程具体可以通过以下S901实现。In a possible implementation, in combination with FIG8, as shown in FIG9, at S804, the test data preparation device uses the numerical value and instance object of the method input as input parameters and executes the target algorithm of the method object before the test data preparation device can also process the method object. The process that the test data preparation device can also process the method object can be specifically implemented by the following S901.

S901、测试数据准备装置对方法对象进行安全检查。S901. The test data preparation device performs a security check on the method object.

一种可能的实现方式中,测试数据准备装置调用setAccessible(true)函数来执行方法对象,以实现对方法对象进行安全检查。In a possible implementation, the test data preparation device calls the setAccessible(true) function to execute the method object to implement a security check on the method object.

需要解释的是,setAccessible(true)函数可以禁止检查访问权限,使得测试数据准备装置可以执行私有方法。It should be explained that the setAccessible(true) function can prohibit checking access rights, so that the test data preparation device can execute private methods.

上述方案至少带来以下有益效果:本申请实施例中,测试数据准备装置调用setAccessible(true)函数来执行方法对象,这样即使就算关键方法是某个类中的私有方法,也能被单独触发执行。可以确保在调用待测接口方法准确地执行关键方法,避免执行费关键方法造成的资源浪费,提高了测试数据准备效率。The above scheme brings at least the following beneficial effects: In the embodiment of the present application, the test data preparation device calls the setAccessible(true) function to execute the method object, so that even if the key method is a private method in a class, it can be triggered and executed separately. It can ensure that the key method is accurately executed when calling the interface method to be tested, avoid the waste of resources caused by executing the non-key method, and improve the efficiency of test data preparation.

可以理解的是,上述测试数据准备方法可以由测试数据准备装置实现。测试数据准备装置为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的模块及算法步骤,本申请公开实施例能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请公开实施例的范围。It is understandable that the above-mentioned test data preparation method can be implemented by a test data preparation device. In order to realize the above-mentioned functions, the test data preparation device includes hardware structures and/or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the modules and algorithm steps of each example described in the embodiments disclosed herein, the embodiments disclosed in the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiments disclosed in the present application.

本申请公开实施例可以根据上述方法示例生成的测试数据准备装置进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请公开实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。The embodiment disclosed in the present application can divide the functional modules according to the test data preparation device generated by the above method example. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment disclosed in the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

图10为本发明实施例提供的一种测试数据准备装置的结构示意图。如图10所示,测试数据准备装置100可以用于执行图3、图6、图7、图8、图9所示的测试数据准备方法。该测试数据准备装置100包括:获取单元1001和处理单元1002。FIG10 is a schematic diagram of the structure of a test data preparation device provided by an embodiment of the present invention. As shown in FIG10 , the test data preparation device 100 can be used to execute the test data preparation method shown in FIG3 , FIG6 , FIG7 , FIG8 , and FIG9 . The test data preparation device 100 includes: an acquisition unit 1001 and a processing unit 1002 .

获取单元1001和处理单元1002;获取单元1001,用于获取目标应用的标识信息和待测接口方法;待测接口方法为目标应用接口上的方法;处理单元1002,用于基于目标应用的标识信息,监控目标应用中的待测接口方法是否被调用;处理单元1002,还用于当待测接口方法被调用时,确定并执行待测接口方法对应的关键方法;关键方法用于协助待测接口方法完成接口测试。Acquisition unit 1001 and processing unit 1002; acquisition unit 1001 is used to acquire identification information of the target application and the interface method to be tested; the interface method to be tested is the method on the target application interface; processing unit 1002 is used to monitor whether the interface method to be tested in the target application is called based on the identification information of the target application; processing unit 1002 is also used to determine and execute the key method corresponding to the interface method to be tested when the interface method to be tested is called; the key method is used to assist the interface method to be tested to complete the interface test.

在一种可能的实现方式中,获取单元1001,还用于获取关键方法的基础信息;基础信息包括:类路径、方法名以及方法入参;处理单元1002,用于基于基础信息,执行关键方法。In a possible implementation, the acquisition unit 1001 is further used to acquire basic information of the key method; the basic information includes: class path, method name and method input parameters; the processing unit 1002 is used to execute the key method based on the basic information.

在一种可能的实现方式中,处理单元1002,还用于:通过对类路径的数值进行反射,得到类对象;基于类对象,确定实例对象;基于方法名的数值和类对象,确定方法对象;将方法入参的数值和实例对象作为输入参数,执行方法对象的目标算法。In one possible implementation, the processing unit 1002 is also used to: obtain a class object by reflecting the value of the class path; determine the instance object based on the class object; determine the method object based on the value of the method name and the class object; and execute the target algorithm of the method object using the value of the method input parameter and the instance object as input parameters.

在一种可能的实现方式中,处理单元1002,还用于对方法对象进行安全检查。In a possible implementation, the processing unit 1002 is further configured to perform a security check on the method object.

在一种可能的实现方式中,目标算法包括invoke方法。In a possible implementation, the target algorithm includes an invoke method.

在一种可能的实现方式中,类路径包括包名和类名。In a possible implementation, the class path includes a package name and a class name.

通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

本公开还提供了一种计算机可读存储介质,计算机可读存储介质上存储有指令,当存储介质中的指令由电子设备的处理器执行时,使得电子设备能够执行上述本公开实施例提供的测试数据准备方法。The present disclosure also provides a computer-readable storage medium having instructions stored thereon. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the test data preparation method provided by the above-mentioned embodiment of the present disclosure.

本公开实施例还提供了一种包含指令的计算机程序产品,当其在电子设备上运行时,使得电子设备执行上述本公开实施例提供的测试数据准备方法。The embodiments of the present disclosure also provide a computer program product including instructions, which, when executed on an electronic device, enables the electronic device to execute the test data preparation method provided by the embodiments of the present disclosure.

其中,计算机可读存储介质,例如可以是但不限于电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机存取存储器(Random Access Memory,RAM)、只读存储器(Read-Only Memory,ROM)、可擦式可编程只读存储器(Erasable Programmable Read Only Memory,EPROM)、寄存器、硬盘、光纤、便携式紧凑磁盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合、或者本领域熟知的任何其它形式的计算机可读存储介质。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于特定用途集成电路(Application Specific Integrated Circuit,ASIC)中。在本申请实施例中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。Among them, the computer readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a register, a hard disk, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above, or any other form of computer readable storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application-specific integrated circuit (ASIC). In the embodiments of the present application, a computer-readable storage medium may be any tangible medium that contains or stores a program, which may be used by or in conjunction with an instruction execution system, apparatus, or device.

以上,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应该以权利要求的保护范围为准。The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto, and any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims (10)

1.一种测试数据准备方法,其特征在于,所述方法包括:1. A test data preparation method, characterized in that the method comprises: 获取目标应用的标识信息和待测接口方法;所述待测接口方法为所述目标应用接口上的方法;Obtain 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; 基于所述目标应用的标识信息,监控所述目标应用中的所述待测接口方法是否被调用;Based on the identification information of the target application, monitoring whether the interface method to be tested in the target application is called; 当所述待测接口方法被调用时,确定并执行所述待测接口方法对应的关键方法;所述关键方法用于协助所述待测接口方法完成接口测试。When the interface method to be tested is called, a key method corresponding to the interface method to be tested is determined and executed; the key method is used to assist the interface method to be tested to complete the interface test. 2.根据权利要求1所述的方法,其特征在于,所述确定并执行所述关键方法,包括:2. The method according to claim 1, characterized in that the determining and executing the key method comprises: 获取所述关键方法的基础信息;所述基础信息包括:类路径、方法名以及方法入参;Obtain basic information of the key method; the basic information includes: class path, method name and method input parameters; 基于所述基础信息,执行所述关键方法。Based on the basic information, the key method is executed. 3.根据权利要求2所述的方法,其特征在于,所述基于所述基础信息,执行所述关键方法,包括:3. The method according to claim 2, characterized in that the executing the key method based on the basic information comprises: 通过对所述类路径的数值进行反射,得到类对象;Obtaining a class object by reflecting the value of the class path; 基于所述类对象,确定实例对象;Based on the class object, determining an instance object; 基于所述方法名的数值和所述类对象,确定方法对象;Determining a method object based on the value of the method name and the class object; 将所述方法入参的数值和所述实例对象作为输入参数,执行所述方法对象的目标算法。The method object's target algorithm is executed using the method's input parameter value and the instance object as input parameters. 4.根据权利要求3所述的方法,其特征在于,在所述将方法入参的第三数值和所述实例对象作为输入参数之前,所述方法还包括:4. The method according to claim 3, characterized in that before taking the third value of the method input parameter and the instance object as input parameters, the method further comprises: 对所述方法对象进行安全检查。Performs a security check on the method object. 5.根据权利要求3所述的方法,其特征在于,所述目标算法包括invoke方法。5. The method according to claim 3, characterized in that the target algorithm includes an invoke method. 6.根据权利要求2-5任一项所述的方法,其特征在于,所述类路径包括包名和类名。6. The method according to any one of claims 2 to 5, characterized in that the class path includes a package name and a class name. 7.一种测试数据准备装置,其特征在于,所述装置包括:获取单元和处理单元;7. A test data preparation device, characterized in that the device comprises: an acquisition unit and a processing unit; 所述获取单元,用于获取目标应用的标识信息和待测接口方法;所述待测接口方法为所述目标应用接口上的方法;The acquisition unit is used to acquire 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 to monitor whether the interface method to be tested in the target application is called based on the identification information of the target application; 所述处理单元,还用于当所述待测接口方法被调用时,确定并执行所述待测接口方法对应的关键方法;所述关键方法用于协助所述待测接口方法完成接口测试。The processing unit is further used 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 to assist the interface method to be tested to complete the interface test. 8.根据权利要求7所述的装置,其特征在于,所述装置包括:8. The device according to claim 7, characterized in that the device comprises: 所述获取单元,还用于获取所述关键方法的基础信息;所述基础信息包括:类路径、方法名以及方法入参;The acquisition unit is further used to acquire basic information of the key method; the basic information includes: class path, method name and method input parameters; 所述处理单元,用于基于所述基础信息,执行所述关键方法。The processing unit is used to execute the key method based on the basic information. 9.一种测试数据准备装置,其特征在于,包括:处理器和通信接口;所述通信接口和所述处理器耦合,所述处理器用于运行计算机程序或指令,以实现如权利要求1-6任一项中所述的测试数据准备方法。9. A test data preparation device, characterized in that it comprises: a processor and a communication interface; the communication interface is coupled to the processor, and the processor is used to run a computer program or instruction to implement the test data preparation method as described in any one of claims 1-6. 10.一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,其特征在于,当计算机执行该指令时,该计算机执行上述权利要求1-6任一项中所述的测试数据准备方法。10. A computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, wherein when a computer executes the instructions, the computer executes the test data preparation method described in any one of claims 1 to 6.
CN202410083190.1A 2024-01-19 2024-01-19 Test data preparation method, device and storage medium Pending CN117909237A (en)

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)

Similar Documents

Publication Publication Date Title
CN111340587B (en) A virtual commodity management method and related device
CN111090666A (en) Data processing method, device and system and computer readable storage medium
CN111104425A (en) Data processing method and device
CN114417780B (en) State synchronization method and device, electronic equipment and storage medium
CN115604144A (en) Test method and device, electronic equipment and storage medium
CN117909237A (en) Test data preparation method, device and storage medium
CN118363846A (en) Test method and device
CN114168962B (en) Method, device, terminal device and storage medium for obtaining vulnerability data
CN114205639B (en) Video processing method and device, electronic equipment and storage medium
CN113407044B (en) Method, device, equipment and storage medium for simulating terminal handle input
CN113315694B (en) Instant messaging methods, devices and electronic equipment
CN113392011B (en) A link segmentation performance testing method and device
CN111626802A (en) Method and apparatus for processing information
CN114493370A (en) A security access method and device for a business product
CN115391168A (en) Sandbox testing method, sandbox testing device, sandbox testing equipment and storage medium
CN109471708B (en) Task processing method, device and system
CN114385475A (en) Test method and related device
CN113703719A (en) Configuration method of business process and related equipment
CN113157360B (en) Method, apparatus, device, medium, and article for processing an API
CN110365664A (en) A kind of phone number register method, device and electronic equipment based on intelligent sound outgoing call
CN111124907A (en) A mobile game testing method, device and server
CN113032040B (en) Method, apparatus, device, medium, and article for processing tasks
CN115988124B (en) Method and device for determining equipment ID
CN119557210A (en) A batch testing method and related device
CN109067690B (en) Method and device for pushing offline calculation result data

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