Test case processing method, device, electronic device and storage medium
By splitting the unit test generation process based on microservice thinking and using code feature data to generate test cases, we can solve the problems of insufficient versatility and scalability of unit test generation in existing technologies and realize automated test case generation that adapts to different programming languages and business scenarios.
Patent Information
- Application Number
- CN202210203828.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-03
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2042-03-03
AI Technical Summary
Existing unit test generation technology lacks versatility and scalability in actual production environments, and is difficult to adapt to the needs of different programming languages and business scenarios.
Adopting the microservice concept, the unit test generation process is systematically split, code feature data is used as the context abstract data representation model, test case data is generated, and automated test case generation is achieved through the use case code generation strategy to adapt to different programming languages and business scenarios.
It realizes the automatic generation of test cases, which is universal and extensible, adapts to the needs of different programming languages and business scenarios, and improves testing efficiency and quality.
Smart Images

Figure CN114610608B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to the field of testing technology, and specifically to a test case processing method, apparatus, electronic device, and storage medium. Background Art
[0002] With the growing number of software applications and the continuous development of the software industry, high-quality code has become a universal requirement of the industry and users. High-quality software is inseparable from software testing. Software testing is the process of operating code under specified conditions to detect code anomalies, measure software quality, and evaluate whether it meets design requirements. Software testing can include unit testing, functional testing, and stress testing.
[0003] Unit testing (i.e. module testing) is a testing work that verifies the correctness of code modules (i.e. the smallest unit of software design). Summary of the Invention
[0004] The present disclosure provides a test case processing method, device, electronic device, and storage medium.
[0005] According to one aspect of the present disclosure, a test case processing method is provided, including: analyzing code feature data corresponding to a code under test, determining a use case data generation strategy for at least one object under test corresponding to the code under test; generating test case data corresponding to the object under test by using the use case data generation strategy corresponding to the object under test; determining a use case code generation strategy based on the code feature data and the test case data corresponding to the at least one object under test; generating test case code by using the use case code generation strategy; and generating a test case for testing the code under test based on the test case code and the test case data corresponding to the at least one object under test.
[0006] According to another aspect of the present disclosure, a first determination module is provided for analyzing code feature data corresponding to a code under test and determining a use case data generation strategy for at least one object under test corresponding to the code under test; a first generation module is provided for generating test case data corresponding to the object under test by using the use case data generation strategy corresponding to the object under test; a second determination module is provided for determining a use case code generation strategy based on the code feature data and the test case data corresponding to the at least one object under test; a second generation module is provided for generating test case code by using the use case code generation strategy; and a third generation module is provided for generating a test case for testing the code under test based on the test case code and the test case data corresponding to the at least one object under test.
[0007] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in the present disclosure.
[0008] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the present disclosure.
[0009] According to another aspect of the present disclosure, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method described in the present disclosure is implemented.
[0010] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.
[0012] Figure 1 Schematically illustrates an exemplary system architecture to which the test case processing method and apparatus according to an embodiment of the present disclosure can be applied;
[0013] Figure 2 The following schematically shows a flow chart of a test case processing method according to an embodiment of the present disclosure;
[0014] Figure 3A The following schematically illustrates an example of a test case processing process according to an embodiment of the present disclosure;
[0015] Figure 3B The following schematically illustrates an example of a test case data generation process according to an embodiment of the present disclosure;
[0016] Figure 3C The following schematically illustrates an example of a test case code generation process according to an embodiment of the present disclosure;
[0017] Figure 3D Schematically illustrates an example diagram of a process for determining failure cause information according to an embodiment of the present disclosure;
[0018] Figure 4 A block diagram schematically shows a test case processing device according to an embodiment of the present disclosure; and
[0019] Figure 5A block diagram of an electronic device suitable for implementing a test case processing method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0020] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0021] Unit test generation can refer to the process of code understanding, test case data generation, and test case code generation for the code under test without human intervention. However, unit test generation technology is not universal and scalable enough in actual production environments.
[0022] To this end, the embodiment of the present disclosure is based on the idea of microservices, and systematically splits the various stages of the unit test generation process. It uses code feature data as the context abstract data representation model, and takes into account the universality and extensibility of each stage, so as to facilitate implementation in different programming languages and different unit test driver codes. Therefore, a test case processing solution is proposed. The code feature data corresponding to the code under test is analyzed to determine the use case data generation strategy for at least one object under test corresponding to the code under test. The use case data generation strategy corresponding to the object under test is used to generate test case data corresponding to the object under test. According to the code feature data and the test case data corresponding to at least one object under test, a use case code generation strategy is determined. The test case code generation strategy is used to generate test case code. According to the test case code and the test case data corresponding to at least one object under test, a test case for testing the code under test is generated.
[0023] According to the embodiments of the present disclosure, a use case data generation strategy corresponding to the object under test is utilized to generate test case data corresponding to the object under test, a use case code generation strategy determined based on code feature data and test case data is utilized to generate test case code, and then a test case is generated based on the test case code and test case data. This realizes the automated generation of test cases, is not restricted by programming language types and business scenarios, and has universality and extensibility.
[0024] This application adopts the idea of microservices, systematically splits each stage of unit test generation, uses code feature files as the context abstract data representation model, and takes into account the versatility and scalability of each subsystem, making it easy to implement in different languages, different unit test driver codes, and different test targets.
[0025] Figure 1 An exemplary system architecture to which the test case processing method and apparatus according to an embodiment of the present disclosure can be applied is schematically shown.
[0026] It should be noted that Figure 1 The examples shown are merely examples of system architectures to which the embodiments of the present disclosure can be applied, to help those skilled in the art understand the technical content of the present disclosure. This does not mean that the embodiments of the present disclosure cannot be applied to other devices, systems, environments, or scenarios. For example, in another embodiment, the exemplary system architecture to which the test case processing method and apparatus can be applied may include a terminal device, but the terminal device can implement the test case processing method and apparatus provided by the embodiments of the present disclosure without interacting with a server.
[0027] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links.
[0028] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as knowledge reading applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software (for example only).
[0029] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0030] Server 105 can be any type of server that provides various services. For example, server 105 can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system. It solves the problems of traditional physical hosts and VPS services (Virtual Private Servers), such as difficult management and poor business scalability.
[0031] It should be noted that the test case processing method provided in the embodiment of the present disclosure can generally be executed by the terminal device 101, 102, or 103. Accordingly, the test case processing apparatus provided in the embodiment of the present disclosure can also be provided in the terminal device 101, 102, or 103.
[0032] Alternatively, the test case processing method provided by the embodiment of the present disclosure may also be generally executed by the server 105. Accordingly, the test case processing apparatus provided by the embodiment of the present disclosure may generally be provided in the server 105. The test case processing method provided by the embodiment of the present disclosure may also be performed by a server or server cluster that is different from the server 105 and that is capable of communicating with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the test case processing apparatus provided by the embodiment of the present disclosure may also be provided in a server or server cluster that is different from the server 105 and that is capable of communicating with the terminal devices 101, 102, 103 and / or the server 105.
[0033] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0034] It should be noted that the sequence numbers of the operations in the following method are only used to indicate the operation for the purpose of description, and should not be regarded as indicating the order in which the operations should be performed. Unless explicitly stated, the method does not need to be performed in the order shown.
[0035] Figure 2 The flowchart of the test case processing method according to the embodiment of the present disclosure is schematically shown.
[0036] like Figure 2 As shown, the method 200 includes operations S210 to S250.
[0037] In operation S210 , code feature data corresponding to the code under test is analyzed to determine a use case data generation strategy for at least one object under test corresponding to the code under test.
[0038] In operation S220 , a test case data corresponding to the object under test is generated using a use case data generation strategy corresponding to the object under test.
[0039] In operation S230 , a use case code generation strategy is determined based on the code feature data and test case data corresponding to at least one object under test.
[0040] In operation S240 , test case codes are generated using a use case code generation strategy.
[0041] In operation S250 , a test case for testing the code under test is generated according to the test case code and test case data corresponding to at least one object under test.
[0042] According to embodiments of the present disclosure, the code under test may refer to the code to be tested. The object under test may refer to the object to be tested. An object may include a function or a class. The code under test may include at least one object under test. The programming language corresponding to the code under test may be determined based on the business scenario and test environment.
[0043] According to an embodiment of the present disclosure, code feature data may refer to data relied upon for generating test cases. Code feature data may include code feature data of multiple granularities. Code feature data may be structured data. Structured feature data may refer to data that is structured and can be divided into predetermined components. Code feature data may have logical relationships. Logical relationships include at least one of the following: parallel relationships and nested relationships. The storage format of code feature data may be configured according to actual business needs and is not limited here. For example, the storage format of code feature data may include XML (Extensible Markup Language). XML may refer to a markup language used to mark electronic files to give them a structure. Code feature data may be stored in a code feature data file in a predetermined storage format. The predicted storage format may include XML. Therefore, the code feature data file may be an XML file. Schema languages used to define and describe the structure and content of XML files may include DTD (Document Type Definition) or XML Schema (Extensible Markup Language Architecture). For example, XML Schema may be used to define and describe the structure and content of an XML file. XML Schema may be determined based on the data type and parameter assignment method. Basic attributes can be supported by defining tags. Basic attributes can include declaration types and type classifications. Tags can include ClassInfo tags, ConfInfo tags, or GlobalInfo tags.
[0044] According to an embodiment of the present disclosure, a test case may refer to a use case written during a software testing process to test input parameters, execution conditions, and expected results to meet predetermined goals, so as to test whether the code under test meets predetermined requirements.
[0045] According to an embodiment of the present disclosure, a use case data generation strategy may refer to a strategy for how to generate test case data. The use case data generation strategy may include at least one of the following: a generation strategy based on a pairwise algorithm, a generation strategy based on a variable elimination algorithm, a generation strategy based on a path algorithm, and a generation strategy based on a heuristic algorithm, etc. The heuristic algorithm may include at least one of the following: a genetic algorithm (GA), a greedy algorithm (GA), a simulated annealing algorithm (SAA), a tabu search (TS) algorithm, an evolutionary algorithm (EA), and an ant colony algorithm (AA), etc. The use case data generation strategies for different objects under test may be the same or different.
[0046] According to embodiments of the present disclosure, in the process of generating test case data corresponding to the object under test, the path information and branch information of the code under test can be used to guide the data fuzzing algorithm to achieve coverage of more branches. Variable diffusion correlation can also be used to reduce the probability of generating invalid test case data. In addition, the data fuzzing algorithm can be used as an independent generation module. The data fuzzing algorithm can also be used to optimize the use case data generation strategy.
[0047] According to embodiments of the present disclosure, a use case code generation strategy may refer to a strategy for generating test case code. For example, the use case code generation strategy may include determining the content of a use case code generator and a use case code generation operator. The use case code generator may determine the use case code generation operator based on test case data and code feature data corresponding to the code under test.
[0048] According to an embodiment of the present disclosure, a code under test can be determined in response to a test case generation request. The code under test may include at least one object under test. Code feature data corresponding to the code under test is determined. The code feature data corresponding to the code under test is analyzed to determine a use case data generation strategy corresponding to at least one object under test. For example, a use case data generation strategy corresponding to each of the at least one object under test can be determined. Alternatively, a use case data generation strategy corresponding to each of the at least one object under test can be determined. After determining the use case data generation strategy corresponding to the object under test, the use case data generation strategy corresponding to the at least one object under test can be used to generate test case data corresponding to the at least one object under test. For example, the use case data generation strategy corresponding to the at least one object under test can be used to generate test case data corresponding to each of the at least one object under test. That is, the use case data generation strategy corresponding to the object under test can be used to assign values to the object under test to obtain test case data.
[0049] According to an embodiment of the present disclosure, a use case code generation strategy for generating test code can be determined based on code feature data and test case data corresponding to at least one object under test, so that test case code can be generated using the use case code generation strategy. A test case can be generated based on the test case code and the test case data corresponding to each of the at least one object under test.
[0050] According to the embodiments of the present disclosure, a use case data generation strategy corresponding to the object under test is utilized to generate test case data corresponding to the object under test, a use case code generation strategy determined based on code feature data and test case data is utilized to generate test case code, and then a test case is generated based on the test case code and test case data. This realizes the automated generation of test cases, is not restricted by programming language types and business scenarios, and has universality and extensibility.
[0051] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0052] According to the selection strategy, the code to be tested is determined from the current submitted code.
[0053] According to an embodiment of the present disclosure, a selection strategy may refer to a strategy for determining the code under test from the currently submitted code. The selection strategy may include at least one of the following: a selection strategy based on changed code, a selection strategy based on object attribute information, a selection strategy based on risk level information, and a selection strategy based on business whitelist information. Object attribute information may include at least one of the following: object type and object attributes. Objects may include at least one of the following: files, classes, and functions.
[0054] According to the embodiments of the present disclosure, by determining the code to be tested from the currently submitted code according to the selection strategy, the amount of test data is reduced and the test efficiency is improved.
[0055] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0056] Feature extraction is performed on the code under test to obtain code feature data corresponding to the code under test.
[0057] According to an embodiment of the present disclosure, feature extraction can be performed on the code under test to obtain relevant data corresponding to the code under test. The relevant data may include at least one of the following: input parameters, internal dependency parameters, other dependency parameters, and return values, etc. The relevant data are processed using a feature selection strategy to obtain code feature data corresponding to the code under test. The feature selection strategy may include multiple granularities. For example, the feature selection strategy may include at least one of the following: a feature selection strategy based on file granularity, a feature selection strategy based on class granularity, a feature selection strategy based on function granularity, a feature selection strategy based on configuration granularity, and a feature selection strategy based on global granularity.
[0058] According to the embodiments of the present disclosure, a feature selection strategy based on file granularity can be used to process relevant data to obtain code feature data at file granularity. A feature selection strategy based on class granularity can be used to process relevant data to obtain code feature data at class granularity. A feature selection strategy based on function granularity can be used to process relevant data to obtain code feature data at function granularity. A feature selection strategy based on configuration granularity can be used to process relevant data to obtain code feature data at configuration granularity. A feature selection strategy based on global granularity can be used to process relevant data to obtain code feature data at global granularity.
[0059] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0060] The code feature data is stored in a code feature data file in a predetermined storage format.
[0061] According to an embodiment of the present disclosure, the code under test is abstractly represented as a code feature data file stored in a file format. The code feature data file can serve as an abstract data representation model connecting upstream and downstream.
[0062] According to an embodiment of the present disclosure, the code feature data may include at least one of the following: code feature data at file granularity, code feature data at class granularity, code feature data at function granularity, code feature data at configuration granularity, and code feature data at global granularity.
[0063] According to an embodiment of the present disclosure, the code feature data at the file granularity may include at least one of the following: header file dependency data, namespace data, and package dependency data, etc. The code feature data at the class granularity may include at least one of the following: description data and other object-oriented data. The description data may include Class and Struct. The code feature data at the function granularity may include at least one of the following: data for describing the return value of the function, data for describing the parameter list, and data for describing the function attributes. The code feature data at the configuration granularity may include configuration content data for describing function dependencies. The code feature data at the global granularity may include data for describing additional dependencies of the code module from a global perspective.
[0064] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0065] According to an embodiment of the present disclosure, operation S420 may include the following operations.
[0066] A parameter value generation strategy corresponding to the object under test is determined based on a use case data generation strategy corresponding to the object under test. A target parameter value is determined from at least one predetermined parameter value based on the parameter value generation strategy corresponding to the object under test. Test case data corresponding to the object under test is generated based on the target parameter value.
[0067] According to an embodiment of the present disclosure, a parameter value generation strategy may refer to a strategy for how to generate parameter values corresponding to the object under test. The parameter value generation strategy may include at least one of the following: a random generation strategy, an interval random generation strategy, a regular random generation strategy, a mutation generation strategy, and a business customized generation strategy. A random generation strategy may refer to a strategy for randomly selecting parameter values from a data source to generate test case data. An interval random strategy may refer to a strategy for randomly selecting parameter values that conform to a predetermined parameter value interval from a data source to generate test case data. A regular random generation strategy may refer to a strategy for randomly selecting parameter values that conform to predetermined regular rules from a data source to generate test case data. A mutation generation strategy may refer to a strategy for mutating historical parameter values corresponding to the object under test to generate test case data. A business customized generation strategy may refer to a strategy for generating test case data by generating parameter values created according to business requirements.
[0068] According to an embodiment of the present disclosure, at least one predetermined parameter value may include at least one of the following: at least one predetermined parameter value corresponding to at least one predetermined boundary value, at least one predetermined parameter value corresponding to at least one predetermined interval range, at least one predetermined parameter value corresponding to at least one predetermined regular rule, and at least one predetermined parameter value corresponding to a business requirement.
[0069] According to an embodiment of the present disclosure, a parameter value generation strategy is associated with a use case data generation strategy. Based on the parameter value generation strategy corresponding to the object under test, a target parameter value can be determined from at least one predetermined parameter value, and the target parameter value can be determined as test case data corresponding to the object under test. Alternatively, the target parameter value can be processed to obtain test case data corresponding to the object under test. The at least one predetermined parameter value can be stored in a data source. The data source can include a database.
[0070] For example, the data type of the object under test is an integer, and the numerical range of the target parameter value corresponding to the object under test is not limited. Therefore, the strategy for generating the parameter value corresponding to the object under test can be a random generation strategy. Based on the above, a predetermined parameter value can be randomly selected from at least one predetermined parameter value corresponding to at least one predetermined boundary value as the target parameter value. The target parameter value can be determined as the test case data corresponding to the object under test.
[0071] For example, the data type of the measured object is integer. A parameter value generation strategy corresponding to the measured object is determined to be a variation generation strategy. A historical parameter value corresponding to the measured object can be determined from at least one predetermined parameter value. The historical parameter value is converted from the current data base to another data base to obtain a converted historical parameter value. A predetermined number of digits of the converted historical parameter value is then adjusted to obtain an adjusted historical parameter value. The adjusted historical parameter value is then converted from the other data base to the current data base to obtain a target parameter value corresponding to the measured object.
[0072] According to an embodiment of the present disclosure, operation S240 may include the following operations.
[0073] Determine type information corresponding to the code feature data. The type information may include at least one of the following: programming language type and business type. Based on the type information, determine a use case code generator and template code. Utilize the use case code generator to determine a use case code generation operator based on the code feature data and test case data corresponding to at least one object under test. Utilize the use case code generation operator to generate target code. Generate test case code based on the target code and the template code.
[0074] According to embodiments of the present disclosure, different programming language types can have different use case code generators and template codes. Different business types can also have different use case code generators and template codes. This makes it easy to expand the test case processing solutions provided by embodiments of the present disclosure.
[0075] According to an embodiment of the present disclosure, a use case code generator may have at least one use case code generation operator associated with the use case code generator. The at least one use case code generation operator may include at least one of the following: a use case code generation operator for generating a complex type LIB, a use case code generation operator for generating a custom type LIB, a use case code generation operator for generating a basic type LIB, and a use case code generation operator for generating a unit test base LIB. The LIB may include a static link LIB library and an import LIB library.
[0076] According to an embodiment of the present disclosure, for each of at least one tested object included in the tested code, code feature data corresponding to the tested object can be analyzed to determine type information of the code feature data corresponding to the tested object. After determining the type information, a use case code generator and template code corresponding to the tested object can be determined based on the type information.
[0077] According to an embodiment of the present disclosure, after determining a use case code generator corresponding to a test object, a use case code generation operator corresponding to the test object can be determined based on code feature data and test case data corresponding to at least one test object. After determining the use case code generation operator corresponding to the test object, the target code can be generated using the use case code generation operator.
[0078] According to an embodiment of the present disclosure, the code feature data corresponding to at least one object under test can be traversed and analyzed in a top-to-bottom manner to obtain type information corresponding to each of the at least one object under test. Based on the type information corresponding to each of the at least one object under test, the use case code generator and template code corresponding to each of the at least one object under test are determined. Based on the use case code generator corresponding to each of the at least one object under test, the use case code generation operator corresponding to each of the at least one object under test is determined. The use case generation operator corresponding to each of the at least one object under test can be used in a bottom-to-top manner to generate test case code corresponding to each of the at least one object under test. Based on the test case code corresponding to each of the at least one object under test, the test case code corresponding to the code under test is obtained.
[0079] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0080] Evaluate the test case data corresponding to the object under test to obtain at least one evaluation index value, and determine a quality evaluation result of the test case data based on the at least one evaluation index value.
[0081] According to an embodiment of the present disclosure, the at least one evaluation indicator may include at least one of the following: code line coverage, code branch rate, function coverage, and depth coverage. The quality evaluation result may include pass or fail.
[0082] According to an embodiment of the present disclosure, at least one evaluation index value can be compared with the respective corresponding predetermined evaluation index thresholds to obtain a comparison result. Based on the comparison result, the quality evaluation result of the test case data is determined. For example, for each evaluation index value in the at least one evaluation index value, when it is determined that the evaluation index value is greater than or equal to the predetermined evaluation index threshold corresponding to the evaluation index value, it is determined that the quality evaluation result for the evaluation index corresponding to the evaluation index value is passed. When it is determined that the evaluation index value is less than the predetermined evaluation index threshold corresponding to the evaluation index value, it is determined that the quality evaluation result for the evaluation index corresponding to the evaluation index value is failed. In this way, a quality evaluation result corresponding to each of the at least one evaluation index can be obtained. The predetermined evaluation index threshold can be configured according to actual business needs and is not limited here.
[0083] According to an embodiment of the present disclosure, determining the quality assessment result of the test case data based on the comparison result may include: determining that the quality assessment result of the test case data is passed when the number of quality assessment results determined to be passed is greater than or equal to a predetermined threshold. Determining that the quality assessment result of the test case data is failed when the number of quality assessment results determined to be passed is less than the predetermined threshold. The predetermined threshold can be configured according to actual business needs and is not limited here.
[0084] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0085] When it is determined that the quality evaluation result is a failure, the test case data is adjusted according to at least one evaluation indicator value so that the new quality evaluation result is a pass.
[0086] According to an embodiment of the present disclosure, if the quality assessment result is determined to be a failure, the test case data can be adjusted to obtain new test case data. The new test case data corresponding to the tested object can be evaluated to obtain at least one new evaluation index value. The quality assessment result of the new test case data is determined based on the at least one new evaluation index value.
[0087] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0088] Execute the test case and get the test case execution result.
[0089] According to an embodiment of the present disclosure, the test case execution result may include a test case execution success or a test case execution failure.
[0090] According to an embodiment of the present disclosure, a compilation instruction can be generated based on the compilation configuration information. The compilation instruction can refer to an instruction for compiling the test case code. In response to detecting the compilation instruction, a general use case execution framework is called and rewrite information corresponding to the code under test is created. The general use case execution framework is adjusted based on the rewrite information corresponding to the code under test to obtain a use case execution framework corresponding to the code under test. The test case is executed using the use case execution framework corresponding to the code under test to obtain a use case execution result.
[0091] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0092] If a test case execution failure is determined based on the test case execution results, the test case execution results are analyzed to determine the error type and the core problem code of the code under test. Syntax analysis is performed on the core problem code and the test case code to obtain a syntax analysis result. Based on the error type information and the syntax analysis result, the cause of the failure is determined.
[0093] According to an embodiment of the present disclosure, error type information can be used to characterize the type of test case execution failure. For example, error type information can include an error caused by division by zero. The core (i.e., core) problem code can refer to the code that plays a key role in causing the test case execution failure. The core problem code can include a core problem code line identifier and the content of the core problem code.
[0094] According to an embodiment of the present disclosure, a test case execution result can be determined to be either a successful test case execution or a failed test case execution. If the test case execution result is determined to be a successful test case execution, the test case processing operation can be terminated. If the test case execution result is determined to be a failed test case execution, the test case execution result can be analyzed to obtain error type information and a core problem code.
[0095] According to an embodiment of the present disclosure, a syntax analysis method can be used to analyze the core problem code and the test case code to obtain a syntax analysis result. The syntax analysis method may include an Abstract Syntax Tree (AST). Based on the syntax analysis result and error type information, the failure reason information that caused the test case execution failure can be determined.
[0096] For example, test cases can be stored in a stack. From the stack information, failure stack information corresponding to test cases where the test case execution result is a test case failure can be determined. The failure stack information can be parsed to obtain valid stack top information. Based on the valid stack top information, the core problem code can be determined.
[0097] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0098] Determine the risk level based on the failure cause information.
[0099] According to an embodiment of the present disclosure, the risk level may include a low risk level or a high risk level. A low risk level may indicate that the core problem code is an ignorable problem code. A high risk level may indicate that the core problem code is a non-ignorable problem code. If the core problem code is an ignorable problem code, the problem with the core problem code may be ignored. If the core problem code is a non-ignorable problem code, the problem with the core problem code may not be ignored and the core problem code needs to be modified.
[0100] According to an embodiment of the present disclosure, determining the risk level according to the failure cause information may include the following operations.
[0101] A key value corresponding to the core problem code is determined. If it is determined that there is a low risk key value matching the key value in the at least one low risk key value, the risk level is determined to be a low risk level.
[0102] According to an embodiment of the present disclosure, a key value can be used to characterize a core problem code. A core problem code corresponding to a low-risk key value can be characterized as a negligible problem code. A core problem code corresponding to a low-risk key value can be a manually labeled negligible problem code.
[0103] According to an embodiment of the present disclosure, a message digest algorithm can be used to determine a key value corresponding to a core problem code. It is determined whether there is a low-risk key value matching the key value in at least one low-risk key value. When it is determined that there is a low-risk key value matching the key value in at least one low-risk key value, it can be determined that the risk level is a low-risk level. For example, at least one low-risk key value can be stored in a question library. A static scanning method can be used to scan the question library to determine whether there is a low-risk key value matching the key value in the question library.
[0104] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0105] When it is determined that no low-risk key value matching the key value exists in at least one low-risk key value, and if the core problem code is determined to be an ignorable problem code based on the call relationship chain, the risk level is determined to be a low-risk level.
[0106] According to an embodiment of the present disclosure, the call relationship chain (ie, the variable relationship tree) can characterize the call relationship of the parameter value of the tested object. If the core problem code is determined to be an ignorable problem code based on the call relationship chain, the risk level can be determined to be a low risk level.
[0107] For example, if the failure reason is determined to be a division by zero problem in the core problem code. That is, in the division operation, the value of the denominator of the parameter (i.e., the parameter value) is zero. Based on the calling relationship chain of the parameter value, it is determined that the upper-level code that calls the parameter value includes the information "if it is determined that the parameter value is not zero, perform subsequent operations", thereby determining that the parameter value is not zero. In this case, the core problem code is determined to be an ignorable problem code based on the calling relationship chain.
[0108] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0109] If the core problem code is determined to be a non-ignorable problem code based on the call relationship chain, a core problem code vector corresponding to the core problem code is determined. The core problem code vector is processed using a risk assessment model to obtain a risk assessment result indicating whether the risk level is a low risk level or a high risk level.
[0110] According to an embodiment of the present disclosure, a risk assessment model can be used to assess the risk level of core problem codes. The risk assessment model can be obtained by training a predetermined model using sample core problem codes. The predetermined model can include a deep learning model.
[0111] According to embodiments of the present disclosure, if a core problem code is determined to be non-ignorable based on a call relationship chain, the core problem code can be vectorized to obtain a core problem code vector corresponding to the core problem code. The core problem vector can then be input into a risk assessment model to obtain a risk assessment result.
[0112] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0113] If the test case execution result is determined to be a successful test case execution, a test case execution report is generated based on the test case execution result. If the test case execution result is determined to be a failed test case execution, a test case execution report is generated based on the failure reason information.
[0114] According to an embodiment of the present disclosure, the above test case processing method may further include the following operations.
[0115] Visually display the test case execution report.
[0116] According to embodiments of the present disclosure, a unified task center, problem center, and reporting service can be built. The problem center can be used to store test case-related information corresponding to test case execution failures. The reporting service can be used to render task information and problem information, and display test case execution reports to users, thereby forming a complete closed-loop chain.
[0117] Reference below Figure 3A 、 Figure 3B 、 Figure 3C and Figure 3D , the test case processing method according to the embodiment of the present disclosure is further explained in combination with specific embodiments.
[0118] Figure 3A An example diagram of a test case processing process according to an embodiment of the present disclosure is schematically shown.
[0119] As shown in FIG3 , in step 300A, based on a selection strategy, code under test 302 is determined from currently submitted code 301. Code feature data 303 corresponding to code under test 302 is analyzed to determine a use case data generation strategy 304 for at least one object under test corresponding to code under test 302. Test case data 305 corresponding to the object under test is generated using the use case data generation strategy 304. Based on code feature data 303 and the test case data 305 corresponding to the at least one object under test, a use case code generation strategy 306 is determined. Based on the use case code generation strategy 306, test case code 307 is generated. Based on the test case code 307 and the test case data 305 corresponding to the at least one object under test, a test case 308 for testing the code under test is generated.
[0120] Figure 3B An example diagram of a test case data generation process according to an embodiment of the present disclosure is schematically shown.
[0121] like Figure 3B As shown in FIG300B, a parameter value generation strategy 309 corresponding to the object under test is determined based on a use case data generation strategy 304 corresponding to the object under test. A target parameter value 310 is determined from at least one predetermined parameter value based on the parameter value generation strategy 309 corresponding to the object under test. Based on the target parameter value 310, test case data 305 corresponding to the object under test is generated.
[0122] Figure 3C An example diagram of a test case code generation process according to an embodiment of the present disclosure is schematically shown.
[0123] like Figure 3C As shown, in 300C, type information 311 corresponding to code feature data 303 is determined. Based on type information 311, a use case code generator 312 and template code 313 are determined. Use case code generator 312 determines a use case code generation operator 314 based on code feature data 303 and test case data 305 corresponding to at least one object under test. Use use case code generation operator 314 generates target code 315. Based on target code 315 and template code 313, test case code 307 is generated.
[0124] Figure 3D An example diagram of a process for determining failure cause information according to an embodiment of the present disclosure is schematically shown.
[0125] like Figure 3D As shown in 300D, test case 308 is executed, obtaining a test case execution result 316. If the test case execution is determined to have failed based on test case execution result 316, test case execution result 316 is analyzed to determine error type information 317 and a core problem code 318 of the code under test. Syntax analysis is performed on core problem code 318 and test case code 307 to obtain a syntax analysis result 319. Based on error type information 317 and syntax analysis result 319, failure cause information 320 is obtained.
[0126] The above are only exemplary embodiments, but are not limited to them. Other test case processing methods known in the art may also be included, as long as they can realize automatic generation of test cases, are not restricted by programming language types and business scenarios, and are universal and extensible.
[0127] Figure 4 The block diagram of the test case processing device according to the embodiment of the present disclosure is schematically shown.
[0128] like Figure 4 As shown, the test case processing apparatus 400 may include a first determination module 410 , a first generation module 420 , a second determination module 430 , a second generation module 440 and a third generation module 450 .
[0129] The first determination module 410 is configured to analyze code feature data corresponding to the code under test and determine a use case data generation strategy for at least one object under test corresponding to the code under test.
[0130] The first generating module 420 is configured to generate test case data corresponding to the object under test by using a use case data generating strategy corresponding to the object under test.
[0131] The second determining module 430 is configured to determine a use case code generation strategy based on the code feature data and the test case data corresponding to at least one object under test.
[0132] The second generating module 440 is configured to generate test case codes using a use case code generation strategy.
[0133] The third generating module 450 is configured to generate a test case for testing the code under test based on the test case code and test case data corresponding to at least one object under test.
[0134] According to an embodiment of the present disclosure, the first generating module 420 may include a first determining submodule, a second determining submodule, and a first generating submodule.
[0135] The first determination submodule is used to determine a parameter value generation strategy corresponding to the object under test based on a use case data generation strategy corresponding to the object under test.
[0136] The second determining submodule is configured to determine a target parameter value from at least one predetermined parameter value according to a parameter value generation strategy corresponding to the measured object.
[0137] The first generating submodule is used to generate test case data corresponding to the object under test according to the target parameter value.
[0138] According to an embodiment of the present disclosure, the test case processing apparatus 400 may further include an evaluation module and a third determination module.
[0139] The evaluation module is used to evaluate the test case data corresponding to the object under test to obtain at least one evaluation index value.
[0140] The third determining module is used to determine the quality evaluation result of the test case data according to at least one evaluation index value.
[0141] According to an embodiment of the present disclosure, the test case processing apparatus 400 may further include an adjustment module.
[0142] The adjustment module is used to adjust the test case data according to at least one evaluation index value when it is determined that the quality evaluation result is failed, so that the new quality evaluation result is passed.
[0143] According to an embodiment of the present disclosure, the second generating module 440 may include a third determining submodule, a fourth determining submodule, a fifth determining submodule, a second generating submodule, and a third generating submodule.
[0144] The third determining submodule is configured to determine type information corresponding to the code feature data. The type information includes at least one of the following: programming language type and business type.
[0145] The fourth determination submodule is used to determine the use case code generator and the template code according to the type information.
[0146] The fifth determining submodule is configured to utilize the use case code generator to determine a use case code generation operator according to the code feature data and the test case data corresponding to at least one object under test.
[0147] The second generation submodule is used to generate operators using the use case code to generate target code.
[0148] The third generation submodule is used to generate test case code according to the target code and the template code.
[0149] According to an embodiment of the present disclosure, the test case processing apparatus 400 may further include a first obtaining module.
[0150] The first acquisition module is used to execute the test case and obtain the test case execution result.
[0151] According to an embodiment of the present disclosure, the test case processing apparatus 400 may further include a fourth determining module, a second obtaining module, and a third obtaining module.
[0152] In the case where the test case execution fails according to the test case execution result,
[0153] The fourth determination module is used to analyze the execution results of the use case and determine the error type information and the core problem code of the tested code.
[0154] The second acquisition module is used to perform syntax analysis on the core problem code and the test case code to obtain the syntax analysis results.
[0155] The third obtaining module is used to obtain failure reason information based on the error type information and the syntax analysis result.
[0156] According to an embodiment of the present disclosure, the test case processing apparatus 400 may further include a fifth determining module.
[0157] The fifth determination module is used to determine the risk level according to the failure cause information.
[0158] According to an embodiment of the present disclosure, the fifth determining module may include a sixth determining submodule and a seventh determining submodule.
[0159] The sixth determination submodule is used to determine the key value corresponding to the core problem code.
[0160] The seventh determining submodule is configured to determine that the risk level is a low risk level when it is determined that there is a low risk key value matching the key value in the at least one low risk key value.
[0161] According to an embodiment of the present disclosure, the test case processing apparatus 400 may further include a sixth determining module.
[0162] The sixth determination module is used to determine that the risk level is a low risk level if it is determined that there is no low risk key value matching the key value in at least one low risk key value and if the core problem code is determined to be an ignorable problem code based on the call relationship chain.
[0163] According to an embodiment of the present disclosure, the test case processing apparatus 400 may further include a seventh determining module and a fourth obtaining module.
[0164] The seventh determination module is configured to determine a core problem code vector corresponding to the core problem code if the core problem code is determined to be a non-ignorable problem code according to the call relationship chain.
[0165] The fourth obtaining module is used to process the core problem code vector using the risk assessment model to obtain a risk assessment result indicating whether the risk level is a low risk level or a high risk level.
[0166] According to an embodiment of the present disclosure, the test case processing apparatus 400 may further include an eighth determining module.
[0167] The eighth determination module is used to determine the code to be tested from the currently submitted code according to the selection strategy.
[0168] According to an embodiment of the present disclosure, the code feature data includes at least one of the following: code feature data at file granularity, code feature data at class granularity, code feature data at function granularity, code feature data at configuration granularity, and code feature data at global granularity.
[0169] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0170] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method described above.
[0171] According to an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method described above.
[0172] According to an embodiment of the present disclosure, a computer program product includes a computer program, and when the computer program is executed by a processor, the computer program implements the method described above.
[0173] Figure 5 A block diagram of an electronic device suitable for implementing a test case processing method according to an embodiment of the present disclosure is schematically shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0174] like Figure 5 As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. Various programs and data required for the operation of the electronic device 500 can also be stored in the RAM 503. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0175] Multiple components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a magnetic disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0176] The computing unit 501 can be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as the test case processing method. For example, in some embodiments, the test case processing method can be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the test case processing method described above can be performed. Alternatively, in other embodiments, the computing unit 501 can be configured to perform the test case processing method by any other appropriate means (e.g., by means of firmware).
[0177] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0178] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0179] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0180] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0181] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0182] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.
[0183] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not a limitation herein.
[0184] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.
Claims
1. A test case processing method, comprising: Analyze code feature data corresponding to the code under test to determine a use case data generation strategy for at least one test object corresponding to the code under test, wherein the code feature data is data relied upon for generating test cases; Generate test case data corresponding to the object under test by using a use case data generation strategy corresponding to the object under test; Determining a use case code generation strategy based on the code feature data and the test case data corresponding to the at least one tested object; Generate test case code using the use case code generation strategy; as well as A test case for testing the code under test is generated according to the test case code and the test case data corresponding to the at least one object under test.
2. The method according to claim 1, wherein The generating of test case data corresponding to the object under test by using a use case data generating strategy corresponding to the object under test includes: Determining a parameter value generation strategy corresponding to the measured object according to a use case data generation strategy corresponding to the measured object; determining a target parameter value from at least one predetermined parameter value according to a parameter value generation strategy corresponding to the measured object; and According to the target parameter value, test case data corresponding to the object under test is generated.
3. The method according to claim 1 or 2, further comprising: Evaluating the test case data corresponding to the object under test to obtain at least one evaluation index value; as well as A quality evaluation result of the test case data is determined according to the at least one evaluation index value.
4. The method according to claim 3, further comprising: When it is determined that the quality evaluation result is a failure, the test case data is adjusted according to the at least one evaluation index value so that a new quality evaluation result is a pass.
5. The method according to claim 1 or 2, wherein: The step of generating test case code by using the test case code generation strategy includes: Determining type information corresponding to the code feature data, wherein the type information includes at least one of the following: a programming language type and a business type; Determine a use case code generator and a template code according to the type information; Determining, using the use case code generator, a use case code generation operator based on the code feature data and the test case data corresponding to the at least one tested object; Generate target code using the use case code generation operator; and The test case code is generated according to the target code and the template code.
6. The method according to claim 1 or 2, further comprising: Execute the test case and obtain the test case execution result.
7. The method according to claim 6, further comprising: If the test case execution fails according to the test case execution result, Analyze the execution results of the test case to determine the error type information and the core problem code of the tested code; Performing grammatical analysis on the core problem code and the test case code to obtain grammatical analysis results; as well as Failure reason information is obtained according to the error type information and the syntax analysis result.
8. The method according to claim 7, further comprising: The risk level is determined based on the failure cause information.
9. The method according to claim 8, wherein Determining the risk level according to the failure cause information includes: Determining a key value corresponding to the core problem code; and In the case where it is determined that there is a low risk key value matching the key value in the at least one low risk key value, the risk level is determined to be a low risk level.
10. The method according to claim 9, further comprising: When it is determined that no low-risk key value matching the key value exists in the at least one low-risk key value, and if the core problem code is determined to be an ignorable problem code based on the call relationship chain, the risk level is determined to be a low-risk level.
11. The method according to claim 10, further comprising: If it is determined according to the call relationship chain that the core problem code is a non-ignorable problem code, determining a core problem code vector corresponding to the core problem code; as well as The core problem code vector is processed using a risk assessment model to obtain a risk assessment result indicating that the risk level is a low risk level or a high risk level.
12. The method according to claim 1 or 2, further comprising: The code under test is determined from the currently submitted code according to a selection strategy.
13. The method according to claim 1 or 2, wherein: The code feature data includes at least one of the following: code feature data at file granularity, code feature data at class granularity, code feature data at function granularity, code feature data at configuration granularity, and code feature data at global granularity.
14. A test case processing device, comprising: A first determination module is configured to analyze code feature data corresponding to the code under test and determine a use case data generation strategy for at least one test object corresponding to the code under test, wherein the code feature data is data relied upon for generating test cases; A first generating module, configured to generate test case data corresponding to the object under test by using a use case data generating strategy corresponding to the object under test; A second determining module is configured to determine a use case code generation strategy based on the code feature data and the test case data corresponding to the at least one tested object; A second generating module is used to generate test case code using the use case code generation strategy; as well as The third generating module is used to generate a test case for testing the code under test based on the test case code and the test case data corresponding to the at least one object under test.
15. The device according to claim 14, wherein The first generating module includes: A first determining submodule, configured to determine a parameter value generation strategy corresponding to the measured object according to a use case data generation strategy corresponding to the measured object; a second determining submodule, configured to determine a target parameter value from at least one predetermined parameter value according to a parameter value generation strategy corresponding to the measured object; and The first generating submodule is used to generate test case data corresponding to the object under test according to the target parameter value.
16. The apparatus according to claim 14 or 15, further comprising: An evaluation module, configured to evaluate the test case data corresponding to the tested object to obtain at least one evaluation index value; as well as The third determining module is used to determine the quality evaluation result of the test case data according to the at least one evaluation index value.
17. The apparatus according to claim 16, further comprising: The adjustment module is used to adjust the test case data according to the at least one evaluation index value when it is determined that the quality evaluation result is a failure, so that the new quality evaluation result is a pass.
18. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 13.
19. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 13.
20. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 13.
Citation Information
Patent Citations
Method and device for automatically generating unit test cases
CN103530223A
Unit test method and device
CN108595342A