Method for generating test case and related device
By analyzing the project code, automatically extracting parameters and constraint information, and generating test cases containing semi-structured data, it solves the time-consuming and labor-intensive problem of manually constructing test cases, and improves the generation efficiency and quality of test cases.
Patent Information
- Application Number
- PCT/CN2024/073235
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-15
- Filing Date
- 2024-01-19
- Publication Date
- 2024-12-19
AI Technical Summary
When software developers conduct regression testing, it is time-consuming and labor-intensive to manually construct test cases, especially when processing semi-structured data, the quality of test cases is difficult to guarantee and the maintenance cost is high.
By analyzing the project code, automatically extracting parameter and constraint information, determining parameter values, generating test cases containing semi-structured data, reducing labor costs and improving the generation efficiency of test cases.
It realizes automatic generation of test cases containing semi-structured data, reduces the labor cost of generating test cases, improves the quality and efficiency of test cases, and is suitable for various types of semi-structured data scenarios.
Smart Images

Figure CN2024073235_19122024_PF_FP_ABST
Abstract
Description
A method for generating test cases and related equipment
[0001] This application claims priority to the Chinese patent application with application number 202310705628.0 filed on June 14, 2023, and invention name “A method for generating test cases and related equipment”, as well as priority to the Chinese patent application with application number 202311200156.X filed on September 15, 2023, and invention name “A method for generating test cases and related equipment”, all of which are incorporated by reference into this application. Technical Field
[0002] Embodiments of the present application relate to the field of computers, and more specifically, to a method for generating test cases, a computing apparatus, a computing device cluster, a computer program product, and a computer-readable storage medium. Background Art
[0003] In the field of software engineering, software developers usually need to test project code to determine whether the project code can run normally. Usually, software developers need to manually construct test cases for testing. In the regression testing scenario, if the business code under test is modified, the software developer needs to modify the test data that the test depends on to ensure that the test proceeds smoothly. However, the work required to manually construct test cases is time-consuming and labor-intensive, and the maintenance cost is high. In addition, for semi-structured data, since semi-structured data can contain structured elements and the structure can be flexibly adjusted through key values, the overall structure is not fixed, which results in the test cases containing semi-structured data manually constructed by developers being relatively simple, and the test quality is usually difficult to guarantee.
[0004] Therefore, how to automatically generate test cases containing semi-structured data becomes an urgent problem to be solved.
[0005] Summary of the Invention
[0006] The present application provides a method for generating test cases, a computing device, a computing device cluster, a computer program product, and a computer-readable storage medium, which can automatically generate test cases containing semi-structured data, thereby reducing the labor cost of generating test cases.
[0007] In a first aspect, a method for generating test cases is provided. The method includes: obtaining project code, the project code including at least one code file for generating a test case, each code file including at least one code block for generating the test case, each code block including one or more code statements; analyzing the project code to determine a parameter set and a constraint information set for the project code, the parameter set including at least one parameter, the data corresponding to each parameter being semi-structured data, the constraint information set including at least one constraint information, each constraint information being used to constrain the values of one or more parameters and / or constrain the execution logic of the project code; determining at least one value for each parameter in the parameter set based on the parameter set and the constraint information set; and generating at least one test case based on the project code and the at least one value for each parameter, each test case being used to test the project code.
[0008] In an embodiment of the present application, the project code can be analyzed to automatically extract the parameters and constraint information included in the project code. Based on each extracted parameter and the corresponding constraint information, the possible values of each parameter are determined, thereby automatically generating at least one test case. Because the data corresponding to each parameter is semi-structured data, a test case containing semi-structured data can be automatically generated, thereby reducing the manual cost of generating test cases.
[0009] In combination with the first aspect, in certain implementations of the first aspect, based on at least one first keyword in the project code, the type of the code block corresponding to each first keyword is determined, and the type of the code block is used to indicate the type of semi-structured data to which the parameters included in the code block belong; based on the type of each code block, the parameter extraction model corresponding to each code block is determined; based on the parameter extraction model corresponding to each code block, at least one parameter included in each code block is determined.
[0010] In an embodiment of the present application, a corresponding parameter extraction model can be determined according to the type of each code block, so that parameters corresponding to different types of semi-structured data can be extracted, which can be applied to various types of business scenarios.
[0011] In combination with the first aspect, in certain implementations of the first aspect, at least one constraint information in the project code is determined based on a constraint information extraction model. The constraint information extraction model is used to determine at least one code statement in the project code that contains constraint information, and extract at least one constraint information from the at least one code statement.
[0012] In an embodiment of the present application, at least one constraint information can be automatically extracted from the project code based on the constraint information extraction model, so that at least one value of each parameter can be automatically determined based on the at least one constraint information, and then a test case containing semi-structured data can be automatically generated.
[0013] In combination with the first aspect, in certain implementations of the first aspect, a first constraint information set is determined from a constraint information set, the first constraint information set including at least one constraint information related to a first parameter, the first parameter being any parameter in the parameter set; determining whether the at least one constraint information included in the first constraint information set is related to at least one second parameter, each second parameter of the at least one second parameter being a parameter in the parameter set different from the first parameter; if the at least one constraint information included in the first constraint information set is related to at least one second parameter, determining at least one value set corresponding to the first parameter and the at least one second parameter based on the second constraint information set and the first constraint information set, each value set including a value of the first parameter and at least one second parameter, and the second constraint information set including at least one constraint information related to the at least one second parameter; if the at least one constraint information included in the first constraint information set is not related to the at least one second parameter, determining at least one value of the first parameter based on the first constraint information set.
[0014] In an embodiment of the present application, when determining the value of each parameter, the constraint information in the constraint information set can be classified, thereby dividing the constraint information set into at least one non-overlapping set, thereby reducing the difficulty of constraint solving and improving the efficiency of constraint solving.
[0015] In combination with the first aspect, in certain implementations of the first aspect, the parameter set also includes hierarchical information of the parameters included in each code block, and the hierarchical information of the parameters included in each code block is used to indicate the hierarchical structure of the parameters included in each code block in the code block.
[0016] In an embodiment of the present application, when extracting parameters of the project code, the hierarchical information of the parameters can be extracted at the same time, thereby facilitating the generation of test inputs containing a hierarchical structure of parameters based on the hierarchical information of the parameters, and further facilitating the generation of test cases.
[0017] In combination with the first aspect, in certain implementations of the first aspect, a data template corresponding to each code block is determined based on the type of each code block and the hierarchical information of the parameters included in each code block, and the type of each code block is used to indicate the type of semi-structured data to which the parameters included in each code block belong; based on at least one value of each parameter included in each code block, each parameter in the data template corresponding to each code block is replaced with a value of each parameter to determine at least one test input; based on each test input and the project code in the at least one test input, at least one test case is generated, and each test input corresponds to a test case.
[0018] In an embodiment of the present application, a corresponding data template can be generated based on the hierarchical information of the parameters, and the values of the parameters can be directly substituted into the data template, so that the test input can be automatically generated, thereby improving the efficiency of automatically generating the test input.
[0019] In combination with the first aspect, in certain implementations of the first aspect, each test case includes a test input, a test sequence, and an expected test result. The expected test result corresponding to each test input is determined based on each test input and the code block corresponding to each test input. The test sequence corresponding to each test input is determined based on each test input and the code block corresponding to each test input. The test sequence corresponding to each test input is used to execute the corresponding code block according to each test input.
[0020] In an embodiment of the present application, a test sequence can be generated and a test result can be predicted based on the project code and the automatically generated test input, that is, at least one test case can be generated, thereby improving the efficiency of generating test cases and reducing the difficulty of generating test cases.
[0021] In combination with the first aspect, in certain implementations of the first aspect, first indication information is obtained, and the first indication information is used to indicate whether the parameter set and / or constraint information set is correct; when the first indication information is used to indicate that the parameter set is incorrect, the parameter set is updated according to the first indication information, and the first indication information is also used to indicate the update of the parameter set; and / or, when the first indication information is used to indicate that the constraint information set is incorrect, the constraint information set is updated according to the first indication information, and the first indication information is also used to indicate the update of the constraint information set.
[0022] In an embodiment of the present application, after determining the parameter set and / or constraint information set, the parameter set and / or constraint information set can be confirmed, and the problematic parameter set and / or constraint information set can be updated according to the indication information, thereby avoiding the generation of erroneous test cases.
[0023] In combination with the first aspect, in certain implementations of the first aspect, the project code is tested according to each test case in at least one test case to obtain a test result, which includes the execution result of each test case, or the test result includes the execution result of each test case and code coverage information.
[0024] In an embodiment of the present application, the project code can be tested directly according to the generated test cases to obtain test results and / or code coverage information.
[0025] In combination with the first aspect, in certain implementations of the first aspect, the semi-structured data includes at least one of the following: JS object notation JSON, extensible markup language XML, another markup language YAML, comma-separated values CSV, hypertext markup language HTML, log files, World Wide Web Ontology Language OWL, Standard Generalized Markup Language SGML, Resource Description Framework RDF, Object Exchange Model OEM data.
[0026] In a second aspect, a device for generating a test case is provided, wherein the device includes a module for implementing the first aspect or any possible implementation of the first aspect.
[0027] In a third aspect, the present application provides a computing device cluster comprising at least one computing device, each computing device comprising a processor and a memory; the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method of the above-mentioned first aspect or any one of the implementation methods of the first aspect.
[0028] In a fourth aspect, the present application provides a computer program product comprising instructions, which, when executed by a computer device cluster, enables the computer device cluster to execute the method of the above-mentioned first aspect or any one of the implementation modes of the first aspect.
[0029] In a fifth aspect, the present application provides a computer-readable storage medium comprising computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method of the above-mentioned first aspect or any one of the implementation methods of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] FIG1 is a schematic structural diagram of a system for generating test cases according to an embodiment of the present application.
[0031] FIG2 is a schematic flowchart of a method for generating a test case according to an embodiment of the present application.
[0032] FIG3 is a schematic diagram of a first graphical interface according to an embodiment of the present application.
[0033] FIG4 is a schematic flowchart of a method for determining at least one parameter according to an embodiment of the present application.
[0034] FIG5 is a schematic diagram of a project code and parameters in the project code according to an embodiment of the present application.
[0035] FIG6 is a schematic flowchart of a method for determining at least one constraint information according to an embodiment of the present application.
[0036] FIG7 is a schematic diagram of a project code and constraint information in the project code according to an embodiment of the present application.
[0037] FIG8 is a schematic flowchart of a method for generating a test case according to another embodiment of the present application.
[0038] FIG9 is a schematic structural diagram of an apparatus for generating test cases according to an embodiment of the present application.
[0039] FIG10 is a schematic structural diagram of a computing device according to an embodiment of the present application.
[0040] FIG11 is a schematic structural diagram of a computing device cluster according to an embodiment of the present application.
[0041] FIG12 is a schematic diagram of a connection between computing devices 1000A and 1000B via a network according to one embodiment of the present application. DETAILED DESCRIPTION
[0042] The technical solution in this application will be described below with reference to the accompanying drawings.
[0043] The embodiments of the present application will present various aspects, embodiments, or features around a system including multiple devices, components, modules, etc. It should be understood and appreciated that each system may include additional devices, components, modules, etc., and / or may not include all of the devices, components, modules, etc. discussed in conjunction with the figures. Furthermore, combinations of these solutions may also be used.
[0044] Additionally, in the embodiments of this application, words such as "exemplary" and "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" in the embodiments of this application should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of the word "exemplary" is intended to present concepts in a concrete manner.
[0045] The business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field will know that with the evolution of technology and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0046] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in yet other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0047] In the embodiments of the present application, "at least one" refers to one or more, and "more" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: including the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0048] The technical solutions in the embodiments of the present application can be applied to various integrated development environments (IDEs), or can be applied to a cloud management platform. The cloud management platform is used to manage the infrastructure that provides cloud services, and the infrastructure includes a computing device cluster, and the computing device cluster includes at least one computing device. Alternatively, the technical solutions in the embodiments of the present application can be applied to a computing device, and the computing device can be, for example, a host, a laptop, a desktop, or a server. The server can be a local server or a cloud server. The technical solutions in the embodiments of the present application can generate test cases for project codes written in various writing languages, for example, test cases can be generated for project codes written in languages such as Java, C, C++, C#, Python, and MATLAB.
[0049] To facilitate understanding of the embodiments of the present application, several terms involved in the present application are first briefly explained.
[0050] 1. Structured data
[0051] Structured data is data organized according to a predefined model, typically in a neat format that can be stored in a relational database. Because structured data follows a consistent schema, it's easy to query and analyze. However, structured data is not easily scalable. For example, if the fields are not fixed, it's difficult to use in a relational database. Examples of structured data include credit card numbers, dates, financial amounts, phone numbers, and addresses.
[0052] 2. Unstructured data
[0053] Unstructured data is data that is difficult to organize according to a predefined model and usually does not have a neat format. Common examples of unstructured data include emails, text documents, web pages, social media posts, videos, audio files, etc.
[0054] 3. Semi-structured data
[0055] Semi-structured data lies between structured and unstructured data. Semi-structured data contains internally structured elements that may not be presented in a structured form (e.g., a table). That is, semi-structured data contains structured elements and can be flexibly restructured using key-value pairs, but the overall structure is not fixed. Semi-structured data typically contains tags or other identifiers to separate data elements. Examples of semi-structured data include JavaScript Object Notation (JSON), Extensible Markup Language (XML), YAML (not a markup language), comma-separated values (CSV), Hypertext Markup Language (HTML), log files, World Wide Web Ontology Language (OWL), Standard Generalized Markup Language (SGML), Resource Description Framework (RDF), and Object Exchange Model (OEM) data. Semi-structured data can contain structured fields, but also allows for flexibility between fields.
[0056] The methods in the embodiments of the present application can be applied to a user's local IDE. That is, a functional plug-in can be provided for the user's local IDE, and this functional plug-in can be used to generate at least one test case for the user's project code according to the methods in the embodiments of the present application. Alternatively, the methods in the embodiments of the present application can be applied to a cloud management platform. That is, a cloud service can be provided to tenants, and this cloud service can be used to generate at least one test case for the tenant's project code according to the methods in the embodiments of the present application.
[0057] FIG1 is a schematic diagram of a system for generating test cases according to an embodiment of the present application. The system 100 for generating test cases in FIG1 includes a computing device 110, which includes an acquisition component 111 and a processing component 112. The computing device 110 can be a standalone computing device. Alternatively, the computing device 110 can be managed by a cloud management platform 120 to provide cloud services to tenants.
[0058] The acquisition component 111 can be used to obtain project code, wherein the project code includes at least one code file for generating a test case, each code file includes at least one code block for generating a test case, and each code block includes one or more code statements.
[0059] The processing component 112 can be used to analyze the project code and determine the parameter set and constraint information set of the project code. The parameter set includes at least one parameter, and the data corresponding to each parameter is semi-structured data. The constraint information set includes at least one constraint information, and each constraint information is used to constrain the values of one or more parameters and / or constrain the execution logic of the project code. The processing component 112 can also determine at least one value of each parameter in the parameter set based on the parameter set and the constraint information set. The processing component 112 can also generate at least one test case based on the project code and at least one value of each parameter. Each test case is used to test the project code.
[0060] In some embodiments, the type of semi-structured data may include at least one of the following: JSON, XML, YAML, CSV, HTML, log file, OWL, SGML, RDF, OEM data, etc.
[0061] In some embodiments, after determining the parameter set and constraint information set of the project code, the acquisition component 111 may provide the parameter set and constraint information set to the user for confirmation. The acquisition component 111 may also obtain first indication information, which is used to indicate whether the parameter set and / or constraint information set is correct. When the first indication information is used to indicate that the parameter set and / or constraint information set is incorrect, the first indication information may also be used to indicate an update of the parameter set and / or constraint information set. The processing component 112 may also generate at least one test case based on the updated parameter set and / or constraint information set.
[0062] In some embodiments, after generating at least one test case, processing component 112 may test the project code according to each of the at least one test case to obtain a test result. The test result may include the execution result of each test case, or the test result may include the execution result of each test case and code coverage information. Processing component 112 may also provide the test result to a user.
[0063] When computing device 110 is managed by cloud management platform 120, cloud management platform 120 can be used to manage the infrastructure that provides cloud services, which can include a computing device cluster. The computing device cluster includes at least one computing device, such as computing device 110. When the computing device cluster includes multiple computing devices, the multiple computing devices in the computing device cluster can be directly connected or connected via a network. The network can be, for example, a local area network or a wide area network. Each computing device in the computing device cluster can independently execute the method in the embodiments of the present application, or multiple computing devices in the computing device cluster can jointly execute the method in the embodiments of the present application.
[0064] The cloud management platform 120 can receive request information from a tenant, where the request information is used to request the generation of at least one test case for the tenant's project code, and each test case is used to test the project code. A tenant is a tenant of a public cloud that has registered a public cloud account and purchased public cloud resources or cloud services. The cloud management platform 120 can also obtain the tenant's project code, thereby generating at least one test case for the project code based on the tenant's request information. Specifically, the cloud management platform 120 can assign a computing task to the computing device 110 for execution. The computing task may include analyzing the project code based on the tenant's request information, determining a parameter set and a constraint information set for the project code, and thereby generating at least one test case.
[0065] The system 100 in FIG1 can analyze the project code, automatically extract the parameters and constraint information included in the project code, and determine the possible values of each parameter based on each extracted parameter and the corresponding constraint information, thereby automatically generating at least one test case. Because the data corresponding to each parameter is semi-structured data, a test case containing the semi-structured data can be automatically generated, thereby reducing the labor cost of generating test cases. At the same time, the system 100 in FIG1 can generate corresponding test cases for different types of semi-structured data, so it does not need to be limited to specific business scenarios, thereby improving the versatility and scalability of the method.
[0066] Figure 2 is a schematic flow chart of a method for generating a test case according to an embodiment of the present application. The method in Figure 2 can be executed by the computing device 110 in Figure 1. The method in Figure 2 includes the following steps.
[0067] S210, obtaining a project code.
[0068] The computing device may obtain project code, which includes at least one code file for generating a test case, each code file including at least one code block for generating a test case, and each code block including one or more code statements.
[0069] Optionally, the computing device may provide a first graphical interface for the user, so that the user can determine at least one code file for generating a test case in the first graphical interface. A possible form of the first graphical interface is shown in FIG3 .
[0070] Figure 3 is a schematic diagram of a first graphical interface provided by an embodiment of the present application. First graphical interface 300 in Figure 3 includes controls 310, 320, 330, and 340. Control 310 is used to display the name of an open code file belonging to a user's Project A. Control 310 may also include a close control, which can be used to close an open code file. Control 320 is used to display the contents of an open code file. Control 330 can be used to display the directories included in the user's Project A. A user can view at least one code file included in Project A by operating control 330. In response to a user's operation on control 330, control 340 may also be displayed in interface 300. Control 340 may include control 341, which can be used to generate test cases. Control 340 may also include controls for creating new, cutting, copying, and pasting. The new control is used to create a new project or a new folder or file within Project A. The cut, copy, paste, etc. controls are used to perform cut, copy, paste, etc. operations on project A or folders or files included in project A. In response to the user's operation on control 341, the computing device can determine at least one code file for which the user is to generate a test case, that is, obtain the project code.
[0071] When a computing device is managed by a cloud management platform, the cloud management platform may receive a tenant's request information and project code, wherein the request information is used to request the generation of at least one test case for the tenant's project code. The tenant's project code may include at least one code file for which a test case is to be generated, each code file including at least one code block for which a test case is to be generated, and each code block including one or more code statements.
[0072] For example, the cloud management platform can provide the tenant with a second graphical interface, allowing the tenant to select or upload the tenant's project code and the request information on the second graphical interface, so that the cloud management platform can generate at least one test case based on the request information and the project code. The embodiments of the present application do not limit the specific form of the second graphical interface.
[0073] S220: Analyze the project code to determine a parameter set and a constraint information set of the project code.
[0074] The parameter set of the project code includes at least one parameter in the project code, and the data corresponding to each parameter in the at least one parameter is semi-structured data. The constraint information set of the project code includes at least one constraint information in the project code, and each constraint information in the at least one constraint information is used to constrain the values of one or more parameters and / or constrain the execution logic of the project code.
[0075] Optionally, the type of semi-structured data includes at least one of the following: JSON, XML, YAML, CSV, HTML, log files, OWL, SGML, RDF, OEM data, etc. The data corresponding to a parameter is semi-structured data if the possible values of the parameter are semi-structured data. For example, if the project code includes the parameter file1, and the possible values of the parameter file1 are data in an XML file, then the data corresponding to the parameter file1 is semi-structured data.
[0076] Alternatively, the computing device may input the project code into a parameter determination model to determine a parameter set for the project code. The parameter determination model is used to extract at least one parameter from the project code.
[0077] In some embodiments, the parameter model may be a model obtained through machine learning training based on a first training data set. The first training data set may include a project code, at least one parameter, and a mapping relationship between the project code and the at least one parameter.
[0078] In some embodiments, before step S220, the computing device may obtain a trained parameter determination model. Alternatively, before step S220, the computing device may obtain a first training data set and train the model based on the first training data set to obtain a trained parameter determination model.
[0079] Optionally, the project code may include at least one code block. The computing device may determine the type of the code block corresponding to each first keyword based on at least one first keyword in the project code. The type of the code block indicates the type of semi-structured data to which the parameters included in the code block belong. The computing device may also determine a parameter extraction model corresponding to each code block based on the type of each code block, and determine at least one parameter included in each code block based on the parameter extraction model corresponding to each code block.
[0080] In some embodiments, the at least one first keyword is a preset keyword. One or more first keywords in the at least one first keyword may be related to an operation or application programming interface (API) for reading semi-structured data. The at least one first keyword may be determined based on the writing language of the project code. For example, assuming that the writing language of the project code is Java, the at least one first keyword may include at least one of the following: parse, JSON, XML, YAML, CSV, HTML, xml, json, yaml, csv, html.
[0081] In some embodiments, the parameter extraction model may include a first program analysis technique. The parameter extraction model may be used to determine at least one code statement in a code block that contains a parameter, and may further extract one or more parameters from each code statement containing a parameter, thereby determining at least one parameter in the code block. The at least one parameter may be related to parsing or operating on semi-structured data.
[0082] In some embodiments, the parameter extraction model may determine, based on at least one second keyword, the code statement in the code block where each second keyword resides, and may also extract one or more parameters from each code statement based on the code statement where each second keyword resides. The at least one second keyword is a preset keyword.
[0083] Optionally, the parameter set may further include hierarchical information between at least one parameter of the project code. The hierarchical information between at least one parameter of the project code is used to indicate the hierarchical structure of at least one parameter in the project code within the project code. Alternatively, the parameter set may further include hierarchical information of parameters included in each code block in the project code, where the hierarchical information of parameters included in each code block is used to indicate the hierarchical structure of the parameters included in each code block within the code block.
[0084] Alternatively, the computing device may input the project code into a constraint information extraction model to determine the constraint information set of the project code. The constraint information extraction model is used to extract at least one constraint information from the project code.
[0085] In some embodiments, the constraint information extraction model may be a model obtained through machine learning training based on a second training data set. The second training data set may include a project code, at least one constraint information, and a mapping relationship between the project code and the at least one constraint information.
[0086] In some embodiments, before step S220, the computing device may obtain a trained constraint information extraction model. Alternatively, before step S220, the computing device may obtain a second training dataset and train the model based on the second training dataset to obtain a trained constraint information extraction model.
[0087] In some embodiments, the constraint information extraction model may include a second program analysis technique. The constraint information extraction model may be used to determine at least one code statement in the project code that contains constraint information, and may also extract one or more constraint information from each code statement that contains constraint information, thereby determining at least one constraint information in the project code.
[0088] In some embodiments, the constraint information extraction model may determine, based on at least one third keyword, a code statement in the project code containing each third keyword. The constraint information extraction model may also determine, based on the code statement containing each third keyword, at least one constraint information in the code statement containing each third keyword. The at least one third keyword may be a preset keyword.
[0089] Optionally, after determining the parameter set and constraint information set of the project code, the computing device may provide the parameter set and constraint information set to the user. The computing device may also obtain first indication information, which is used to indicate whether the parameter set and / or constraint information set is correct.
[0090] When the first indication information indicates that the parameter set is incorrect, the first indication information may also indicate an update of the parameter set. The computing device may also update the parameter set based on the first indication information and generate at least one test case based on the updated parameter set. Updating the parameter set includes at least one of the following: deleting one or more parameters in the parameter set, adding one or more parameters to the parameter set, or modifying one or more parameters in the parameter set.
[0091] When the first indication information indicates that the constraint information set is incorrect, the first indication information may also indicate an update of the constraint information set. The computing device may also update the constraint information set based on the first indication information and generate at least one test case based on the updated constraint information set. Updating the constraint information set includes at least one of the following: deleting one or more constraint information in the constraint information set, adding one or more constraint information to the constraint information set, or modifying one or more constraint information in the constraint information set.
[0092] When the first indication information is used to indicate that the parameter set and the constraint information set are correct, the computing device may execute step S230.
[0093] S230: Determine at least one value of each parameter in the parameter set according to the parameter set and the constraint information set.
[0094] The computing device may determine at least one value of each parameter in the parameter set according to the parameter set and the constraint information set of the project code.
[0095] Alternatively, the computing device may input the parameter set and the constraint information set into a constraint solving model to determine at least one value for each parameter in the parameter set. The constraint solving model is configured to determine at least one value for each parameter in the parameter set based on the constraint information set.
[0096] In some embodiments, the constraint solving model may be a model obtained through machine learning training based on a third training data set. The third training data set may include parameters, parameter constraint information, parameter values, and a mapping relationship between the parameters, parameter constraint information, and values.
[0097] In some embodiments, before step S230, the computing device may obtain a trained constraint solving model. Alternatively, before step S230, the computing device may obtain a third training data set and train the model based on the third training data set to obtain a trained constraint solving model.
[0098] Optionally, the computing device may classify the constraint information in the constraint information set to determine at least one subset. When the constraint information set includes multiple subsets, the multiple subsets do not include the same constraint information. That is, the multiple subsets are disjoint sets. Based on the multiple subsets, the computing device may solve for the parameters involved in each subset, thereby determining at least one value for each parameter involved in each subset, thereby reducing the difficulty of constraint solving and improving the efficiency and effectiveness of constraint solving.
[0099] Optionally, the computing device may determine a first constraint information set from a constraint information set. The first constraint information set includes at least one constraint information item related to a first parameter, where the first parameter is any parameter in a parameter set. The computing device may also determine whether the at least one constraint information item included in the first constraint information set is related to at least one second parameter. Each of the at least one second parameters is a parameter in the parameter set that is different from the first parameter. If the at least one constraint information item included in the first constraint information set is related to the at least one second parameter, the computing device may determine at least one value set corresponding to the first parameter and the at least one second parameter based on the second constraint information set and the first constraint information set. Each value set includes a value for the first parameter and the at least one second parameter. The second constraint information set includes at least one constraint information item related to the at least one second parameter. If the at least one constraint information item included in the first constraint information set is unrelated to the at least one second parameter, the computing device may determine at least one value for the first parameter based on the first constraint information set.
[0100] S240: Generate at least one test case according to the project code and at least one value of each parameter.
[0101] The computing device may generate at least one test case based on the project code and at least one value of each parameter, wherein each test case in the at least one test case is used to test the project code.
[0102] In some embodiments, each of the at least one test case includes a test input, a test sequence corresponding to the test input, and an expected test result. The test input of each test case is determined based on a value of one or more parameters included in a code block. The test sequence is determined based on the code block corresponding to the test input, and the test sequence is used to execute the code in the corresponding code block based on each test input. The expected test result is determined based on the test input and the code block corresponding to the test input.
[0103] Optionally, the computing device may input the project code and at least one value corresponding to each parameter into a first test case generation model to obtain at least one test case. The first test case generation model is configured to generate at least one test case based on the project code and at least one value corresponding to each parameter.
[0104] In some embodiments, the first test case generation model may be a model obtained through machine learning training based on a fourth training dataset. The fourth training dataset may include a project code, at least one value of each parameter, at least one test case, and a mapping relationship between the project code, at least one value of each parameter, and at least one test case.
[0105] In some embodiments, before step S240, the computing device may obtain a trained first test case generation model. Alternatively, before step S240, the computing device may obtain a fourth training dataset and train the model based on the fourth training dataset to obtain the trained first test case generation model.
[0106] Optionally, steps S230 and S240 may be combined. That is, the computing device may input the project code, the parameter set of the project code, and the constraint information set into a second test case generation model, thereby obtaining at least one test case. The second test case generation model is configured to generate at least one test case based on the project code, the parameter set of the project code, and the constraint information set.
[0107] In some embodiments, the second test case generation model may be a model obtained through machine learning training based on a fifth training data set. The fifth training data set may include a project code, a parameter set, a constraint information set, and a mapping relationship between the project code, the parameter set, and the constraint information set.
[0108] In some embodiments, before step S230, the computing device may obtain a trained second test case generation model. Alternatively, before step S230, the computing device may obtain a fifth training dataset and train the model based on the fifth training dataset to obtain a trained second test case generation model.
[0109] Optionally, after generating at least one test case, the computing device may also test the project code according to each of the at least one test case to obtain a test result. The test result includes the execution result of each test case. Alternatively, the test result includes the execution result of each test case and code coverage information. The code coverage information is used to indicate the extent to which each test case covers the corresponding code block. The computing device may also provide the test results to a user.
[0110] In some embodiments, the computing device may provide a third graphical interface to the user, allowing the user to select or upload second instruction information on the third graphical interface. The second instruction information is used to instruct the project code to be tested according to at least one test case. The computing device may test the project code using the at least one test case based on the second instruction information, obtain test results, and provide the test results to the user. The embodiments of the present application do not limit the specific form of the third graphical interface.
[0111] In an embodiment of the present application, the computing device can analyze the project code, automatically extract the parameters and constraint information included in the project code, and determine the possible values of each parameter based on each extracted parameter and the corresponding constraint information, thereby automatically generating at least one test case. Since the data corresponding to each parameter is semi-structured data, a test case containing semi-structured data can be automatically generated, thereby reducing the labor cost of generating test cases. At the same time, for different types of semi-structured data, the computing device can generate corresponding test cases, so there is no need to be limited to specific business scenarios, which improves the versatility and scalability of the method for generating test cases.
[0112] FIG4 is a schematic flow chart of a method for determining at least one parameter provided by an embodiment of the present application. The method in FIG4 can be executed by computing device 110 in FIG1 . The method in FIG4 is a possible implementation of step S220. The method in FIG4 includes the following steps.
[0113] S410: Determine, based on at least one first keyword in the project code, the type of the code block corresponding to each first keyword.
[0114] The project code may include at least one code block for the test case to be generated. Each code block includes at least one code statement. Each code block can be executed as a unit. For example, a code block may include a function definition, a function call, or a loop statement.
[0115] For example, assume that the project code includes a code file, and the code file is shown in Figure 5. Figure 5 is a schematic diagram of the project code 500 provided in an embodiment of the present application. The project code in Figure 5 may include a code block 510 and a code block 520, and the writing language of the project code in Figure 5 is Java. Among them, code block 510 is used to call a function, the name of the function is elementRoot, and the function is used to parse a file in XML format named "data". Code block 520 is used to define the function of elementRoot.
[0116] The computing device may determine the type of the code block corresponding to each first keyword based on at least one first keyword, wherein the type of the code block is used to indicate the type of semi-structured data to which the parameters included in the code block belong.
[0117] Optionally, the type of the semi-structured data includes at least one of the following: JSON, XML, YAML, CSV, HTML, log files, OWL, SGML, RDF, OEM data, etc. In other words, the type of the code block includes at least one of the following: JSON, XML, YAML, CSV, HTML, log files, OWL, SGML, RDF, OEM data, etc.
[0118] Optionally, the at least one first keyword is a preset keyword. One or more of the at least one first keyword may be related to an operation or API for reading semi-structured data. The at least one first keyword may be determined based on the language in which the project code is written. For example, assuming that the project code is written in Java, the at least one first keyword may include at least one of the following: parse, JSON, XML, YAML, CSV, HTML, xml, json, yaml, csv, html.
[0119] Alternatively, the computing device may input the project code and at least one first keyword into a type determination model to determine the type of each code block in the project code. The type determination model is used to determine the type of each code block in the project code.
[0120] In some embodiments, the type determination model may be a model obtained through machine learning training based on a sixth training data set. The sixth training data set may include multiple code blocks, at least one first keyword, types of the code blocks, and mapping relationships between the multiple code blocks, the at least one first keyword, and the types of the code blocks.
[0121] In some embodiments, before step S410, the computing device may obtain a trained type determination model. Alternatively, before step S410, the computing device may obtain a sixth training data set and train the model based on the sixth training data set to obtain a trained type determination model.
[0122] Alternatively, the computing device may determine the location of one or more first keywords in the project code and, based on the location of each first keyword in the project code, determine the code blocks associated with the one or more first keywords. The computing device may also determine the type of each code block based on the first keyword corresponding to each code block.
[0123] For example, assuming the project code is as shown in FIG5 , and assuming the first keyword includes xml, the computing device may determine that the first keyword xml is located on line 1 of code block 510. The computing device may also determine, based on the first line of code block 510 containing the first keyword xml, that code block 520 is related to the first keyword xml. The computing device may also determine, based on the first keyword xml, that the types of code blocks 510 and 520 are XML.
[0124] S420: Determine a parameter extraction model corresponding to each code block according to the type of each code block.
[0125] The computing device may determine a parameter extraction model corresponding to each code block according to the type of each code block. The parameter extraction model is used to extract at least one parameter included in the code block.
[0126] Optionally, the parameter extraction model may include a first program analysis technique. The first program analysis technique may include a first static analysis technique and / or a first dynamic analysis technique. The first static analysis technique may extract parameters from a code block by analyzing the syntax, logic, data structure, etc. in the code block. For example, parameters from a code block may be extracted by analyzing the function definition, function call, function return value, assignment statements, judgment statements, and semantic trees corresponding to the code block, etc., included in each code block. The first dynamic analysis technique may extract parameters from the code block by running the code in the code block and monitoring the data flow, control flow, and other information during the code block execution in real time, analyzing the specific process of parsing semi-structured data in the code block. The control flow information includes the execution order of control flow statements in the code block, and the control flow statements may include conditional statements and / or loop statements. The data flow information includes the input and output operations of data in the code block and the flow of data within the code block.
[0127] In some embodiments, the parameter extraction model may be a model obtained through machine learning training based on a seventh training data set. The seventh training data set may include multiple code blocks, at least one parameter included in each code block, and a mapping relationship between the multiple code blocks and the at least one parameter included in each code block.
[0128] Optionally, the parameter extraction models corresponding to different types of code blocks may be the same or different. Different parameter extraction models may include different first program analysis techniques. These different first program analysis techniques may be used to analyze different functions, thereby extracting parameters from different types of code blocks. That is, different types of code blocks may include different functions, and therefore different parameter extraction models may be used to analyze different functions, thereby extracting at least one parameter from the code blocks.
[0129] In some embodiments, the parameter extraction model can determine the code statement where each second keyword is located based on at least one second keyword, and extract one or more parameters from each code statement containing the second keyword, thereby determining at least one parameter in the code block. The at least one second keyword is a preset keyword. One or more second keywords in the at least one second keyword can be related to at least one of the following operations: reading data, initializing data, assigning values to data, judging whether data meets conditions, etc. The at least one second keyword can be determined based on the writing language of the project code. For example, assuming that the writing language of the project code is Java, the at least one second keyword may include at least one of the following: get, equals, "", =, >, <, etc. The at least one second keyword in different parameter extraction models may be the same or different, and the embodiments of the present application are not limited to this.
[0130] Optionally, the computing device may determine a first mapping relationship, where the first mapping relationship is used to indicate parameter extraction models corresponding to different types of semi-structured data. The first mapping relationship may be expressed in the form of a table, an array, a function, a matrix, or the like.
[0131] For example, assume that the first mapping relationship is as shown in Table 1.
[0132] Table 1 First mapping relationship table
[0133] As shown in Table 1, when the type of semi-structured data is XML, the corresponding parameter extraction model is the XML parameter extraction model. When the type of semi-structured data is HTML, the corresponding parameter extraction model is the HTML parameter extraction model.
[0134] Optionally, after determining the type of each code block, the computing device may determine a parameter extraction model corresponding to each code block based on the first mapping relationship. For example, assuming the project code is as shown in FIG5 , since code block 510 and code block 520 are both of XML type, the parameter extraction models corresponding to code block 510 and code block 520 are both XML parameter extraction models.
[0135] S430 : Determine at least one parameter included in each code block according to a parameter extraction model corresponding to each code block.
[0136] Optionally, the computing device may input each code block into a parameter extraction model corresponding to each code block, thereby obtaining an output of the parameter extraction model, namely, obtaining at least one parameter included in each code block. The parameter extraction model may be used to determine at least one code statement in the code block that contains a parameter, and may also extract one or more parameters from each code statement containing a parameter, thereby determining at least one parameter included in each code block.
[0137] For example, assume that the project code is as shown in Figure 5, and assume that the parameter extraction model corresponding to code block 520 is an XML parameter extraction model. The computing device can determine at least one code statement containing a parameter based on the XML parameter extraction model, that is, the computing device can determine that the 3rd, 4th, and 5th lines of code statements in the code block 520 contain parameters. The computing device can also analyze the 3rd, 4th, and 5th lines of code statements in the code block 520 based on the XML parameter extraction model, thereby determining that the 3rd, 4th, and 5th lines of code statements in the code block 520 respectively contain a parameter. The computing device can also name the parameters in the 3rd, 4th, and 5th lines of code block 520 as field1, field2, and field3, respectively, based on the XML parameter extraction model. Among them, parameter field1 is used to indicate a data category called "item". Parameter field2 is used to indicate a data category called "id". Parameter field3 is used to indicate a possible value under the data category indicated by parameter field2.
[0138] In some embodiments, before step S430, the computing device may obtain a trained parameter extraction model. Alternatively, before step S430, the computing device may obtain a seventh training data set and train the model based on the seventh training data set to obtain a trained parameter extraction model.
[0139] Optionally, the computing device may also determine hierarchical information of the parameters included in each code block while determining at least one parameter of each code block. The hierarchical information of the parameters included in each code block is used to indicate the hierarchical structure of the parameters included in each code block within the code block. The hierarchical structure of the parameters included in each code block within the code block is determined based on the hierarchical structure of the code block.
[0140] For example, the computing device may determine that code block 520 in FIG5 includes parameters field1, field2, and field3, and at the same time, determine the hierarchical information of the three parameters in code block 520. The computing device may determine the hierarchical structure of the three parameters based on the hierarchical structure of code block 520. The hierarchical structure of the three parameters is as follows: parameter field1 is the outermost parameter, parameter field2 is located between parameter field1 and parameter field3, and parameter field3 is the innermost parameter.
[0141] In some embodiments, the computing device can determine the data template corresponding to each code block based on the type of each code block and the hierarchical information of the parameters included in each code block. Specifically, the computing device can determine the corresponding representation method for each code block based on the type of each code block, and the representation method corresponding to each code block is used to indicate the specific method for representing the hierarchical information of the parameters included in each code block. When the type of the code block includes at least one of the following: JSON, XML, YAML, CSV, HTML, log file, OWL, SGML, RDF, OEM data, etc., the representation method corresponding to the code block includes at least one of the following: JSON, XML, YAML, CSV, HTML, log file, OWL, SGML, RDF, OEM data, etc. The computing device can also represent the hierarchical information of the parameters included in each code block through the representation method corresponding to each code block, thereby generating a data template corresponding to each code block.
[0142] For example, since the type of code block 520 is XML, the computing device can determine that the representation method corresponding to code block 520 is XML. The computing device can use XML to represent the hierarchical information of the three parameters in code block 520, thereby generating the following data template:
[0143] Among them, <>,, <input> and are preset representations in XML. The XML representation refers to a representation of hierarchical information of parameters included in a code block in accordance with the XML writing language. The data templates determined according to different representations may be different.
[0144] Optionally, while determining at least one parameter in the code block, the computing device may also determine information related to the parameter in the code block. The parameter-related information includes at least one of the following: a key value corresponding to the parameter, a key-value pair corresponding to the parameter, hierarchical information of the parameter, and constraint information corresponding to the parameter. The key value corresponding to the parameter may be, for example, field1, field2, or field3. The key-value pair corresponding to the parameter may be, for example: <field1> 、 <field2> 、 <field3>.
[0145] In an embodiment of the present application, a computing device can determine the type of each code block in the project code based on at least one first keyword, thereby extracting parameters from each code block based on a parameter extraction model that matches the type of the code block, and further determining at least one parameter included in each code block. Because the computing device can determine different parameter extraction models for different types of semi-structured data, it can be more broadly applied to extract parameters of various types of semi-structured data, thereby facilitating the generation of test inputs containing various types of semi-structured data, without being limited to specific business scenarios, thereby improving the versatility and scalability of the method.
[0146] FIG6 is a schematic flowchart of a method for determining at least one constraint information provided by an embodiment of the present application. The method in FIG6 can be executed by computing device 110 in FIG1 . The method in FIG6 is a possible implementation of step S220. The method in FIG6 includes the following steps.
[0147] S610: Determine at least one code statement containing constraint information in the project code according to a constraint information extraction model.
[0148] The computing device may determine at least one code statement in the project code that contains constraint information based on a constraint information extraction model. The constraint information extraction model is used to determine at least one code statement that contains constraint information.
[0149] Optionally, the constraint information extraction model may include a second program analysis technique. This second program analysis technique may include a second static analysis technique and / or a second dynamic analysis technique. The second static analysis technique may analyze the syntax, logic, and data structure of the project code to identify at least one code statement containing constraint information, thereby extracting the at least one constraint information from the project code. For example, the at least one constraint information from the project code may be extracted by analyzing function definitions, function calls, function return values, assignment statements, judgment statements, semantic trees, and the like included in the project code. The second dynamic analysis technique may analyze the execution logic of the project code by running the project code and monitoring data flow, control flow, and other information during the execution of the project code in real time, thereby extracting the at least one constraint information from the project code. The control flow information includes the execution order of control flow statements in the project code, which may include conditional statements and / or loop statements. The data flow information includes the input and output operations of data in the project code and the flow of data within the project code.
[0150] Optionally, the constraint information extraction model can determine the code statement where each third keyword is located in the project code based on at least one third keyword. The at least one third keyword is a preset keyword. One or more third keywords in the at least one third keyword can be related to at least one of the following operations: initializing data, assigning values to data, judging whether data meets conditions, etc. The at least one third keyword can be determined based on the writing language of the project code. For example, assuming that the writing language of the project code is Java, the at least one third keyword can include at least one of the following: if, equals, contains, =, >, <, etc.
[0151] Alternatively, the computing device may directly input the project code into the constraint information extraction model to determine at least one code statement containing constraint information.
[0152] For example, assume that the project code is shown as project code 500 in Figure 7. It should be understood that project code 500 in Figure 5 and project code 500 in Figure 7 are the same project code. The computing device can directly input project code 500 into the constraint information extraction model to determine that the third, fourth, and fifth lines of code in code block 520 of project code 500 contain constraint information.
[0153] S620: Extract at least one constraint information of the project code from the at least one code statement.
[0154] The computing device may extract at least one constraint information from at least one code statement containing constraint information according to the constraint information extraction model.
[0155] Optionally, the constraint information extraction model may include a second program analysis technique that can extract at least one constraint information from at least one code statement containing constraint information. Alternatively, the constraint information extraction model may determine at least one constraint information included in each code statement based on the code statement containing each third keyword.
[0156] For example, the project code may include at least one parameter-independent constraint information, each of which is used to constrain the execution logic of the project code. The computing device may directly extract one or more parameter-independent constraint information from each code statement containing constraint information.
[0157] For example, the project code may include at least one parameter-related constraint information, where each constraint information in the at least one parameter-related constraint information is used to constrain the values of one or more parameters. The computing device may determine the one or more parameter-related constraint information based on each code statement including the constraint information and at least one parameter included in each code statement.
[0158] For example, assume that the third, fourth, and fifth lines of code in code block 520 contain constraint information. The computing device can analyze the third, fourth, and fifth lines of code in code block 520 to determine three constraints in project code 500. These three constraints are: field1 = "item", field2 = "id", and field3 < 0. These three constraints are used to constrain the values of three parameters in code block 520.
[0159] In an embodiment of the present application, the computing device can automatically extract a set of constraint information in the project code, thereby determining at least one possible value for each parameter in the project code without manually defining templates and constraints, thereby reducing the labor cost of testing and increasing the practicality and versatility of the method.
[0160] FIG8 is a schematic flow chart of a method for generating a test case provided by an embodiment of the present application. The method in FIG8 can be executed by the computing device 110 in FIG1 . The method in FIG8 is a possible implementation of steps S230 and S240 . The method in FIG8 includes the following steps.
[0161] S810: Determine at least one subset according to the constraint information set.
[0162] The computing device may classify at least one constraint information included in the constraint information set to determine at least one subset, wherein each subset in the at least one subset is a disjoint set, that is, each subset includes different constraint information.
[0163] Optionally, the computing device may determine a first constraint information set from a constraint information set, wherein the first constraint information set includes at least one constraint information related to a first parameter, where the first parameter is any parameter in the parameter set. A constraint information related to a first parameter means that the constraint information can be used to constrain the value of the first parameter. The computing device may also determine whether at least one constraint information included in the first constraint information set is related to at least one second parameter, where each second parameter in the at least one second parameter is a parameter in the parameter set that is different from the first parameter. That is, the computing device may determine whether the constraint information in the first constraint information set can also be used to constrain the values of other parameters besides the first parameter.
[0164] When at least one piece of constraint information included in the first constraint information set is related to at least one second parameter, the computing device may determine a second constraint information set. The second constraint information set includes at least one piece of constraint information related to each second parameter. The computing device may also determine a first subset based on the first constraint information set and the second constraint information set. The first subset is any subset of the at least one subset. The first subset includes the first constraint information set and the second constraint information set. That is, the constraint information included in the first constraint information set and the second constraint information set all belongs to the first subset.
[0165] When at least one piece of constraint information included in the first constraint information set is unrelated to at least one second parameter, the computing device may directly determine the first constraint information set as the first subset.
[0166] Alternatively, the computing device may directly input the constraint information set into a constraint information classification model to determine at least one subset. The constraint information classification model is used to determine at least one subset including different constraint information.
[0167] In some embodiments, the constraint information classification model may be a model obtained through machine learning training based on an eighth training data set. The eighth training data set may include at least one constraint information, at least one subset, and a mapping relationship between the at least one constraint information and the at least one subset.
[0168] In some embodiments, before step S810, the computing device may obtain a trained constraint information classification model. Alternatively, before step S810, the computing device may obtain an eighth training data set and train the model based on the eighth training data set to obtain a trained constraint information classification model.
[0169] S820: Solve each subset separately to determine at least one value of each parameter.
[0170] The computing device may solve each subset separately, thereby determining at least one value of a parameter involved in the constraint information in each subset.
[0171] When the first subset includes the first constraint information set and the second constraint information set, the computing device may determine, based on the second constraint information set and the first constraint information set, at least one value set corresponding to the first parameter and the at least one second parameter. Each value set in the at least one value set includes a value of the first parameter and the at least one second parameter, and the values of the first parameter and each second parameter included in each value set satisfy each constraint information in the first constraint information set and the second constraint information set.
[0172] When the first subset includes only the first constraint information set, the computing device may determine at least one value of the first parameter based on the first constraint information set. That is, when the computing device determines that the constraint information in the first constraint information set is only used to constrain the value of the first parameter, the computing device may directly determine at least one value of the first parameter based on the first constraint information set.
[0173] For example, assume that the constraint information set for project code 500 includes three constraints: field1 = "item", field2 = "id", and field3 < 0. The computing device can determine that the parameters constrained by these three constraints are different, that is, the three constraints belong to three different subsets. The computing device can also determine, based on these three constraints, that the value of field1 is item and its type is character, that the value of field2 is id and its type is character, and that the value of field3 can be 0, -1, etc. and its type is numeric.
[0174] Optionally, the constraint information set may further include at least one parameter-independent constraint information, each of which is used to constrain the execution logic of the project code. The computing device may directly determine at least one state corresponding to each constraint information based on the at least one parameter-independent constraint information, thereby ensuring that the generated test cases cover different branch situations of the project code when generating test cases.
[0175] For example, suppose a constraint states that flag1 > flag0, where the data corresponding to flag1 and flag0 is not semi-structured data. That is, flag1 and flag0 are not parameters and are not part of the project code's parameter set. Based on this constraint, the computing device can directly determine the corresponding states as False and True, and set the corresponding states to False and True, respectively, when generating a test case.
[0176] S830 : Determine at least one test input corresponding to each code block according to the data template corresponding to each code block and at least one value of each parameter included in each code block.
[0177] Optionally, the computing device may replace each parameter in the data template corresponding to each code block with a value of the parameter, thereby determining the at least one test input.
[0178] For example, assume that the data template corresponding to code block 520 is as follows:
[0179] Assume that the computing device determines that the value of field1 is item and the type is character, that the value of field2 is id and the type is character, and that the value of field3 can be 0 or -1 and the type is numeric. The computing device can replace each parameter in the data template corresponding to code block 520 with a value of the parameter, thereby obtaining test input 1 and test input 2. Test input 1 is:
[0180] Test input 2 is:
[0181] It should be understood that the above test inputs 1 and 2 are merely exemplary, and the computing device may also determine other test inputs. Alternatively, the computing device may also represent the test inputs in other forms, and the embodiments of the present application do not limit the specific forms.
[0182] Optionally, before step S830, the computing device may determine the data template corresponding to each code block. The manner in which the computing device determines the data template corresponding to each code block can be found in the description of step S430.
[0183] S840: Generate at least one test case according to the project code and at least one test input.
[0184] Each test input of the at least one test input corresponds to a test case, that is, each test input is used to generate a test case.
[0185] Optionally, the computing device may determine a test sequence corresponding to each test input based on each test input and the code block corresponding to each test input. The test sequence corresponding to each test input is used to execute the code in the corresponding code block according to each test input.
[0186] For example, assuming the test input is test input 1, the code block corresponding to test input 1 is code block 520 in Figure 5 or Figure 7. The computing device can determine test sequence 1 corresponding to test input 1, and test sequence 1 is used to execute code block 520 according to test input 1.
[0187] In some embodiments, the computing device can determine the expected test result corresponding to each test input based on each test input and the code block corresponding to each test input. The embodiments of the present application do not limit the specific method for determining the expected test result, for example, it can be determined manually or automatically through program code.
[0188] In an embodiment of the present application, the computing device can automatically determine at least one value for each parameter based on the parameter set and constraint information set of the project code, thereby automatically generating at least one test case. Since the data corresponding to each parameter is semi-structured data, a test case containing semi-structured data can be automatically generated, thereby reducing the labor cost of generating test cases. At the same time, the computing device can generate corresponding test cases for different types of semi-structured data, so there is no need to be limited to specific business scenarios, which improves the versatility and scalability of the method for generating test cases.
[0189] FIG9 is a schematic structural diagram of an apparatus for generating test cases according to an embodiment of the present application. The apparatus 900 for generating test cases in FIG9 includes an acquisition module 910 and a processing module 920. The apparatus 900 for generating test cases in FIG9 can be applied to a computing device, such as the computing device 110 in FIG1 .
[0190] Acquisition module 910 can be used to obtain project code. The project code includes at least one code file for generating a test case, each code file includes at least one code block for generating a test case, and each code block includes one or more code statements. Acquisition module 910 can be used to execute step S210 in Figure 2.
[0191] The processing module 920 can be used to analyze the project code and determine the parameter set and constraint information set of the project code. The processing module 920 can also be used to determine at least one value for each parameter in the parameter set based on the parameter set and the constraint information set. The processing module 920 can also be used to generate at least one test case based on the project code and at least one value for each parameter. The processing module 920 can execute steps S220 to S240 in Figure 2, steps S410 to S430 in Figure 4, steps S610 to S620 in Figure 6, and steps S810 to S840 in Figure 8.
[0192] The acquisition module 910 and the processing module 920 can be implemented by software or hardware. For example, the implementation of the processing module 920 will be described below using the processing module 920 as an example. Similarly, the implementation of the acquisition module 910 can refer to the implementation of the processing module 920.
[0193] As an example of a software functional unit, the processing module 920 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the processing module 920 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Typically, a region may include multiple AZs.
[0194] Similarly, multiple hosts / virtual machines / containers running the code can be distributed within the same VPC or across multiple VPCs. Typically, a VPC is set up within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.
[0195] As an example of a hardware functional unit, processing module 920 may include at least one computing device, such as a server. Alternatively, processing module 920 may be implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0196] The multiple computing devices included in processing module 920 can be distributed in the same region or in different regions. The multiple computing devices included in processing module 920 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in processing module 920 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, GALs, and other computing devices.
[0197] Therefore, the modules of each example described in the embodiments of this application can be implemented with electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0198] It should be noted that: when the device provided in the above embodiment executes the above method, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. For example, the acquisition module 910 can be used to execute any step in the above method, and the processing module 920 can be used to execute any step in the above method. The steps that the acquisition module 910 and the processing module 920 are responsible for implementing can be specified as needed, and all the functions of the above device can be realized by respectively implementing different steps in the above method through the acquisition module 910 and the processing module 920.
[0199] In addition, the device and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation processes are detailed in the method embodiments above and will not be repeated here.
[0200] The method provided in the embodiment of the present application can be performed by a computing device, which can also be referred to as a computer system. It includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a processing unit, a memory and a memory control unit, and the function and structure of the hardware are subsequently described in detail. The operating system is any one or more computer operating systems that implement business processing through a process, for example, a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system or a Windows operating system. The application layer includes applications such as a browser, an address book, a word processing software, and an instant messaging software. Furthermore, optionally, the computer system is a handheld device such as a smart phone, or a terminal device such as a personal computer, and this application is not particularly limited, as long as the method provided in the embodiment of the present application can be used. The execution subject of the method provided in the embodiment of the present application can be a computing device, or a functional module in a computing device that can call a program and execute a program.
[0201] FIG10 is a schematic block diagram of a computing device 1000 provided in an embodiment of the present application. The computing device 1000 may be a server, a computer, or other device with computing capabilities. The computing device 1000 shown in FIG10 includes at least one processor 1010 and a memory 1020.
[0202] It should be understood that this application does not limit the number of processors and memories in the computing device 1000.
[0203] The processor 1010 executes the instructions in the memory 1020 so that the computing device 1000 implements the method provided in this application. Alternatively, the processor 1010 executes the instructions in the memory 1020 so that the computing device 1000 implements the functional modules provided in this application, thereby implementing the method provided in this application.
[0204] Optionally, the computing device 1000 further includes a communication interface 1030. The communication interface 1030 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 1000 and other devices or a communication network.
[0205] Optionally, the computing device 1000 further includes a system bus 1040, wherein the processor 1010, the memory 1020, and the communication interface 1030 are respectively connected to the system bus 1040. The processor 1010 can access the memory 1020 through the system bus 1040. For example, the processor 1010 can read and write data or execute code in the memory 1020 through the system bus 1040. The system bus 1040 is a peripheral component interconnect express (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus 1040 is divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in Figure 10, but it does not mean that there is only one bus or one type of bus.
[0206] In one possible implementation, the processor 1010 is primarily responsible for interpreting computer program instructions (or codes) and processing data in the computer software. The computer program instructions and the data in the computer software may be stored in the memory 1020 or the cache of the processor 1010.
[0207] Optionally, processor 1010 may be an integrated circuit chip with signal processing capabilities. By way of example and not limitation, processor 1010 is a general-purpose processor, a digital signal processor (DSP), an ASIC, an FPGA, or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. A general-purpose processor is a microprocessor, for example. For example, processor 1010 is a central processing unit (CPU).
[0208] Memory 1020 can provide runtime space for processes in computing device 1000. For example, memory 1020 stores computer programs (specifically, program code) used to generate processes. After the computer program is executed by the processor to generate a process, the processor allocates corresponding storage space for the process in memory 1020. Furthermore, the aforementioned storage space further includes a text segment, an initialized data segment, a bit-initialized data segment, a stack segment, a heap segment, and the like. Memory 1020 stores data generated during the execution of the process, such as intermediate data or process data, in the storage space corresponding to the aforementioned process.
[0209] Alternatively, the memory is also referred to as the internal memory. It is used to temporarily store data being processed by the processor 1010, as well as data exchanged with external storage devices such as a hard disk. As long as the computer is running, the processor 1010 will load the data to be processed into the internal memory for processing, and then transmit the result after the calculation is completed.
[0210] By way of example and not limitation, memory 1020 is a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. The non-volatile storage medium may be, for example, a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory is a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus DRAM (DRDRAM). It should be noted that the memory 1020 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0211] The structure of the computing device 1000 listed above is only an example description, and the present application is not limited thereto. The computing device 1000 of the embodiment of the present application includes various hardware in the computer system in the prior art. For example, the computing device 1000 also includes other memories in addition to the memory 1020, such as disk storage, etc. It should be understood by those skilled in the art that the computing device 1000 may also include other devices necessary to achieve normal operation. At the same time, according to specific needs, it should be understood by those skilled in the art that the computing device 1000 may also include hardware devices that implement other additional functions. In addition, it should be understood by those skilled in the art that the computing device 1000 may also include only the devices necessary to implement the embodiment of the present application, and does not necessarily include all the devices shown in Figure 10.
[0212] The present application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device may be a server. In some embodiments, the computing device may also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0213] As shown in Figure 11, the computing device cluster includes at least one computing device 1000. The memory 1020 in one or more computing devices 1000 in the computing device cluster may store the same instructions for executing the above method.
[0214] In some possible implementations, the memory 1020 of one or more computing devices 1000 in the computing device cluster may also store some instructions for executing the above method. In other words, the combination of one or more computing devices 1000 can jointly execute the instructions of the above method.
[0215] It should be noted that the memory 1020 in different computing devices 1000 in the computing device cluster can store different instructions, each for performing part of the functions of the above-mentioned apparatus. In other words, the instructions stored in the memory 1020 in different computing devices 1000 can implement the functions of one or more modules in the above-mentioned apparatus.
[0216] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. The network can be a wide area network (WAN), a local area network (LAN), or the like. FIG12 illustrates one possible implementation. As shown in FIG12 , two computing devices 1000A and 1000B are connected via a network. Specifically, each computing device is connected to the network via a communication interface within the computing device.
[0217] It should be understood that the functionality of the computing device 1000A shown in FIG12 may also be accomplished by multiple computing devices 1000. Similarly, the functionality of the computing device 1000B may also be accomplished by multiple computing devices 1000.
[0218] This embodiment also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on a computing device, it causes the computing device to perform the method provided above, or causes the computing device to implement the functions of the apparatus provided above.
[0219] This embodiment also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be executed on a computing device cluster or stored in any available medium. When executed by a computing device cluster, the computer program product causes the computing device cluster to perform the above-mentioned method or implement the functions of the above-mentioned apparatus.
[0220] This embodiment also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium capable of storing data on a computing device, or a data storage device such as a data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, or a magnetic tape), an optical medium (e.g., a digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state drive). The computer-readable storage medium includes instructions that, when executed on a computing device, cause the computing device to perform the method provided above.
[0221] This embodiment also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium capable of storing data on a computing device, or a data storage device such as a data center that contains one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, or a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive). The computer-readable storage medium includes instructions that, when executed by a computing device cluster, cause the computing device cluster to perform the method provided above.
[0222] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0223] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0224] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0225] The units described as separate components may or may not be physically separate, and 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 these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0226] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0227] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0228] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims. < / field2> < / field1>
Claims
1. A method for generating test cases, It is characterized in that include: Obtaining project code, wherein the project code includes at least one code file for a test case to be generated, each code file includes at least one code block for a test case to be generated, and each code block includes one or more code statements; Analyze the project code to determine a parameter set and a constraint information set of the project code, wherein the parameter set includes at least one parameter, and data corresponding to each parameter is semi-structured data; the constraint information set includes at least one constraint information, and each constraint information is used to constrain the value of one or more parameters and / or constrain the execution logic of the project code; Determining at least one value of each parameter in the parameter set according to the parameter set and the constraint information set; At least one test case is generated according to the project code and at least one value of each parameter, and each test case is used to test the project code.
2. The method according to claim 1, It is characterized in that The analyzing the project code to determine a parameter set and a constraint information set of the project code includes: Determine, according to at least one first keyword in the project code, a type of a code block corresponding to each first keyword, wherein the type of the code block is used to indicate a type of semi-structured data to which a parameter included in the code block belongs; Determine, according to the type of each code block, a parameter extraction model corresponding to each code block; At least one parameter included in each code block is determined according to the parameter extraction model corresponding to each code block.
3. The method according to claim 1 or 2, It is characterized in that The analyzing the project code to determine a parameter set and a constraint information set of the project code includes: At least one constraint information in the project code is determined according to a constraint information extraction model, wherein the constraint information extraction model is used to determine at least one code statement containing constraint information in the project code and extract the at least one constraint information from the at least one code statement.
4. The method according to any one of claims 1 to 3, It is characterized in that Determining, according to the parameter set and the constraint information set, at least one value of each parameter in the parameter set includes: Determine a first constraint information set from the constraint information set, wherein the first constraint information set includes at least one constraint information related to a first parameter, and the first parameter is any parameter in the parameter set; Determining whether at least one piece of constraint information included in the first constraint information set is related to at least one second parameter, each second parameter of the at least one second parameter being a parameter in the parameter set different from the first parameter; If at least one piece of constraint information included in the first constraint information set is related to the at least one second parameter, determining, according to the second constraint information set and the first constraint information set, at least one value set corresponding to the first parameter and the at least one second parameter, each value set including a value of the first parameter and the at least one second parameter, and the second constraint information set including at least one piece of constraint information related to the at least one second parameter; If at least one piece of constraint information included in the first constraint information set is independent of the at least one second parameter, at least one value of the first parameter is determined according to the first constraint information set.
5. The method according to any one of claims 1 to 4, It is characterized in that The parameter set also includes hierarchical information of parameters included in each code block, and the hierarchical information of parameters included in each code block is used to indicate the hierarchical structure of the parameters included in each code block in the code block.
6. The method according to claim 5, It is characterized in that The generating the at least one test case according to the project code and at least one value of each parameter includes: Determining a data template corresponding to each code block according to the type of each code block and the hierarchical information of the parameters included in each code block, wherein the type of each code block is used to indicate the type of semi-structured data to which the parameters included in each code block belong; According to at least one value of each parameter included in each code block, each parameter in the data template corresponding to each code block is replaced with a value of each parameter to determine at least one test input; The at least one test case is generated according to each test input of the at least one test input and the project code, and each test input corresponds to a test case.
7. The method according to claim 6, It is characterized in that Each test case includes a test input, a test sequence, and an expected test result, and generating the at least one test case according to each test input of the at least one test input and the project code includes: Determine the expected test result corresponding to each test input according to each test input and the code block corresponding to each test input; According to each test input and the code block corresponding to each test input, a test sequence corresponding to each test input is determined, and the test sequence corresponding to each test input is used to execute the corresponding code block according to each test input.
8. The method according to any one of claims 1 to 7, It is characterized in that The method further comprises: Obtaining first indication information, where the first indication information is used to indicate whether the parameter set and / or the constraint information set is correct; When the first indication information is used to indicate that the parameter set is incorrect, updating the parameter set according to the first indication information, the first indication information being further used to indicate updating the parameter set; and / or, When the first indication information is used to indicate that the constraint information set is incorrect, the constraint information set is updated according to the first indication information, and the first indication information is further used to indicate that the constraint information set is updated.
9. The method according to any one of claims 1 to 8, It is characterized in that The method further comprises: According to each test case in the at least one test case, the project code is tested to obtain a test result, wherein the test result includes an execution result of each test case, or the test result includes an execution result of each test case and code coverage information.
10. The method according to any one of claims 1 to 9, It is characterized in that The semi-structured data includes at least one of the following: JS object notation JSON, extensible markup language XML, another markup language YAML, comma separated value CSV, hypertext markup language HTML, log file, World Wide Web Ontology Language OWL, standard generalized markup language SGML, resource description framework RDF, object exchange model OEM data.
11. A device for generating test cases, It is characterized in that The device comprises: An acquisition module is used to obtain a project code, wherein the project code includes at least one code file for a test case to be generated, each code file includes at least one code block for a test case to be generated, and each code block includes one or more code statements; A processing module, used to analyze the project code, determine a parameter set and a constraint information set of the project code, wherein the parameter set includes at least one parameter, and the data corresponding to each parameter belongs to semi-structured data; the constraint information set includes at least one constraint information, and each constraint information is used to constrain the value of one or more parameters and / or constrain the execution logic of the project code; The processing module is further used to determine at least one value of each parameter in the parameter set according to the parameter set and the constraint information set; The processing module is further used to generate at least one test case according to the project code and at least one value of each parameter, and each test case is used to test the project code.
12. The device according to claim 11, It is characterized in that The processing module is specifically used for: Determine, according to at least one first keyword in the project code, a type of a code block corresponding to each first keyword, wherein the type of the code block is used to indicate a type of semi-structured data to which a parameter included in the code block belongs; Determine, according to the type of each code block, a parameter extraction model corresponding to each code block; At least one parameter included in each code block is determined according to the parameter extraction model corresponding to each code block.
13. The device according to claim 11 or 12, It is characterized in that The processing module is specifically used to determine at least one constraint information in the project code according to a constraint information extraction model, wherein the constraint information extraction model is used to determine at least one code statement containing constraint information in the project code, and extract the at least one constraint information from the at least one code statement.
14. The device according to any one of claims 11 to 13, It is characterized in that The processing module is specifically used for: Determine a first constraint information set from the constraint information set, wherein the first constraint information set includes at least one constraint information related to a first parameter, and the first parameter is any parameter in the parameter set; Determining whether at least one piece of constraint information included in the first constraint information set is related to at least one second parameter, each second parameter of the at least one second parameter being a parameter in the parameter set different from the first parameter; If at least one piece of constraint information included in the first constraint information set is related to the at least one second parameter, determining, according to the second constraint information set and the first constraint information set, at least one value set corresponding to the first parameter and the at least one second parameter, each value set including a value of the first parameter and the at least one second parameter, and the second constraint information set including at least one piece of constraint information related to the at least one second parameter; If at least one piece of constraint information included in the first constraint information set is independent of the at least one second parameter, at least one value of the first parameter is determined according to the first constraint information set.
15. The device according to any one of claims 11 to 14, It is characterized in that The parameter set also includes hierarchical information of parameters included in each code block, and the hierarchical information of parameters included in each code block is used to indicate the hierarchical structure of the parameters included in each code block in the code block.
16. The device according to claim 15, It is characterized in that The processing module is specifically used for: Determining a data template corresponding to each code block according to the type of each code block and the hierarchical information of the parameters included in each code block, wherein the type of each code block is used to indicate the type of semi-structured data to which the parameters included in each code block belong; According to at least one value of each parameter included in each code block, each parameter in the data template corresponding to each code block is replaced with a value of each parameter to determine at least one test input; The at least one test case is generated according to each test input of the at least one test input and the project code, and each test input corresponds to a test case.
17. The device according to claim 16, It is characterized in that Each test case includes a test input, a test sequence and an expected test result. The processing module is specifically used to: Determine the expected test result corresponding to each test input according to each test input and the code block corresponding to each test input; According to each test input and the code block corresponding to each test input, a test sequence corresponding to each test input is determined, and the test sequence corresponding to each test input is used to execute the corresponding code block according to each test input.
18. The device according to any one of claims 11 to 17, It is characterized in that The acquisition module is further used to obtain first indication information, where the first indication information is used to indicate whether the parameter set and / or the constraint information set is correct; The processing module is further configured to update the parameter set according to the first indication information when the first indication information is used to indicate that the parameter set is incorrect, and the first indication information is further used to indicate updating the parameter set; and / or, The processing module is further used to update the constraint information set according to the first indication information when the first indication information is used to indicate that the constraint information set is incorrect, and the first indication information is also used to indicate updating of the constraint information set.
19. The device according to any one of claims 11 to 18, It is characterized in that The processing module is further used for: According to each test case in the at least one test case, the project code is tested to obtain a test result, wherein the test result includes an execution result of each test case, or the test result includes an execution result of each test case and code coverage information.
20. The device according to any one of claims 11 to 19, It is characterized in that The type of the semi-structured data includes at least one of the following: JS object notation JSON, extensible markup language XML, another markup language YAML, comma separated value CSV, hypertext markup language HTML, log file, World Wide Web Ontology Language OWL, standard generalized markup language SGML, resource description framework RDF, object exchange model OEM data.
21. A computing device cluster, It is characterized in that comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 10.
22. A computer program product comprising instructions, It is characterized in that When the instructions are executed by a computing device cluster, the computing device cluster is caused to perform the method according to any one of claims 1 to 10.
23. A computer-readable storage medium, It is characterized in that The method comprises computer program instructions, and when the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Automatic test case code generation device and method
CN107133174A
A test case design system based on a high-coupling automatic matching technology
CN109656802A
Method and device for generating a combined test case, storage medium and computer equipment
CN109902002A
Method and system for information processing and test care generation
US20120030516A1
Method, apparatus, and storage medium for generating test cases
US20230055523A1
