Automated test case determination method, apparatus, device, and storage medium
Patent Information
- Application Number
- CN202010156568.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-09
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2040-03-09
AI Technical Summary
[0029]本申请将自动化测试用例与基于AOP收集到的全函数调用链路进行一对一关联;再根据代码行变更信息,检索出基于AOP收集到的全函数调用链路的影响范围,并以此推荐变更后要执行验证的自动化测试用例,从而避免对所有的自动化测试用例均进行验证,提高了验证效率。
Smart Images

Figure CN111382073B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automated testing technology, and in particular to an automated test case determination method, apparatus, device, and storage medium. Background Technology
[0002] Automated testing is a process that transforms human-driven testing behaviors into machine-executed actions. It's a testing method that saves manpower and time costs and improves testing efficiency. Automated testing technology is widely used in the software testing field, primarily for rapid regression verification of software before release. Automated testing requires converting manual test cases into machine-executable scripting languages; this process is called automated test case development, which is both a key and challenging aspect of automated testing.
[0003] As business operations become more diversified and complex, testers will write more and more automated test cases to facilitate regression verification or continuous integration process verification. However, as the number of automated test cases increases, the time required for regression verification or basic process verification will also increase, thereby affecting the efficiency of real-time test feedback and development iteration efficiency for continuous integration projects.
[0004] Therefore, it is necessary to provide an automated test case determination method, apparatus, device, and storage medium. By updating the code, the dynamic function call chain is determined, and the automated test cases corresponding to the dynamic call chain are further determined. This identifies the test cases affected by the code changes, facilitating the verification of the determined automated test cases and avoiding the need to verify all automated test cases, thus improving verification efficiency. Summary of the Invention
[0005] This application provides a method, apparatus, device, and storage medium for determining automated test cases, which can identify the test cases affected by code changes, facilitating the verification of the identified automated test cases and avoiding the need to verify all automated test cases, thereby improving verification efficiency.
[0006] On the one hand, this application provides an automated test case determination method, the method comprising:
[0007] Obtain the target code;
[0008] When the target code undergoes iterative changes, the changed code is determined;
[0009] Determine the target function dynamic call chain set corresponding to the modified code;
[0010] Based on a preset database, a set of target automated test cases that matches the dynamic call chain set of the target function is determined.
[0011] The method for constructing the preset database includes:
[0012] During the execution of each automated test case, code is injected using aspect-oriented programming to collect dynamic function call chains;
[0013] Determine the automated test cases corresponding to each function's dynamic call chain;
[0014] The preset database is constructed based on the mapping relationship between the dynamic call chain of each function and the automated test cases.
[0015] In some embodiments, the method further includes:
[0016] The blockchain system stores the dynamic call chain corresponding to each objective function. The blockchain system includes multiple nodes, and the multiple nodes form a peer-to-peer network.
[0017] On the other hand, an automated test case determination device is provided, the device comprising:
[0018] The target code acquisition module is used to acquire target code.
[0019] The code change determination module is used to determine the code change when the target code undergoes iterative changes.
[0020] The target function dynamic call link set determination module is used to determine the target function dynamic call link set corresponding to the changed code;
[0021] The target automated test case set determination module is used to determine the target automated test case set that matches the target function dynamic call chain set based on a preset database;
[0022] It also includes a preset database construction module, which includes:
[0023] The Function Dynamic Call Chain Collection Submodule is used to collect the function dynamic call chain by injecting code through aspect-oriented programming during the execution of each automated test case.
[0024] The automated test case determination submodule is used to determine the automated test cases corresponding to each function's dynamic call chain;
[0025] The preset database construction submodule is used to construct the preset database based on the mapping relationship between each function's dynamic call chain and automated test cases.
[0026] On the other hand, an automated test case determination device is provided, the device including a processor and a memory, the memory storing at least one instruction or at least one program segment, the at least one instruction or the at least one program segment being loaded and executed by the processor to implement the automated test case determination method as described above.
[0027] On the other hand, a computer storage medium is provided, wherein at least one instruction or at least one program is stored in the computer storage medium, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the automated test case determination method as described above.
[0028] The automated test case determination method, apparatus, equipment, and storage medium provided in this application have the following technical effects:
[0029] This application associates automated test cases one-to-one with the full function call chain collected based on AOP; then, based on the code line change information, it retrieves the impact range of the full function call chain collected based on AOP, and recommends the automated test cases to be verified after the change, thereby avoiding the need to verify all automated test cases and improving verification efficiency. Attached Figure Description
[0030] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 This is a schematic diagram of an automated test case determination system provided in an embodiment of this application;
[0032] Figure 2 This is a flowchart illustrating an automated test case determination method provided in an embodiment of this application;
[0033] Figure 3 This application provides a method for determining the target function dynamic call chain set corresponding to the modified code;
[0034] Figure 4 This is a schematic diagram of a full-function dynamic call chain provided in an embodiment of this application;
[0035] Figure 5 This is a schematic diagram of the structure of a blockchain system provided in an embodiment of this application;
[0036] Figure 6This is a schematic diagram of the block structure provided in an embodiment of this application;
[0037] Figure 7 This is a schematic diagram of the full function dynamic call chain associated with automated test cases provided in an embodiment of this application;
[0038] Figure 8 This is a schematic diagram illustrating the determination of target automated test cases provided in an embodiment of this application;
[0039] Figure 9 This application provides an automated test case determination device.
[0040] Figure 10 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation
[0041] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0042] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0043] Please see Figure 1 , Figure 1 This is a schematic diagram of an automated test case determination system provided in an embodiment of this application, such as... Figure 1 As shown, this automated test case determines that the system can include at least server 01 and client 02.
[0044] Specifically, in the embodiments of this specification, server 01 may include a standalone server, a distributed server, or a server cluster consisting of multiple servers. Server 01 may include a network communication unit, a processor, and memory, etc. Specifically, server 01 can be used to determine the automated test cases affected by the changed code.
[0045] Specifically, in this embodiment of the specification, the client 02 may include physical devices such as smartphones, desktop computers, tablets, laptops, digital assistants, and smart wearable devices, and may also include software running on the physical device, such as web pages provided to users by some service providers, or applications provided to users by such service providers. Specifically, the client 02 can be used to respond to user-triggered operations, modify code, and query the automated test cases affected by the modified code.
[0046] The following describes an automated test case determination method proposed in this application. Figure 2 This is a flowchart illustrating an automated test case determination method provided in this application. This specification provides the operational steps of the method described in the embodiments or flowchart, but based on conventional or non-inventive labor, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many and does not represent the only possible execution order. In actual system or server product execution, the method can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment) as shown in the embodiments or accompanying drawings. Specifically, as... Figure 2 As shown, the method may include:
[0047] S201: Obtain the target code.
[0048] In the embodiments described in this specification, the target code may be the code corresponding to the target application.
[0049] In this embodiment of the specification, after the step of obtaining the target code, the method further includes:
[0050] In response to a code change request, the target code is iteratively modified.
[0051] In the embodiments of this specification, each iteration requirement of the user will lead to code updates in order to meet the various sub-requirements in the project iteration. By iteratively changing the target code, new code based on the target code changes is obtained.
[0052] S203: When the target code undergoes iterative changes, determine the changed code.
[0053] In the embodiments described in this specification, the modified code refers to the code in the target code that has been modified.
[0054] S205: Determine the target function dynamic call chain set corresponding to the changed code.
[0055] In the embodiments of this specification, when the modified code corresponds to multiple target functions, and each target function corresponds to a different dynamic call chain, the target function dynamic call chain set may include multiple target function dynamic call chains.
[0056] In the embodiments described in this specification, such as Figure 3 As shown, determining the target function dynamic call chain set corresponding to the changed code includes:
[0057] S2051: Determine the target function corresponding to the changed code;
[0058] In the embodiments of this specification, the change code includes added code, modified code, and deleted code; the target function includes an add function, a modify function, and a delete function; and determining the target function corresponding to the change code includes:
[0059] Determine the function corresponding to the added code;
[0060] Determine the modified function corresponding to the modified code;
[0061] Determine the deletion function corresponding to the deleted code.
[0062] S2053: Determine at least one dynamic call chain corresponding to the objective function to obtain the set of dynamic call chains for the objective function.
[0063] In the embodiments described in this specification, each target function corresponds to one or more dynamic call chains, and each dynamic call chain may include multiple sub-call functions. The set of target function dynamic call chains includes one or more target function dynamic call chains.
[0064] S207: Based on a preset database, determine the target automated test case set that matches the target function dynamic call chain set.
[0065] In the embodiments of this specification, a preset database stores the mapping relationship between function dynamic call chains and automated test cases. Typically, one automated test case corresponds to one function dynamic call chain.
[0066] In this embodiment of the specification, determining the target automated test case set that matches the target function dynamic call chain set based on a preset database includes:
[0067] Determine the dynamic call chain of each objective function in the set of objective function dynamic call chains;
[0068] Search the preset database for the target automated test cases corresponding to the dynamic call chain of each target function;
[0069] The set of target automated test cases corresponding to the dynamic call chain of each target function is defined as the target automated test case set.
[0070] In the embodiments of this specification, dynamic function call chains can be collected through aspect-oriented programming, and the correspondence between each dynamic function call chain and the corresponding automated test case can be stored.
[0071] In the embodiments of this specification, the method for constructing the preset database includes:
[0072] S301: During the execution of each automated test case, code is injected using aspect-oriented programming to collect dynamic function call chains;
[0073] In the embodiments of this specification, the step of injecting code through aspect-oriented programming to collect dynamic function call chains during the execution of each automated test case includes:
[0074] During the execution of each automated test case, determine the status information of the function corresponding to the automated test case;
[0075] When the function corresponding to the automated test case is in the compile-time or runtime state, code is injected into the function corresponding to each automated test case using aspect-oriented programming to collect the dynamic function call chain.
[0076] Aspect-Oriented Programming (AOP) refers to extracting aspects in the business process and dynamically inserting code into specified methods and locations.
[0077] In the embodiments of this specification, code enhancement techniques are not limited to code injection during compilation (such as AspectJ), but can also include code injection at runtime (such as the Instrumentation+ASM solution).
[0078] In the embodiments of this specification, the dynamic call chain corresponding to a function can be determined by the identifier and feature value of the function corresponding to the automated test case;
[0079] Specifically, the method may include:
[0080] By using the eigenvalues of each function, the target functions with correlations can be identified;
[0081] The dynamic call chain of each objective function is determined by the identifiers of each objective function and its corresponding sub-functions.
[0082] In the embodiments of this specification, the identifier corresponding to a first sub-call of the target function can be determined based on the identifier of each target function;
[0083] Based on the identifier corresponding to the Nth sub-call of the objective function, determine the identifier corresponding to the N+1th sub-call of the objective function, where N = 1, 2, ..., M, M ≥ 3 and M is a positive integer.
[0084] In the embodiments of this specification, the identifier of the corresponding sub-function can be determined based on the identifier of the objective function. For example, a hierarchical number can be added to the identifier of the objective function.
[0085] In the embodiments of this specification, the identifier can be the root identifier of each function call chain, marking the root part of the identifier, and subsequent sub-calls will add the sequence number within the hierarchy based on this.
[0086] S303: Determine the automated test cases corresponding to each function's dynamic call chain;
[0087] In the embodiments described in this specification, a function dynamic call chain can correspond to an automated test case.
[0088] S305: Construct the preset database based on the mapping relationship between the dynamic call chain of each function and the automated test cases.
[0089] In the embodiments described in this specification, the method further includes:
[0090] Regression verification or continuous verification is performed on each target automated test case in the target automated test case set.
[0091] In this embodiment of the specification, after the step of obtaining the target code, the method further includes:
[0092] In response to a code change request, the target code is iteratively modified.
[0093] In the embodiments described in this specification, the user can send a code change request to the server through their terminal.
[0094] In some embodiments, the method further includes:
[0095] The blockchain system stores the dynamic call chain corresponding to each objective function. The blockchain system includes multiple nodes, and the multiple nodes form a peer-to-peer network.
[0096] In one specific embodiment Figure 4 This is a full-function real-time call chain; such as Figure 4 As shown, in blockchain business, AOP code enhancement injection is performed on the blockchain server. Automated test cases are run one by one in the test environment or automated test environment. Simultaneously, the collection of the full function dynamic call chain is initiated, and the automated test cases are associated with the dynamic chain. When the code iterates and changes, the associated full function dynamic call chain is retrieved through code line change information, and the relevant automated test cases are deduced. Function I is the add function, and function Y is the delete function. Sub-call functions B, C, and D of the request entry function A are synchronous operations. Function F initiates an asynchronous operation, which starts from the packaging entry function H. A DataKey in the packaging entry function is the same as the DataKey of the request entry function A. Similarly, function L initiates an asynchronous operation, starting from the verification entry function K; function T initiates an asynchronous operation, starting from the submission entry function Q; and function Z initiates an asynchronous operation, starting from the storage entry function M. The association of the dynamic call chains of functions in different data processing parts assists in the analysis of the entire data processing process. Keypoint injection is performed on the entry functions of different processing parts to obtain key data features, i.e., unique identifiers, such as transaction hashes and block hashes, through reflection, and recorded in the log. Call chain injection enables real-time tracking and recording of different parts of the call chain, recorded hierarchically. The entry function has two fields: LevelNo and DataKey. LevelNo is the root identifier of each function call chain, marking the root of this part. Subsequent sub-calls will increment their hierarchical numbers based on this. For example, if LevelNo is 10340, then the first sub-call's LevelNo is 10340.1, the second sub-call is 10340.2, and the next sub-call is 10340.1.1, thus recording the entire dynamic call chain. For example, function A includes a series of sub-calls, such as...
[0097]
[0098] In this context, functions B and D are sub-calls of A.
[0099] DataKey is the key data feature value of the entry function. It serves as a unique identifier for data processing and is used to associate different parts of the function call chain.
[0100] In some embodiments, a blockchain system can be Figure 5The structure shown depicts a peer-to-peer (P2P) network formed by multiple nodes. The P2P protocol is an application layer protocol that runs on top of the Transmission Control Protocol (TCP). In a blockchain system, any machine, such as a server or terminal, can join and become a node. A node comprises a hardware layer, a middleware layer, an operating system layer, and an application layer.
[0101] Figure 5 The functions of each node in the blockchain system shown include:
[0102] 1) Routing: A basic function of nodes used to support communication between nodes.
[0103] In addition to routing capabilities, nodes can also have the following functions:
[0104] 2) Applications are deployed in the blockchain to implement specific business needs. They record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system. When other nodes successfully verify the source and integrity of the record data, they add the record data to a temporary block.
[0105] 3) A blockchain consists of a series of blocks that are sequentially generated. Once a new block is added to the blockchain, it will not be removed. The blocks contain the data submitted by the nodes in the blockchain system.
[0106] In some embodiments, the block structure can be Figure 6 The structure shown includes a hash value for each block containing the transaction records stored in that block (the hash value of this block) and the hash value of the previous block. These blocks are linked together to form the blockchain. Additionally, blocks may include information such as a timestamp when they were generated. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains relevant information used to verify the validity of the information (anti-counterfeiting) and to generate the next block.
[0107] In a specific embodiment, such as Figure 7As shown, an AOP version of the service is deployed in the test environment or automated test environment. The full function dynamic call chain is collected and associated with each automated test case. Automated test cases A, C, and D are associated with three different function dynamic call chains. The version manager analyzes the changes in the current iteration, obtaining information about function changes, such as the addition, modification, or deletion of specific logic within functions. Based on the changed function names, the full function dynamic call chain is associated, and automated test cases are recommended based on the binding relationships. For example... Figure 8 As shown, when code is added to function G and part of code is deleted from function F, since function F corresponds to two dynamic links, and these two dynamic links are associated with automated test cases C and D respectively, and since G corresponds to one dynamic link, and this dynamic link is associated with automated test case D, it can be determined that the code changes to functions G and F will affect automated test cases C and D, requiring verification of automated test cases C and D. For the application, this allows for precise analysis of the impact scope of application version iteration changes, improving continuous verification efficiency while ensuring version quality.
[0108] As can be seen from the technical solutions provided in the embodiments of this specification above, the embodiments of this specification determine the dynamic function call chain by updating the code, and further determine the automated test cases corresponding to the dynamic call chain, thereby determining the test cases affected by the code change, which facilitates the verification of the determined automated test cases, avoids verifying all automated test cases, and improves verification efficiency.
[0109] This application also provides an automated test case determination device, such as... Figure 9 As shown, the device includes:
[0110] Target code acquisition module 910 is used to acquire target code;
[0111] The change code determination module 920 is used to determine the change code when the target code undergoes iterative changes;
[0112] The target function dynamic call link set determination module 930 is used to determine the target function dynamic call link set corresponding to the changed code;
[0113] The target automated test case set determination module 940 is used to determine the target automated test case set that matches the target function dynamic call chain set based on a preset database;
[0114] It also includes a preset database construction module 950, which includes:
[0115] The Function Dynamic Call Chain Collection Submodule 9510 is used to collect the function dynamic call chain by injecting code through aspect-oriented programming during the execution of each automated test case.
[0116] The automated test case determination submodule 9520 is used to determine the automated test cases corresponding to each function's dynamic call chain.
[0117] The preset database construction submodule 9530 is used to construct the preset database based on the mapping relationship between each function's dynamic call chain and automated test cases.
[0118] In some embodiments, the objective function dynamic call link set determination module may include:
[0119] The objective function determination submodule is used to determine the objective function corresponding to the modified code;
[0120] The target function dynamic call link set determination submodule is used to determine at least one dynamic call link corresponding to the target function, thereby obtaining the target function dynamic call link set.
[0121] In some embodiments, the change code includes added code, modified code, and deleted code; the target function includes an add function, a modify function, and a delete function; and the target function determination submodule may include:
[0122] An additional function determination unit is added to determine the added function corresponding to the added code;
[0123] A function determination unit is used to determine the modified function corresponding to the modified code;
[0124] The deletion function determination unit is used to determine the deletion function corresponding to the deleted code.
[0125] In some embodiments, the function dynamic call chain collection submodule may include:
[0126] The status information determination unit is used to determine the status information of the function corresponding to the automated test case during the execution of each automated test case.
[0127] The function dynamic call chain collection unit is used to collect the function dynamic call chain by injecting code into the function corresponding to each automated test case through aspect-oriented programming when the function corresponding to the automated test case is in the compile-time or runtime state.
[0128] In some embodiments, the target automated test case set determination module includes:
[0129] The objective function dynamic call chain determination submodule is used to determine the dynamic call chain of each objective function in the objective function dynamic call chain set.
[0130] The target automated test case determination submodule is used to search the preset database for target automated test cases corresponding to the dynamic call chain of each target function.
[0131] The target automated test case set determination submodule is used to determine the set of target automated test cases corresponding to each target function's dynamic call chain as the target automated test case set.
[0132] In some embodiments, the apparatus may further include:
[0133] The verification module is used to perform regression verification or continuous verification on each target automated test case in the target automated test case set.
[0134] In some embodiments, the apparatus may further include:
[0135] The iterative change module is used to perform iterative changes on the target code in response to a code change request.
[0136] The apparatus and method embodiments described herein are based on the same inventive concept.
[0137] This application provides an automated test case determination device, which includes a processor and a memory. The memory stores at least one instruction or at least one program segment, which is loaded and executed by the processor to implement the automated test case determination method provided in the above method embodiments.
[0138] The embodiments of this application also provide a computer storage medium, which can be disposed in a terminal to store at least one instruction or at least one program related to implementing an automated test case determination method in the method embodiments. The at least one instruction or the at least one program is loaded and executed by the processor to implement the automated test case determination method provided in the above method embodiments.
[0139] Optionally, in the embodiments of this specification, the computer storage medium may be located at at least one of the multiple network servers in a computer network. Optionally, in this embodiment, the aforementioned storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0140] The memory described in the embodiments of this specification can be used to store software programs and modules. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for the functions, etc.; the data storage area may store data created according to the use of the device, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor with access to the memory.
[0141] The automated test case determination method provided in this application can be executed on a mobile terminal, computer terminal, server, or similar computing device. Taking running on a server as an example... Figure 10 This is a hardware structure block diagram of a server for an automated test case determination method provided in an embodiment of this application. For example... Figure 10 As shown, the server 1000 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 1010 (CPUs 1010 may include, but are not limited to, microprocessors (MCUs) or programmable logic devices (FPGAs), a memory 1030 for storing data, and one or more storage media 1020 (e.g., one or more mass storage devices) for storing application programs 1023 or data 1022. The memory 1030 and storage media 1020 may be temporary or persistent storage. The program stored in the storage media 1020 may include one or more modules, each module may include a series of instruction operations on the server. Furthermore, the CPU 1010 may be configured to communicate with the storage media 1020 and execute the series of instruction operations in the storage media 1020 on the server 1000. Server 1000 may also include one or more power supplies 1060, one or more wired or wireless network interfaces 1050, one or more input / output interfaces 1040, and / or one or more operating systems 1021, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0142] The input / output interface 1040 can be used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of server 1000. In one example, the input / output interface 1040 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the input / output interface 1040 may be a radio frequency (RF) module for wireless communication with the Internet.
[0143] Those skilled in the art will understand that Figure 10 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, server 1000 may also include... Figure 10 The more or fewer components shown, or having the same Figure 10 The different configurations shown.
[0144] As can be seen from the embodiments of the automated test case determination method, apparatus, server or storage medium provided in this application, this application determines the dynamic function call chain by updating the code, and further determines the automated test cases corresponding to the dynamic call chain, thereby determining the test cases affected by the code change, which facilitates the verification of the determined automated test cases, avoids verifying all automated test cases, and improves verification efficiency.
[0145] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0146] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, devices, and storage media are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0147] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0148] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for determining automated test cases, characterized in that, The method includes: Obtain the target code; When the target code undergoes iterative changes, the changed code is determined; Determine the target function corresponding to the modified code; determine at least one dynamic call chain corresponding to the target function to obtain the dynamic call chain set of the target function corresponding to the modified code; Determine the dynamic call chain of each objective function in the set of objective function dynamic call chains; Search the preset database for the target automated test cases corresponding to the dynamic call chain of each target function; The set of target automated test cases corresponding to each target function dynamic call chain is determined as the target automated test case set that matches the target function dynamic call chain set. The method for constructing the preset database includes: During the execution of each automated test case, code is injected using aspect-oriented programming to collect dynamic function call chains; Keypoint injection is performed on the entry functions of different data processing parts to obtain key features of the data through reflection. The entry function includes two fields: a root identifier for each function call chain and a key data feature value. The key data feature value serves as a unique identifier for data processing and is used to associate different parts of the function call chain. Real-time tracking and recording of different parts of the call chain are achieved through call chain injection, and the recording is performed in a hierarchical manner. The root identifier marks the root part of each function call chain, and subsequent sub-calls are based on the root identifier and add a sequence number within the hierarchy to record the entire dynamic call chain. By using the feature values of the functions corresponding to the automated test cases, the target functions with related relationships are determined; by using the identifiers of each target function and its corresponding sub-functions, the dynamic call chain of each target function is determined. Determine the automated test cases corresponding to each function's dynamic call chain; The preset database is constructed based on the mapping relationship between the dynamic call chain of each function and the automated test cases.
2. The method according to claim 1, characterized in that, The change code includes added code, modified code, and deleted code; the target function includes an add function, a modify function, and a delete function; and determining the target function corresponding to the change code includes: Determine the function corresponding to the added code; Determine the modified function corresponding to the modified code; Determine the deletion function corresponding to the deleted code.
3. The method according to claim 1, characterized in that, During the execution of each automated test case, code is injected using aspect-oriented programming to collect dynamic function call chains, including: During the execution of each automated test case, determine the status information of the function corresponding to the automated test case; When the function corresponding to the automated test case is in the compile-time or runtime state, code is injected into the function corresponding to each automated test case through aspect-oriented programming to collect the dynamic function call chain.
4. The method according to claim 1, characterized in that, The method further includes: Regression verification or continuous verification is performed on each target automated test case in the target automated test case set.
5. The method according to claim 1, characterized in that, After the step of obtaining the target code, the method further includes: In response to a code change request, the target code is iteratively modified.
6. An automated test case determination device, characterized in that, The device includes: The target code acquisition module is used to acquire target code. The code change determination module is used to determine the code change when the target code undergoes iterative changes. The target function dynamic call link set determination module is used to determine the target function dynamic call link set corresponding to the modified code; the target function dynamic call link set determination module includes: a target function determination submodule, used to determine the target function corresponding to the modified code; and a target function dynamic call link set determination submodule, used to determine at least one dynamic call link corresponding to the target function, to obtain the target function dynamic call link set; The target automated test case set determination module is used to determine a target automated test case set that matches the target function dynamic call link set based on a preset database. The target automated test case set determination module includes: a target function dynamic call link determination submodule, used to determine each target function dynamic call link in the target function dynamic call link set; a target automated test case determination submodule, used to search the preset database for target automated test cases corresponding to each target function dynamic call link; and a target automated test case set determination submodule, used to determine the set of target automated test cases corresponding to each target function dynamic call link as the target automated test case set. It also includes a preset database construction module, which includes: The Function Dynamic Call Chain Collection Submodule is used to collect the function dynamic call chain by injecting code through aspect-oriented programming during the execution of each automated test case. The automated test case determination submodule is used to determine the automated test cases corresponding to each function's dynamic call chain; The preset database construction submodule is used to construct the preset database based on the mapping relationship between each function's dynamic call chain and automated test cases; The preset database construction module is also used to inject key points into the entry functions of different data processing parts, and obtain key features of the data through reflection mechanism. The entry function includes two fields: the root identifier of each function call chain and the key feature value of the data. The key feature value of the data serves as a unique identifier for data processing and is used to associate different parts of the function call chain. Real-time call chain tracking and recording of different parts are achieved through call chain injection, and the records are made in a hierarchical relationship. The root identifier marks the root part of each function call chain, and subsequent sub-calls are based on the root identifier and add a sequence number within the hierarchy to record the entire dynamic call chain. The target functions with correlation are determined by the feature values of the functions corresponding to the automated test cases. The dynamic call chain of each target function is determined by the identifiers of each target function and its corresponding sub-functions.
7. The apparatus according to claim 6, characterized in that, The change code includes added code, modified code, and deleted code; the target function includes an add function, a modify function, and a delete function; and the target function determination submodule includes: An additional function determination unit is added to determine the added function corresponding to the added code; A function determination unit is used to determine the modified function corresponding to the modified code; The deletion function determination unit is used to determine the deletion function corresponding to the deleted code.
8. The apparatus according to claim 6, characterized in that, The function dynamic call chain collection submodule includes: The status information determination unit is used to determine the status information of the function corresponding to the automated test case during the execution of each automated test case. The function dynamic call chain collection unit is used to collect the function dynamic call chain by injecting code into the function corresponding to each automated test case through aspect-oriented programming when the function corresponding to the automated test case is in the compile-time or runtime state.
9. The apparatus according to claim 6, characterized in that, The device further includes: The verification module is used to perform regression verification or continuous verification on each target automated test case in the target automated test case set.
10. The apparatus according to claim 6, characterized in that, The device further includes: The iterative change module is used to perform iterative changes on the target code in response to a code change request.
11. An automated test case determination device, characterized in that, The device includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the automated test case determination method as described in any one of claims 1-5.
12. A computer storage medium, characterized in that, The computer storage medium stores at least one instruction or at least one program, which is loaded and executed by a processor to implement the automated test case determination method as described in any one of claims 1-5.
Citation Information
Patent Citations
White-box testing method and apparatus
CN106547678A
Method and device for automatically selecting test cases for regression testing
CN110362463A