Data processing method and related device
By automating the generation of test cases from source code, the problem of low efficiency in manually writing software test cases is solved, thus achieving efficient software testing.
Patent Information
- Application Number
- CN202410566855.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2025-11-14
AI Technical Summary
In existing technologies, the generation of software test cases relies on manual writing, which leads to low efficiency and a high risk of errors, especially in complex software code, where it is time-consuming and labor-intensive.
The system automatically selects the smallest test unit from the target source code as the target test unit, generates test cases based on its key information and dependencies, runs the test cases to obtain output parameters, analyzes the source code detection results and displays them, all without human intervention.
It significantly improves the efficiency of test case writing and source code verification, and reduces human error and omissions.
Smart Images

Figure CN120950376A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer software, and more particularly to a data processing method and related apparatus. Background Technology
[0002] In the development of computer software, unit testing is a crucial step before deployment to prevent software malfunctions. Unit testing involves checking and verifying the smallest testable unit of the software to discover errors and defects in the code, ensuring that each unit functions as expected. Test cases used in unit testing include a series of operational steps performed during the test and the expected results of these steps.
[0003] However, test case generation mainly relies on manual writing. Complex software code is lengthy and often contains nested references, making manual writing time-consuming and labor-intensive. Therefore, improving the efficiency of software testing has become a pressing issue. Summary of the Invention
[0004] This application provides a data processing method and related apparatus for improving the efficiency of software testing.
[0005] In view of this, this application provides a data processing method, including:
[0006] Obtain the target source code;
[0007] Based on the target source code, the detection results of the target source code are displayed on the source code detection interface. The detection results of the target source code include the analysis of the target output parameters and the actual output parameters of the target test unit. The actual output parameters of the target test unit are obtained by executing the test cases of the target test unit. The target output parameters of the target test unit are contained in the test cases of the target test unit. The test cases of the target test unit are generated based on the key information and dependencies of the target source code. The key information and dependencies of the target source code are obtained by parsing the target source code. The target test unit is contained in the target source code and is the smallest test unit in the target source code.
[0008] A second aspect of this application provides a data processing apparatus, comprising:
[0009] The acquisition unit is used to acquire the target source code;
[0010] The interactive unit is used to display the detection results of the target source code on the source code detection interface. The detection results of the target source code include the analysis of the target output parameters and the actual output parameters of the target test unit. The actual output parameters of the target test unit are obtained by executing the test cases of the target test unit. The target output parameters of the target test unit are contained in the test cases of the target test unit. The test cases of the target test unit are generated based on the key information and dependencies of the target source code. The key information and dependencies of the target source code are obtained by parsing the target source code. The target test unit is contained in the target source code and is the smallest test unit in the target source code.
[0011] In one possible implementation of the second aspect, the interaction unit is specifically used for:
[0012] Analyze the target source code to obtain key information and dependencies.
[0013] Test cases for the target test unit are generated based on key information and dependencies of the target source code.
[0014] Execute the test cases of the target test unit to obtain the actual output parameters of the target test unit;
[0015] Analyze the detection results of the target source code based on the target output parameters and the actual output parameters of the target test unit;
[0016] Based on the target source code, the detection results of the target source code are displayed on the source code detection interface.
[0017] In one possible implementation of the second aspect, the interaction unit is specifically used for:
[0018] Target test units are determined based on key information and dependencies in the target source code.
[0019] Generate test cases for the target test unit based on the target test unit.
[0020] In one possible implementation of the second aspect, the test cases of the target test unit also carry the target input parameters of the target test unit;
[0021] Interactive units, specifically used for:
[0022] If the target test unit has input parameters, determine the target input parameter set of the target test unit based on the target test unit;
[0023] Select the target input parameters of the target test unit based on the target input parameter set;
[0024] Determine the target output parameters of the target test unit based on the target input parameters and the target test unit;
[0025] Generate test cases for the target test unit based on the target test unit, target input parameters, and target output parameters.
[0026] In one possible implementation of the second aspect, the interaction unit is specifically used for:
[0027] Based on the target input parameter set, the input parameters of the target test unit are divided into a valid input parameter set and an invalid input parameter set. The valid input parameter set is the target input parameter set, and the invalid input parameter set is the non-target input parameter set.
[0028] Select the first input parameter from the set of valid input parameters. The first input parameter is included in the target input parameter.
[0029] A second input parameter is selected from the set of invalid input parameters, and the second input parameter is included in the target input parameter.
[0030] In one possible implementation of the second aspect, the first input parameter is either the largest value in the set of valid input parameters or the smallest value in the set of valid input parameters, and the second input parameter is either the smallest value in the set of invalid input parameters or the largest value in the set of invalid input parameters.
[0031] In one possible implementation of the second aspect, the target input parameter set indicates the compliant input parameter types of the target test unit;
[0032] The interaction unit is specifically used to select a third input parameter based on the target input parameter set, where the third input parameter is not included in the target input parameter set, or is included in the target input parameter set.
[0033] In one possible implementation of the second aspect, the acquisition unit is further configured to acquire preset input parameters of the target test unit and preset output parameters of the target test unit, wherein the preset input parameters and preset output parameters correspond one-to-one.
[0034] The interaction unit is also used to determine the target input parameter as the preset output parameter based on the target input parameter and the target test unit when the target input parameter is the preset input parameter.
[0035] In one possible implementation of the second aspect, the interaction unit is specifically used to run the target test unit and obtain the target output parameters of the target test unit when the function in the target test unit has no input parameters.
[0036] Generate test cases for the target test unit based on the target test unit and the target output parameters.
[0037] In one possible implementation of the second aspect, the interaction unit is specifically used to execute the test cases of the target test unit when the test cases of the target test unit meet the preset conditions, and obtain the actual output parameters of the target test unit.
[0038] In a second aspect, in one possible implementation, the apparatus further includes a generating unit for:
[0039] Generate the identity identifier for the target test unit;
[0040] The function in the target test unit is uniquely identified by the identity of the target test unit. The function in the target test unit is contained in the lexical unit or the class name of the target test unit.
[0041] A third aspect of this application provides a computer device, including: a memory, a processor, and a bus system;
[0042] The memory is used to store programs;
[0043] The processor is used to execute programs in memory, and the processor is used to execute the methods mentioned above according to the instructions in the program code;
[0044] Bus systems are used to connect memory and processor to enable communication between them.
[0045] The fourth aspect of this application provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the methods described above.
[0046] A fifth aspect of this application provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the above aspects.
[0047] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0048] In this embodiment, the smallest test unit is first selected from the target source code as the target test unit. Then, test cases for the target test unit are determined based on the functions within the target test unit. The test cases are run to obtain the actual output parameters of the target test unit. Based on the actual output parameters and the target output parameters of the target test unit, the detection results of the target source code are analyzed and displayed through a source code detection interface. The test cases for the target test unit carry the target output parameters of the target test unit. Test cases for any smallest test unit in the target source code can be written without manual intervention, greatly improving the efficiency of test case writing and source code verification. Attached Figure Description
[0049] Figure 1 A schematic diagram of the architecture of the data processing system provided in the embodiments of this application;
[0050] Figure 2 A flowchart illustrating the data processing method provided in this application embodiment;
[0051] Figure 3a A schematic diagram of the source code of the data target provided in the embodiments of this application;
[0052] Figure 3b A schematic diagram illustrating the method for parsing the target source code provided in the embodiments of this application;
[0053] Figure 3c A schematic diagram illustrating key information of the target source code provided in the embodiments of this application;
[0054] Figure 4 A schematic diagram of test cases for the target source code provided in an embodiment of this application;
[0055] Figure 5 A flowchart illustrating the process of determining target input parameters provided in the embodiments of this application;
[0056] Figure 6 A schematic diagram of the source code detection interface provided in this application embodiment;
[0057] Figure 7 This is a schematic diagram of the data processing system according to an embodiment of this application;
[0058] Figure 8 A flowchart illustrating the operation of the data processing system provided in this application embodiment;
[0059] Figure 9a Another schematic flowchart illustrating the operation of the data processing system provided in the embodiments of this application;
[0060] Figure 9b A flowchart illustrating the operation of the parsing module provided in this application embodiment;
[0061] Figure 9c Another flowchart illustrating the operation of the parsing module provided in the embodiments of this application;
[0062] Figure 10 A schematic diagram of the structure of the data processing apparatus provided in the embodiments of this application;
[0063] Figure 11 Another schematic diagram of the data processing apparatus provided in the embodiments of this application;
[0064] Figure 12 This is another schematic diagram of the data processing apparatus provided in the embodiments of this application. Detailed Implementation
[0065] This application provides a data processing method and related apparatus to improve the efficiency of test case writing.
[0066] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular 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, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “corresponding to,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus 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 apparatus.
[0067] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0068] In the process of computer software development, unit testing is an essential step before the software is put into use. Unit testing helps to find errors and defects in the software code. However, writing unit test cases manually is a tedious and error-prone task. It not only consumes a lot of time and energy, but is also prone to omissions and errors. How to improve the efficiency of writing test cases has become a problem that needs to be solved.
[0069] To address this issue, this application proposes a method where, after obtaining the target source code from which test cases need to be generated, the smallest test unit is selected as the target test unit. Then, based on the test cases of the target test unit, the test cases are run to obtain the actual output parameters of the target test unit. The detection results of the target source code are obtained by analyzing the actual output parameters and the target output parameters of the target test unit, and the detection results are displayed through a source code detection interface. The test cases of the target test unit carry the target output parameters of the target test unit. This method allows for the writing of test cases corresponding to any smallest test unit in the target source code without manual intervention, greatly improving the efficiency of test case writing and source code verification.
[0070] To better understand the application scenarios of the data processing method provided in this application, please refer to [link / reference]. Figure 1 , Figure 1This is an optional architecture diagram illustrating an application scenario of the data processing method provided in this application embodiment. To support a data processing method, terminal device 100 connects to server 300 via network 200, and server 300 connects to database 400. Network 200 can be a wide area network (WAN), a local area network (LAN), or a combination of both. The client for implementing the data processing method is deployed on terminal device 100. The client can run on terminal device 100 via a browser or as a standalone application (APP). The specific form of the client is not limited here. Server 300 involved in this application can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Terminal device 100 can be a smartphone, tablet, laptop, PDA, personal computer, smart TV, smartwatch, in-vehicle device, wearable device, etc., but is not limited to these. Terminal device 100 and server 300 can be directly or indirectly connected via network 200 through wired or wireless communication, which is not limited in this application. The number of server 300 and terminal device 100 is also not limited. The solution provided in this application can be completed independently by terminal device 100, independently by server 300, or jointly by terminal device 100 and server 300, which is not specifically limited in this application. In short, database 400 can be regarded as an electronic filing cabinet—a place to store electronic files, where users can perform operations such as adding, querying, updating, and deleting data in the files. The so-called "database" is a collection of data stored together in a certain way, which can be shared by multiple users, has the lowest possible redundancy, and is independent of applications. Database management system (DBMS) is a computer software system designed for managing databases, and generally has basic functions such as storage, retrieval, security, and backup.Database management systems can be categorized based on the database model they support, such as relational or Extensible Markup Language (XML); or based on the type of computer they support, such as server clusters or mobile phones; or based on the query language used, such as Structured Query Language (SQL) or XQuery; or based on performance priorities, such as maximum scale or highest operating speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories, for example, supporting multiple query languages simultaneously. In this application, database 400 can be used to store training samples or images to be processed. Of course, the storage location of training samples or images to be processed is not limited to the database; for example, it can also be stored in terminal device 100, a blockchain, or the distributed file system of server 300, etc.
[0071] In some embodiments, the terminal device 100 may execute the data processing method provided in this application embodiment alone, or the terminal device 100 may execute the data processing method provided in this application in conjunction with the server 300.
[0072] In this embodiment, the specific process can be as follows: The terminal device 100 acquires the target source code, and then the terminal device 100 displays the detection result of the target source code on the source code detection interface based on the target source code. The detection result of the target source code includes the analysis obtained based on the target output parameters and the actual output parameters of the target test unit. The actual output parameters of the target test unit are obtained by executing the test cases of the target test unit. The target output parameters of the target test unit are contained in the test cases of the target test unit. The test cases of the target test unit are generated based on the key information of the target source code and the dependency relationship of the target source code. The key information of the target source code and the dependency relationship of the source code are obtained by parsing the target source code. The target test unit is contained in the target source code. The target test unit is the smallest test unit in the target source code.
[0073] A database, simply put, can be viewed as an electronic filing cabinet—a place to store electronic files, where users can perform operations such as adding, querying, updating, and deleting data. A "database" is a collection of data stored together in a certain way, shared by multiple users, with minimal redundancy, and independent of application programs. A Database Management System (DBMS) is a computer software system designed to manage databases, generally possessing basic functions such as storage, retrieval, security, and backup. DBMSs can be classified according to the database model they support, such as relational or Extensible Markup Language (XML); or according to the type of computer they support, such as server clusters or mobile phones; or according to the query language used, such as Structured Query Language (SQL) or XQuery; or according to performance priorities, such as maximum scale or maximum operating speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories, for example, supporting multiple query languages simultaneously.
[0074] Given that this application involves some technical terms, these terms will be introduced below.
[0075] Unit testing: The process of checking and verifying the smallest testable unit in software to ensure that each unit of code works as expected.
[0076] Test cases: A series of operational steps and expected results executed during the testing process to verify whether a certain function or performance of the software meets expectations.
[0077] Function signature: A function signature contains information about a function, including the function name, parameter types, class, namespace, and other information. It represents the unique characteristics of a function. In this case, it is hashed and expressed as a string.
[0078] Based on the above introduction, the data processing methods in this application will be described below. Please refer to [link / reference]. Figure 2 One embodiment of the data processing method in this application includes:
[0079] S110, Obtain the target source code;
[0080] The target source code may include at least one source file, and there is no restriction here.
[0081] Specifically, obtaining the target source code can include two steps: setting the path information of the target source code and loading the target source code based on the path information.
[0082] When setting the path information of the target source code, the target object can set the path information of the target source code through the system application programming interface (API). For example, the target object can set the path information of the target source code to the URL address of the code library or the local storage path through the API.
[0083] Optionally, the target object can also set the path information of the target source code through the UI interface, or directly write the target source code through the UI interface; there are no restrictions here.
[0084] Furthermore, in some scenarios that require identity authentication, the target can also set a username and a corresponding password for identity authentication, without any restrictions.
[0085] It is understood that the description of how to obtain the target source code here is only an example. In actual applications, the settings should be combined with the specific application scenario. No restrictions are imposed here.
[0086] S120. Analyze the target source code to obtain key information and dependencies of the target source code;
[0087] Specifically, when the target source code is programmed in C++, key information includes function names, parameter types, and function call relationships; when the target source code is programmed in Python, key information includes class names, class inheritance relationships, class member variables, and methods. Dependencies in the target source code can include references between code files within the target source code.
[0088] Specifically, parsing the target source code includes lexical analysis, syntax analysis, and then combining the results of syntax analysis to extract key information from the target source code. Lexical analysis decomposes the target source code into a series of lexical units (tokens), where a lexical unit is the smallest meaningful unit in the source code, such as keywords, identifiers, constants, or operators. Lexical analysis decomposes the target source code into a sequence of lexical units. Syntax analysis constructs an abstract syntax tree (AST) based on the sequence of lexical units obtained from lexical analysis. The abstract syntax tree displays the hierarchical relationships between the various elements in the target source code in a tree structure. Based on the results of lexical and syntax analysis, key information and dependencies of the target source code can be obtained.
[0089] For example, the following section uses Python as the programming language of the target source code to illustrate the key information obtained from parsing the target source code and its dependencies. Please refer to [link / reference needed]. Figure 3a , Figure 3a A schematic diagram of the target source code provided in an embodiment of this application. Figure 3a The code defines a method for calculating complex numbers. For complex numbers C1(1.0, 2.0) and C2(3.0, 4.0), the operation C1 and C2 are added together to obtain C3. In this calculation, the real and imaginary parts of C1 and C2 are added separately to obtain C3.
[0090] The following is combined with Figure 3b Regarding the aforementioned Figure 3a The analysis of the provided target source code is explained. Figure 3b This is a schematic diagram illustrating a method for parsing the target source code provided in an embodiment of this application.
[0091] First, lexical analysis is performed on the target source code to obtain "tokens". Then, syntactic analysis is performed on the "tokens" to obtain the "AST". Finally, the "tokens" and "AST" are combined to generate class names and method names.
[0092] The foregoing Figure 3a The lexical units, abstract syntax trees, class names, and class method names generated from the target source code shown can be as follows: Figure 3c As shown.
[0093] This section explains how to parse the target source code to obtain key information when the target source code is programmed in Python. When the target source code is programmed in C, C++, or JAVA, the operations performed are similar to those in Python, and will not be repeated here.
[0094] Understandable Figure 3a , Figure 3b and Figure 3c The descriptions of key information in the target source code are for illustrative purposes only. In actual applications, the settings should be tailored to the specific application scenario, and no restrictions are imposed here.
[0095] If the target source code includes multiple source files and there are function calls between these files, it is also necessary to parse the target source code to obtain its dependencies.
[0096] S130. Generate test cases for the target test unit based on the key information and dependencies of the target source code;
[0097] The target test unit is determined based on the key information of the target source code and the dependencies of the target source code.
[0098] Specifically, the target test unit is first determined based on the key information and dependencies of the target source code. The target source code contains multiple test units, from which any one test unit is selected as the target test unit. Then, test cases are generated for the target test unit.
[0099] In this embodiment, the target source code contains multiple test units. By randomly sampling, the target test units are determined based on the key information and dependencies of the target source code, thereby improving the implementation efficiency of the solution.
[0100] Specifically, since the target source code includes multiple source files, there may be functions with the same name in different source files. In order to distinguish these functions, after the target test unit is determined, an identity identifier for the target test unit can be generated. The identity identifier of the target test unit is used to uniquely mark the functions in the target test unit. The identity identifier of the target test unit can be a function signature string, and there are no restrictions here.
[0101] In this embodiment, by adding an identity identifier to the target test unit and marking the functions in the target test unit, it is easier to distinguish multiple functions with the same name in the target source code, so that the target object can quickly identify the function that has an exception, thereby improving the implementation efficiency of software testing.
[0102] Specifically, to generate test cases for the target test unit, we can first determine the target input parameters based on the data type of the target test unit, then obtain the target output parameters based on the target input parameters and the target test unit, and finally combine the target input parameters, target output parameters, and target test unit to obtain the test cases for the target test unit.
[0103] In this embodiment, when the target test unit has input parameters, the target input parameter set of the target test unit is determined according to the parameter type of the target test unit, and target input parameters are selected from it. Based on the target input parameters and the target test unit, target output parameters are obtained. This can verify the code coverage of the target test unit under parameter compliance conditions, providing strong support for the analysis of the detection results of the target source code.
[0104] The target input parameters are determined based on the data type of the target test unit. There are three cases based on the parameter type of the target test unit:
[0105] Scenario 1: The target test unit has no input parameters:
[0106] If the target test unit has no input parameters, the input parameters of the target test unit are empty.
[0107] You can directly run the target test unit and obtain its output parameters.
[0108] For example, when the target test unit is used to obtain the current time, the target output parameter of the target test unit can be obtained directly without inputting any parameters. The target output parameter of the target test unit is xxxx year xx month xx day, xx hour xx minute xx second.
[0109] It is understood that the description of the target test unit and the content of its output parameters are only examples when there are no input parameters for the target test unit. In actual applications, they should be set according to the specific application scenario, and no restrictions are imposed here.
[0110] In this embodiment, the target test unit is run directly when there are no input parameters. Test cases for the target test unit are generated based on the target output parameters and the target test unit, which effectively improves the completeness of the solution.
[0111] Compared to Case 1, when the target test unit has input parameters, determining the target input parameter set of the target test unit can be further divided into Case 2 and Case 3. Case 2 is when the input parameters of the target test unit are basic data types, and Case 3 is when the input parameters of the target test unit are complex data types.
[0112] In both scenario two and scenario three, the target input parameters for the target test unit include countless possibilities. Therefore, the selection of target input parameters for these two scenarios will be discussed below.
[0113] Scenario 2: The input parameters of the function in the target test unit are basic data types;
[0114] Basic data types are data types supported by the programming language that do not require definition by the programmer. Each basic data type has a specific range of values. Examples include bool, int, float, double, long, and char in C++, and int, long, float, double, char, and boolean in Java. Similar definitions exist in every programming language, and will not be elaborated upon here.
[0115] Table 1 shows the values of basic data types in C++ on an x86_64 computer using the g++ compiler.
[0116] Table 1
[0117]
[0118]
[0119] Given that the input parameters of the target test unit are of basic data types, the target test unit determines its target input parameter set based on its own data type. When generating test cases, any value can be randomly selected from the target input parameter set as the target input parameter of the target test unit. The target input parameter is then input into the target test unit to obtain the target output parameter. Combining the target input parameter, target output parameter, and target test unit yields the test cases for the target test unit; no restrictions are imposed here.
[0120] For example, when the data type of the target test unit is char, its value range includes any integer from -128 to 127, meaning the target input parameter set is any integer from -128 to 127. When selecting the target input parameter, any integer can be randomly selected from -128 to 127 as the target input parameter. This target input parameter is then input into the target test unit to obtain the target output parameter.
[0121] Optionally, in order to improve the representativeness of the target input parameters and reduce the number of target input parameters, this application proposes that the input parameters of the target test unit can be divided into different equivalence classes using the equivalence class method, and representative values can be selected from each equivalence class as target input parameters.
[0122] For example, the input parameters of the target test unit can be divided into a valid input parameter set and an invalid input parameter set based on the target input parameter set. The valid input parameter set is the target input parameter set, and the invalid input parameter set consists of values not in the target input parameter set. Furthermore, at least one value (the first input parameter) is selected from the valid input parameter set as the target input parameter, and at least one value (the second input parameter) is selected from the invalid input parameter set as the target input parameter; this is not limited here.
[0123] For example, when the data type of the target test unit is char, its value range includes any integer from -128 to 127, which means the target input parameter set is any integer from -128 to 127. Therefore, the valid input parameter set includes any integer from -128 to 127, and the invalid input parameter set includes any value other than -128 to 127.
[0124] In this embodiment of the application, by dividing equivalence classes, it is ensured that the collection of target input parameters can be distributed across different equivalence classes. This ensures that the collection of target input parameters involves all equivalence classes, avoiding the problem of incomplete testing caused by the collection of target input parameters being concentrated in certain specific equivalence classes. Under the same number of target input parameters, the reliability of test cases is improved.
[0125] Optionally, to more accurately identify potential boundary issues and errors, when selecting target input parameters from the sets of valid and invalid input parameters, values closer to the set boundaries should be prioritized. Continuing with the example of the target test unit being of data type char, when selecting target input parameters, the first input parameter should preferably be -128 and / or 127, and the second input parameter should preferably be -129 or 128; no restrictions are placed here.
[0126] In this embodiment of the application, by selecting the boundary values of equivalence classes as target input parameters, the potential problems and errors at the boundaries of equivalence classes can be accurately identified, thereby improving the testing efficiency of the solution.
[0127] Optionally, in order to test the fault tolerance capability of the target test unit, if it is confirmed that the target input parameter set is a compliant input parameter type of the target test unit, a third input parameter that is not included in the target input parameter set is selected, and the third input parameter is included in the target input parameter.
[0128] For example, when the data type of the target test unit is int, the target input parameter set is an integer from -(2^31) to (2^31)-1, and other data types that violate the int rule, such as 3.14159, "abc", 2^32, @ or #, are selected as target input parameters.
[0129] It is understood that the description of how to select the target input parameters here is only an example. In actual applications, the settings should be combined with the specific application scenario, and no restrictions are imposed here.
[0130] In this embodiment, by selecting a non-compliant parameter type as the third input parameter, which is included in the target input parameter, when the target test unit has strong fault tolerance, the feedback for the third input parameter is a parameter abnormality signal; when the target test unit has poor fault tolerance, the feedback for the third input parameter is a target test unit crash, which effectively helps to detect the fault tolerance of the target test unit.
[0131] Scenario 3: The input parameters of the function in the target test unit are complex data types.
[0132] Since complex data types are data objects constructed from combinations of basic data types, they can be decomposed into combinations of at least two reference input parameters during analysis. These reference input parameters are of basic data types. Then, by combining the processing methods for basic data types, values are taken from each of the at least two reference input parameters obtained from the decomposition, thus obtaining the target input parameter.
[0133] For example, taking complex data types such as complex numbers as an example, combined with the aforementioned... Figure 3a For the target test units in examples 3b and 3c, please refer to [link / reference]. Figure 4 Let c1 and c2 be complex numbers, with the real part of c1 being 1.0 and the imaginary part being 2.0, and the real part of c2 being 3.0 and the imaginary part being 4.0. Calculate c3 as the sum of c1 and c2. Therefore, the real part of c3 is obtained by adding the real part of c1 to the real part of c2, and the imaginary part of c3 is obtained by adding the imaginary part of c1 to the imaginary part of c2. In practice, the real and imaginary parts of c1 and c2 can be assigned values separately; no restrictions are placed here.
[0134] Figure 4 The example shown includes the target input parameters (1.0, 2.0) and (3.0, 4.0), the target output parameter (4.0, 6.0), and the target test unit itself, forming a test case for one target test unit. In practical applications, a target test unit can have multiple test cases.
[0135] In some possible scenarios, the construction of target input parameters can be combined with pre-execution of the target test unit. If the execution of all current target input parameters cannot cover every statement in the function body of the target test unit, the number of possible target input parameter values is increased, and the function body of the target test unit is pre-executed again. If the number of target input parameters equals a threshold, and the execution of all target input parameters still cannot cover every statement in the function body of the target test unit, the uncovered code is marked as invalid code statements; no restrictions are placed here.
[0136] To facilitate understanding, the following will be combined with... Figure 5 The process for determining the target input parameters is briefly described below. First, determine the data type contained in the target test unit; then, determine the target input parameters based on the data type of the target test unit; determine the statements and judgment conditions included in the target test unit; input the target input parameters into the target test unit, perform pre-execution, and determine the statements that the execution of the target input parameters can cover; adjust the target input parameters according to the statements that the execution of the target input parameters can cover; finally, determine the target input parameters.
[0137] In other words, the condition for selecting all target input parameters is that the number of target input parameters equals the threshold, or that all target input parameters can traverse the entire code of the target test unit.
[0138] Specifically, obtaining the target output parameters based on the target input parameters and the target test unit includes directly inputting the target input parameters into the target test unit to obtain the target input parameters.
[0139] If the target input parameters of the target test unit are set in the target source code specification, the preset input parameters and preset output parameters of the target test unit can be obtained before obtaining the target output parameters based on the target input parameters and the target test unit. The preset input parameters and preset output parameters correspond one-to-one. That is, when the target input parameter equals the preset input parameter, the value of the target output parameter is determined to be the value of the preset output parameter; no restrictions are imposed here.
[0140] In this embodiment, when preset input parameters and preset output parameters are predefined, if the target input parameter and the preset input parameter have the same value, it is not necessary to input the target input parameter into the target test unit to calculate and obtain the target output parameter. Instead, the preset output parameter corresponding to the preset input parameter is directly used as the target output parameter, which further verifies whether the target test unit can achieve the expected result and further improves the verification efficiency and accuracy of the target test unit.
[0141] S140. Execute the test cases of the target test unit to obtain the actual output parameters of the target test unit;
[0142] In this context, the actual output parameters of the target test unit correspond one-to-one with the target input parameters and the target output parameters. That is, each target input parameter corresponds to one target input parameter and one actual output parameter.
[0143] Optionally, when there are too many test cases in the target test unit, test cases that meet the preset conditions can be selected from the test cases of multiple target test units as target test cases and executed.
[0144] Specifically, the preset condition can be whether the target input parameter in the test case of the target test unit is a critical input. Critical input includes at least one of valid input, invalid input, boundary value input, or outlier input, without any restrictions here.
[0145] The preset conditions can also be whether the target output parameter in the test case of the target test unit is a critical output. Critical output includes at least one of normal output or abnormal output, which is not limited here.
[0146] The preset conditions can also be whether the test cases of the target test unit can execute the critical path (critical statement). The critical path includes at least one of the normal path or the abnormal path. The abnormal path can be an invalid code path (invalid code statement), which is not restricted here.
[0147] In addition, since the target source code may contain a large number of target test units, the preset conditions may also include whether the target test units contain key functions. Key functions include at least one of the following: public functions / public class methods, important functions, or frequently called functions. There are no restrictions here.
[0148] In this embodiment of the application, by setting preset conditions to filter the test cases of the target test unit to be executed, the test time can be effectively reduced, and the test efficiency can be effectively improved while ensuring the accuracy of the test.
[0149] S150. Analyze the detection results of the target source code based on the target output parameters and the actual output parameters of the target test unit.
[0150] The detection results of the target source code include at least one of the following: statement coverage, branch coverage, function coverage, defect density, and abnormal statements.
[0151] Specifically, statement coverage includes the proportion of statements covered by test cases in the target test unit to the total number of statements in the target test unit; branch coverage includes the proportion of branches covered by test cases in the target test unit to the total number of branches in the target test unit; function coverage includes the proportion of functions covered by test cases in the target test unit to the total number of functions in the target test unit; and defect density includes the proportion of statements in the target test unit that have exceptions to the total number of statements in the target test unit.
[0152] S160. Display the detection results of the target source code on the source code detection interface.
[0153] Furthermore, the detection results of the target source code can be displayed in various forms on the source code detection interface. Depending on the specific needs, they can be presented as bar charts, pie charts, or folded bar charts, etc. There are no restrictions here.
[0154] For example, please refer to Figure 6 , Figure 6 This is a schematic diagram of a source code detection interface provided in an embodiment of this application.
[0155] If software A contains M source code files, the target source code A can also consist of M source code files. The source code detection interface can display the detection results of the target source code from the perspective of a single source code file, or from the perspective of M source code files.
[0156] For example, the source code inspection interface displays the target source code A, the target test unit A, the m-th line of the target test unit A containing an exception, the statement coverage of the target test unit A, and the function coverage of the target test unit A. There are no restrictions here.
[0157] Furthermore, the detection results of the target source code can also be output in the form of HTML, PDF or Word. The detection results of the target source code can be viewed online or exported for local viewing, without any restrictions.
[0158] In this embodiment, the smallest test unit is first selected from the target source code as the target test unit. Then, test cases for the target test unit are determined based on the functions within the target test unit. The test cases are run to obtain the actual output parameters of the target test unit. Based on the actual output parameters and the target output parameters of the target test unit, the detection results of the target source code are analyzed and displayed through a source code detection interface. The test cases for the target test unit carry the target output parameters of the target test unit. Test cases for any smallest test unit in the target source code can be written without manual intervention, greatly improving the efficiency of test case writing and source code verification.
[0159] In this embodiment, test cases for the target test unit can be generated by analyzing the target source code on the terminal device, and the test cases for the target test unit can be executed to obtain the actual output parameters of the target test unit. The detection results of the target source code can be analyzed based on the target output parameters and the actual output parameters, and the detection results of the target source code can be displayed on the source code detection interface. No human intervention is required, which improves the implementation efficiency of the solution.
[0160] The foregoing Figure 2 The implementation is based on a data processing system; please refer to [link / reference]. Figure 7 The data processing system 10 may include a parsing module 110, a test case generation module 120, a testing module 130, and a report generation module 140.
[0161] The main operations performed by the data processing system are as follows: Figure 8 As shown, the specific steps include: obtaining the target source code provided by the target object; parsing the target source code and extracting key information; generating test cases for the target test unit; executing the test cases for the target test unit; and generating the detection results of the target source code.
[0162] The operations performed before the target source code input parsing module 110 are as follows: Figure 9aAs shown, the specific steps include: obtaining the target source code, traversing and loading the source code files of the target source code, determining the programming language type of the target source code, and inputting the target source code into the corresponding parsing module 110 according to the programming language type. For example, the programming language of the target source code is Python, Java, C++, or others. That is, the parsing module 110 includes a Python parsing module 111, a Java parsing module 112, a C++ parsing module 113, and other parsing modules 114.
[0163] Parsing module 110 executes the aforementioned Figure 2 In step S120, when the target source code's programming language is Python, the built-in module ast and the third-party library astor in the Python parsing module 111 perform lexical and syntactic analysis and extract key information.
[0164] Test case generation module 120 executes the aforementioned Figure 2 In step S130, the relevant operations are detailed as follows: Figure 9b As shown, firstly, the key information of the target source code generated by the parsing module 110 is loaded; target input parameters are constructed based on the key information of the target source code; target output parameters are obtained based on the target test unit and the target input parameters; and test cases for the target test unit are generated based on the target test unit, the target input parameters, and the target output parameters.
[0165] In one possible scenario, the use case generation module 120 performs the aforementioned... Figure 2 In step S130, the specific execution method can be as follows: Figure 9c As shown, the process first obtains the unit test framework and test case programming language configuration for the target object; then, it sequentially inputs the target input parameters into the target test unit; it determines the programming language of the target test unit, selects the appropriate test framework based on the determination result, and generates test cases for the target test unit based on the target test unit, target output parameters, and target input parameters. For example, the target test unit's programming language may include other languages, C, C++, Java, and Python, and the test framework may include the default test framework, C language test framework, C++ test framework, Java test framework, and Python test framework; no restrictions are imposed here.
[0166] Test module 130 performs the aforementioned Figure 2 In step S140, the test module 130 can integrate various test frameworks and tools, such as gtest, JUnit, TestNG, pytest, etc., without any restrictions.
[0167] Report generation module 140 performs the aforementioned Figure 2The relevant operations in step S150 are not restricted here.
[0168] The data processing apparatus in this application is described in detail below. Please refer to [link / reference]. Figure 10 , Figure 10 This is a schematic diagram of one embodiment of the data processing apparatus in this application. The data processing apparatus 20 includes:
[0169] Acquisition unit 210 is used to acquire the target source code;
[0170] Interactive unit 220 is used to display the detection results of the target source code on the source code detection interface based on the target source code. The detection results of the target source code include the analysis of the target output parameters and the actual output parameters of the target test unit. The actual output parameters of the target test unit are obtained by executing the test cases of the target test unit. The target output parameters of the target test unit are contained in the test cases of the target test unit. The test cases of the target test unit are generated based on the key information and dependencies of the target source code. The key information and dependencies of the target source code are obtained by parsing the target source code. The target test unit is contained in the target source code and is the smallest test unit in the target source code.
[0171] In this embodiment, the smallest test unit is first selected from the target source code as the target test unit. Then, test cases for the target test unit are determined based on the functions within the target test unit. The test cases are run to obtain the actual output parameters of the target test unit. Based on the actual output parameters and the target output parameters of the target test unit, the detection results of the target source code are analyzed and displayed through a source code detection interface. The test cases for the target test unit carry the target output parameters of the target test unit. Test cases for any smallest test unit in the target source code can be written without manual intervention, greatly improving the efficiency of test case writing and source code verification.
[0172] Optionally, the interaction unit 220 is specifically used for:
[0173] Analyze the target source code to obtain key information and dependencies.
[0174] Test cases for the target test unit are generated based on key information and dependencies of the target source code.
[0175] Execute the test cases of the target test unit to obtain the actual output parameters of the target test unit;
[0176] Analyze the detection results of the target source code based on the target output parameters and the actual output parameters of the target test unit;
[0177] The source code detection interface displays the detection results of the target source code.
[0178] In this embodiment, test cases for the target test unit can be generated by analyzing the target source code on the terminal device, and the test cases for the target test unit can be executed to obtain the actual output parameters of the target test unit. The detection results of the target source code can be analyzed based on the target output parameters and the actual output parameters, and the detection results of the target source code can be displayed on the source code detection interface. No human intervention is required, which improves the implementation efficiency of the solution.
[0179] Optionally, the interaction unit 220 is specifically used for:
[0180] Target test units are determined based on key information and dependencies in the target source code.
[0181] Generate test cases for the target test unit based on the target test unit.
[0182] In this embodiment, the target source code contains multiple test units. By randomly sampling, the target test units are determined based on the key information and dependencies of the target source code, thereby improving the implementation efficiency of the solution.
[0183] Optionally, the test cases for the target test unit also carry the target input parameters of the target test unit;
[0184] Interaction unit 220 is specifically used for:
[0185] If the target test unit has input parameters, determine the target input parameter set of the target test unit based on the target test unit;
[0186] Select the target input parameters of the target test unit based on the target input parameter set;
[0187] Determine the target output parameters of the target test unit based on the target input parameters and the target test unit;
[0188] Generate test cases for the target test unit based on the target test unit, target input parameters, and target output parameters.
[0189] In this embodiment, when the target test unit has input parameters, the target input parameter set of the target test unit is determined according to the parameter type of the target test unit, and target input parameters are selected from it. Based on the target input parameters and the target test unit, target output parameters are obtained. This can verify the code coverage of the target test unit under parameter compliance conditions, providing strong support for the analysis of the detection results of the target source code.
[0190] Optionally, the interaction unit 220 is specifically used for:
[0191] Based on the target input parameter set, the input parameters of the target test unit are divided into a valid input parameter set and an invalid input parameter set. The valid input parameter set is the target input parameter set, and the invalid input parameter set is the non-target input parameter set.
[0192] Select the first input parameter from the set of valid input parameters. The first input parameter is included in the target input parameter.
[0193] A second input parameter is selected from the set of invalid input parameters, and the second input parameter is included in the target input parameter.
[0194] In this embodiment of the application, by dividing equivalence classes, it is ensured that the collection of target input parameters can be distributed across different equivalence classes. This ensures that the collection of target input parameters involves all equivalence classes, avoiding the problem of incomplete testing caused by the collection of target input parameters being concentrated in certain specific equivalence classes. Under the same number of target input parameters, the reliability of test cases is improved.
[0195] Optionally, the first input parameter is the largest value in the set of valid input parameters, or the smallest value in the set of valid input parameters, and the second input parameter is the smallest value in the set of invalid input parameters, or the largest value in the set of invalid input parameters.
[0196] In this embodiment of the application, by selecting the boundary values of equivalence classes as target input parameters, the potential problems and errors at the boundaries of equivalence classes can be accurately identified, thereby improving the testing efficiency of the solution.
[0197] Optionally, the target input parameter set indicates the compliant input parameter types of the target test unit;
[0198] The interaction unit 220 is specifically used to select a third input parameter based on the target input parameter set, wherein the third input parameter is not included in the target input parameter set, or is included in the target input parameter set.
[0199] In this embodiment, by selecting a non-compliant parameter type as the third input parameter, which is included in the target input parameter, when the target test unit has strong fault tolerance, the feedback for the third input parameter is a parameter abnormality signal; when the target test unit has poor fault tolerance, the feedback for the third input parameter is a target test unit crash, which effectively helps to detect the fault tolerance of the target test unit.
[0200] Optionally, the acquisition unit 210 is also used to acquire the preset input parameters and preset output parameters of the target test unit, wherein the preset input parameters and preset output parameters correspond one-to-one.
[0201] The interaction unit 220 is also used to determine the target input parameter as the preset output parameter based on the target input parameter and the target test unit when the target input parameter is the preset input parameter.
[0202] In this embodiment, when preset input parameters and preset output parameters are predefined, if the target input parameter and the preset input parameter have the same value, it is not necessary to input the target input parameter into the target test unit to calculate and obtain the target output parameter. Instead, the preset output parameter corresponding to the preset input parameter is directly used as the target output parameter, which further verifies whether the target test unit can achieve the expected result and further improves the verification efficiency and accuracy of the target test unit.
[0203] Optionally, the interaction unit 220 is specifically used to run the target test unit and obtain the target output parameters of the target test unit when the function in the target test unit has no input parameters.
[0204] Generate test cases for the target test unit based on the target test unit and the target output parameters.
[0205] In this embodiment, the target test unit is run directly when there are no input parameters. Test cases for the target test unit are generated based on the target output parameters and the target test unit, which effectively improves the completeness of the solution.
[0206] Optionally, the interaction unit 220 is specifically used to execute the test cases of the target test unit when the test cases of the target test unit meet the preset conditions, and obtain the actual output parameters of the target test unit.
[0207] In this embodiment of the application, by setting preset conditions to filter the test cases of the target test unit to be executed, the test time can be effectively reduced, and the test efficiency can be effectively improved while ensuring the accuracy of the test.
[0208] Optionally, the apparatus also includes a generating unit 230, for:
[0209] Generate the identity identifier for the target test unit;
[0210] The function in the target test unit is uniquely identified by the identity of the target test unit. The function in the target test unit is contained in the lexical unit or the class name of the target test unit.
[0211] In this embodiment, by adding an identity identifier to the target test unit and marking the functions in the target test unit, it is easier to distinguish multiple functions with the same name in the target source code, so that the target object can quickly identify the function that has an exception, thereby improving the implementation efficiency of software testing.
[0212] The data processing apparatus provided in this application can be used on a server; please refer to [link / reference]. Figure 11 , Figure 11 This is a schematic diagram of a server structure provided in an embodiment of this application. The server 300 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 322 (e.g., one or more processors) and memory 332, and one or more storage media 330 (e.g., one or more mass storage devices) for storing application programs 342 or data 344. The memory 332 and storage media 330 can be temporary or persistent storage. The program stored in the storage media 330 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the server. Furthermore, the CPU 322 may be configured to communicate with the storage media 330 and execute the series of instruction operations stored in the storage media 330 on the server 300.
[0213] Server 300 may also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM etc.
[0214] The steps performed by the server in the above embodiments can be based on this Figure 11 The server structure shown.
[0215] The data processing apparatus provided in this application can be used in terminal devices; please refer to [link / reference]. Figure 12For ease of explanation, only the parts relevant to the embodiments of this application are shown. For specific technical details not disclosed, please refer to the method section of the embodiments of this application. In the embodiments of this application, a smartphone is used as an example for illustration:
[0216] Figure 12 This is a block diagram illustrating a portion of the structure of a smartphone related to the terminal device provided in the embodiments of this application. (Reference) Figure 12 The smartphone includes components such as a radio frequency (RF) circuit 410, a memory 420, an input unit 430, a display unit 440, a sensor 450, an audio circuit 460, a wireless fidelity (WiFi) module 470, a processor 480, and a power supply 490. Those skilled in the art will understand that... Figure 12 The smartphone structure shown does not constitute a limitation on smartphones and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0217] The following is combined with Figure 12 A detailed introduction to the various components of a smartphone:
[0218] RF circuit 410 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and processes it with processor 480; additionally, it transmits uplink data to the base station. Typically, RF circuit 410 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, RF circuit 410 can also communicate wirelessly with networks and other devices. The aforementioned wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile Communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Message Service (SMS), etc.
[0219] The memory 420 can be used to store software programs and modules. The processor 480 executes various functions and data processing of the smartphone by running the software programs and modules stored in the memory 420. The memory 420 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the smartphone (such as audio data, phonebook, etc.). In addition, the memory 420 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.
[0220] The input unit 430 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the smartphone. Specifically, the input unit 430 may include a touch panel 431 and other input devices 432. The touch panel 431, also known as a touch screen, can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel 431), and drive the corresponding connected devices according to a pre-set program. Optionally, the touch panel 431 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 480, and can also receive and execute commands sent by the processor 480. In addition, the touch panel 431 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 431, the input unit 430 may also include other input devices 432. Specifically, other input devices 432 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0221] Display unit 440 can be used to display information input by the user or information provided to the user, as well as various menus of the smartphone. Display unit 440 may include display panel 441, optionally configured as a liquid crystal display (LCD), organic light-emitting diode (OLED), or similar form. Further, touch panel 431 may cover display panel 441. When touch panel 431 detects a touch operation on or near it, it transmits the information to processor 480 to determine the type of touch event. Subsequently, processor 480 provides corresponding visual output on display panel 441 based on the type of touch event. Although in Figure 12 In this embodiment, the touch panel 431 and the display panel 441 are two separate components to realize the input and output functions of the smartphone. However, in some embodiments, the touch panel 431 and the display panel 441 can be integrated to realize the input and output functions of the smartphone.
[0222] The smartphone may also include at least one sensor 450, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 441 according to the ambient light level, and the proximity sensor can turn off the display panel 441 and / or the backlight when the smartphone is moved to the ear. As a type of motion sensor, an accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that recognize the smartphone's posture (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition-related functions (such as pedometer, tapping), etc. Other sensors that may be configured in the smartphone, such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be described in detail here.
[0223] Audio circuit 460, speaker 461, and microphone 462 provide an audio interface between the user and the smartphone. Audio circuit 460 converts received audio data into electrical signals and transmits them to speaker 461, where speaker 461 converts them into sound signals for output. On the other hand, microphone 462 converts collected sound signals into electrical signals, which are received by audio circuit 460, converted into audio data, and then processed by processor 480 before being transmitted via RF circuit 410 to, for example, another smartphone, or the audio data can be output to memory 420 for further processing.
[0224] WiFi is a short-range wireless transmission technology. Smartphones, through their WiFi modules (470), can help users send and receive emails, browse web pages, and access streaming media, providing wireless broadband internet access. Although Figure 12 WiFi module 470 is shown, but it is understood that it is not an essential component of a smartphone and can be omitted as needed without changing the nature of the invention.
[0225] The processor 480 is the control center of the smartphone, connecting various parts of the smartphone through various interfaces and lines. It performs various functions and processes data by running or executing software programs and / or modules stored in the memory 420, and by calling data stored in the memory 420, thereby providing overall monitoring of the smartphone. Optionally, the processor 480 may include one or more processing units; optionally, the processor 480 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the aforementioned modem processor may also not be integrated into the processor 480.
[0226] The smartphone also includes a power supply 490 (such as a battery) that supplies power to various components. Optionally, the power supply can be logically connected to the processor 480 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0227] Although not shown, smartphones may also include a camera, Bluetooth module, etc., which will not be described in detail here.
[0228] The steps performed by the terminal device in the above embodiments can be based on this Figure 12 The terminal device structure is shown.
[0229] This application also provides a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the methods described in the foregoing embodiments.
[0230] This application also provides a computer program product including a program, which, when run on a computer, causes the computer to perform the methods described in the foregoing embodiments.
[0231] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0232] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0233] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0234] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0235] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0236] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A data processing method, characterized in that, include: Obtain the target source code; Based on the target source code, the detection results of the target source code are displayed on the source code detection interface. The detection results of the target source code include those obtained by analyzing the target output parameters and the actual output parameters of the target test unit. The actual output parameters of the target test unit are obtained by executing the test cases of the target test unit. The target output parameters of the target test unit are contained in the test cases of the target test unit. The test cases of the target test unit are generated based on the key information and dependencies of the target source code. The key information and dependencies of the target source code are obtained by parsing the target source code. The target test unit is contained in the target source code and is the smallest test unit in the target source code.
2. The method according to claim 1, characterized in that, The process of displaying the detection results of the target source code on the source code detection interface, based on the target source code, includes: The target source code is parsed to obtain key information about the target source code and its dependencies. Test cases for the target test unit are generated based on the key information of the target source code and the dependencies of the target source code; Execute the test cases of the target test unit to obtain the actual output parameters of the target test unit; The detection results of the target source code are analyzed based on the target output parameters and the actual output parameters of the target test unit. The detection results of the target source code are displayed on the source code detection interface.
3. The method according to claim 2, characterized in that, The generation of test cases for the target test unit based on the key information and dependencies of the target source code includes: The target test unit is determined based on the key information of the target source code and the dependencies of the target source code; Based on the target test unit, generate test cases for the target test unit.
4. The method according to claim 3, characterized in that, The test cases for the target test unit also carry the target input parameters of the target test unit; The step of generating test cases for the target test unit based on the target test unit includes: If the target test unit has input parameters, determine the target input parameter set of the target test unit based on the target test unit; Select the target input parameters of the target test unit according to the target input parameter set; The target output parameters of the target test unit are determined based on the target input parameters and the target test unit. Test cases for the target test unit are generated based on the target test unit, the target input parameters, and the target output parameters.
5. The method according to claim 4, characterized in that, The step of selecting the target input parameters of the target test unit according to the target input parameter set includes: The input parameters of the target test unit are divided into a valid input parameter set and an invalid input parameter set according to the target input parameter set. The valid input parameter set is the target input parameter set, and the invalid input parameter set is a non-target input parameter set. A first input parameter is selected from the set of valid input parameters, wherein the first input parameter is included in the target input parameter; A second input parameter is selected from the set of invalid input parameters, and the second input parameter is included in the target input parameter.
6. The method according to claim 5, characterized in that, The first input parameter is the largest value in the set of valid input parameters, or the smallest value in the set of valid input parameters; the second input parameter is the smallest value in the set of invalid input parameters, or the largest value in the set of invalid input parameters.
7. The method according to claim 4, characterized in that, The target input parameter set indicates the compliant input parameter types of the target test unit; The step of selecting the target input parameters of the target test unit according to the target input parameter set includes: A third input parameter is selected based on the target input parameter set, wherein the third input parameter is not included in the target input parameter set, and the third input parameter is included in the target input parameter.
8. The method according to claim 4, characterized in that, The method further includes: Obtain the preset input parameters and preset output parameters of the target test unit, wherein the preset input parameters and the preset output parameters correspond one-to-one; Determining the target output parameters of the target test unit based on the target input parameters and the target test unit includes: When the target input parameter is the preset input parameter, the target input parameter is determined to be the preset output parameter based on the target input parameter and the target test unit.
9. The method according to claim 3, characterized in that, The step of generating test cases for the target test unit based on the functions in the target test unit includes: If the function in the target test unit has no input parameters, run the target test unit to obtain the target output parameters of the target test unit; Test cases for the target test unit are generated based on the target test unit and the target output parameters.
10. The method according to claim 2, characterized in that, The process of executing test cases to obtain the actual output parameters of the target test unit includes: When the test cases of the target test unit meet the preset conditions, the test cases of the target test unit are executed to obtain the actual output parameters of the target test unit.
11. The method according to claim 3, characterized in that, After determining the target test unit based on the key information and dependencies of the target source code, the method further includes: Generate the identity identifier of the target test unit; The function in the target test unit is uniquely identified by the identity identifier of the target test unit. The function in the target test unit is contained in the lexical unit of the target test unit or the class name of the target test unit.
12. A data processing apparatus, characterized in that, include: The acquisition unit is used to acquire the target source code; An interactive unit is used to display the detection results of the target source code on a source code detection interface based on the target source code. The detection results of the target source code include those obtained by analyzing the target output parameters and the actual output parameters of the target test unit. The actual output parameters of the target test unit are obtained by executing the test cases of the target test unit. The target output parameters of the target test unit are contained in the test cases of the target test unit. The test cases of the target test unit are generated based on the key information and dependencies of the target source code. The key information and dependencies of the target source code are obtained by parsing the target source code. The target test unit is contained in the target source code and is the smallest test unit in the target source code.
13. A computer device, characterized in that, include: Memory, processor, and bus system; The memory is used to store programs; The processor is configured to execute a program in the memory, and the processor is configured to execute the method of any one of claims 1 to 11 according to instructions in the program code; The bus system is used to connect the memory and the processor to enable communication between the memory and the processor.
14. A computer-readable storage medium comprising instructions that, when executed on a computer, cause the computer to perform the method as claimed in any one of claims 1 to 11.
15. A computer program product, comprising a computer program, characterized in that, The computer program is executed by a processor using the method as described in any one of claims 1 to 11.