Test case generation method and device, equipment and medium

By automatically generating test cases and using the method identification splitting and parsing of view layer code files, the problem of time-consuming and error-prone traditional software testing is solved, and the efficiency and adaptability of software testing are improved.

CN118585448APending Publication Date: 2024-09-03GUANGZHOU FANGZHOU INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410755580.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

Traditional software testing methods rely on manual writing of test cases, which is time-consuming and error-prone. It is difficult to adapt to the rapid iteration development environment and affects software testing and development efficiency.

Method used

By obtaining the view layer code file of the target software, using method identification to split and parse to generate test cases, automatic generation of test cases is realized.

Benefits of technology

It improves the efficiency of software testing, reduces manual errors, and adapts to the needs of a rapidly iterative development environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118585448A
    Figure CN118585448A
Patent Text Reader

Abstract

The invention discloses a test case generation method and device, equipment and a medium, and relates to the technical field of software test.The method comprises the steps that at least one view layer code file of target development software is obtained; a method identifier is recorded in the view layer code file; aiming at each view layer code file, according to the method identifier in the view layer code file, splitting the code in the view layer code file to obtain the code of at least one view layer method; aiming at the code of each view layer method, analyzing the code of the view layer method to obtain method parameter information of the view layer method; according to the method parameter information of the view layer method, generating a test case of the view layer method; and determining the test case of each view layer method as the test case of the target development software. According to the method and the device, automatic generation of the test case is realized, and the software test efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing, and in particular to a method, device, equipment and medium for generating a test case. Background Art

[0002] During the software development process, developers need to test the software to ensure its reliability and stability.

[0003] In traditional software testing methods, technical personnel are mainly relied on to write test cases and test the developed software through the written test cases. This is not only time-consuming and error-prone, but also affects the efficiency of software testing, and then affects the efficiency of software development. It is difficult to adapt to the rapid iteration development environment. Summary of the invention

[0004] The present invention provides a test case generation method, device, equipment and medium to realize automatic generation of test cases and improve software testing efficiency.

[0005] In a first aspect, the present invention provides a method for generating a test case, comprising:

[0006] Obtain at least one view layer code file of the target development software; the view layer code file records a method identifier;

[0007] For each view layer code file, split the code in the view layer code file according to the method identifier in the view layer code file to obtain the code of at least one view layer method;

[0008] For each view layer method code, parse the view layer method code to obtain the method parameter information of the view layer method;

[0009] Generate test cases for view layer methods based on method parameter information of view layer methods;

[0010] Determine the test cases of each view layer method as the test cases of the target development software.

[0011] In a second aspect, the present invention further provides a test case generation device, comprising:

[0012] A code file acquisition module is used to acquire at least one view layer code file of the target development software; the view layer code file records method annotations;

[0013] A code splitting module is used to split the code in each view layer code file according to the method annotations in the view layer code file to obtain the code of at least one view layer method;

[0014] A parameter determination module is used to parse the code of each view layer method to obtain method parameter information of the view layer method;

[0015] A test case generation module is used to generate test cases for view layer methods according to method parameter information of view layer methods;

[0016] The use case determination module is used to determine the test cases of each view layer method as the test cases of the target development software.

[0017] In a third aspect, an embodiment of the present invention further provides an electronic device, including:

[0018] at least one processor; and

[0019] a memory communicatively coupled to at least one processor; wherein

[0020] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that the at least one processor can execute the test case generation method provided by any embodiment of the present invention.

[0021] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement a method for generating a test case according to any embodiment of the present invention when the computer instructions are executed.

[0022] The embodiment of the present invention obtains at least one view layer code file of the target development software; the view layer code file records a method identifier; for each view layer code file, the code in the view layer code file is split according to the method identifier in the view layer code file to obtain the code of at least one view layer method; for each view layer method code, the view layer method code is parsed to obtain the method parameter information of the view layer method; according to the method parameter information of the view layer method, a test case of the view layer method is generated; and the test case of each view layer method is determined as the test case of the target development software. The present invention can automatically split the code in the view layer code file into the codes of multiple view layer methods, and parse the code of each view layer method to obtain the method parameter information of each view layer method, thereby generating a test case for each view layer method, realizing the automatic generation of test cases and improving the test efficiency.

[0023] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0025] Figure 1 is a flow chart of a method for generating a test case according to Embodiment 1 of the present invention;

[0026] Figure 2 is a flow chart of a method for generating a test case according to Embodiment 2 of the present invention;

[0027] Figure 3 is a schematic diagram of the structure of a test case generation device provided according to Embodiment 3 of the present invention;

[0028] Figure 4 The present invention is a schematic diagram of the structure of an electronic device for implementing the test case generation method of the embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0030] It should be noted that the terms "first" and "second" and the like in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0031] In the technical solution of the embodiment of the present invention, the acquisition, storage and application of the view layer code files involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0032] Embodiment 1

[0033] Figure 1 A flowchart of a test case generation method provided in Embodiment 1 of the present invention. This embodiment is applicable to the situation of automatically generating test cases. The method can be executed by a test case generation device. The test case generation device can be implemented in the form of hardware and / or software and specifically configured in an electronic device, such as a server.

[0034] See also Figure 1 The test case generation method shown includes:

[0035] S101. Obtain at least one view layer code file of target development software; a method identifier is recorded in the view layer code file.

[0036] In this embodiment, the target development software may be software in the development process. The target development software may be developed in a multi-layer architecture, which includes but is not limited to a view layer, a service layer, a logic layer, and a data layer; wherein the view layer may be implemented by at least one class; and each class may be composed of at least one method. The view layer code file may be a file that records the code of the class in the view layer; wherein the classes in each view layer code file are different. The method identifier may be used to identify the method in the code file.

[0037] In a specific embodiment, the method identifier can be in the form of a code comment. When developers write view layer code files, they can annotate the corresponding position of each method with a method identifier to identify the method in the view layer code file while avoiding modifying the software code.

[0038] Optionally, before obtaining at least one view layer code file of the target development software, it also includes: obtaining at least one candidate code file of the target development software; for each candidate code file, querying the hierarchy identifier in the code recorded in the candidate code file; and determining the candidate code file with the hierarchy identifier of the view layer as the view layer code file.

[0039] In this embodiment, the candidate code files may include but are not limited to view layer code files, service layer code files, logic layer code files, and data layer code files; wherein the service layer code files may be files that record the codes of classes in the service layer; the logic layer code files may be files that record the codes of classes in the logic layer; and the data layer code files may be files that record the codes of classes in the data layer. The level identifier may be used to identify the level to which the class recorded in the code file belongs, including the level identifier of the view layer, the level identifier of the service layer, the level identifier of the logic layer, and the level identifier of the data layer.

[0040] In a specific embodiment, the level identification can be in the form of code comments. When developers write candidate code files, they can annotate the classes in the candidate code files with the level identification to identify the level to which the classes in the candidate code files belong while avoiding modification of the software code.

[0041] It can be understood that, by adopting the above technical scheme, the hierarchy identifier is queried in the code recorded in the candidate code file; the candidate code file with the hierarchy identifier as the hierarchy identifier of the view layer is determined as the view layer code file. On the basis of ensuring that the code is not modified, the view layer code file can be quickly determined from the candidate code files, thereby improving the efficiency of obtaining the view layer code file.

[0042] S102 . For each view layer code file, split the code in the view layer code file according to the method identifier in the view layer code file to obtain the code of at least one view layer method.

[0043] In this embodiment, the view layer method may be a method recorded in a view layer code file.

[0044] In a specific embodiment, the method identifier may include a method start identifier and a method end identifier; the method start identifier may be used to identify the start line of the method; the method end identifier may be used to identify the end line of the method; the code start line and code end line of each method code recorded in the view layer code file may be annotated with a method start identifier and a method end identifier, respectively. For each view layer code file, the method start identifier and the method end identifier are searched in the code recorded in the view layer code file; according to the searched method start identifier and method end identifier, the code in the view layer code file is split to obtain the code of at least one view layer method.

[0045] Specifically, according to the queried method start identifier and method end identifier, the code in the view layer code file is split to obtain the code of at least one view layer method, including: for each method start identifier, determining the method end identifier that is adjacent to the method start identifier and has a line number greater than the line number of the method start identifier; and determining the code between the method start identifier and the determined method end identifier as the code of the view layer method.

[0046] S103 . Parse the code of each view layer method to obtain method parameter information of the view layer method.

[0047] In this embodiment, the method parameter information may include but is not limited to the view layer method parameters of the view layer method, the calling method parameters of the method called by the view layer method, and the calling order of the called method. Among them, the view layer method parameters may be the parameters of the view layer method, and may include but is not limited to at least one of the request path, request mode, request parameters, field types of request parameters, the number of logical judgments, and the type of logical judgments. The calling method parameters may be the parameters of the called method, for example, the number of logical judgments and the type of logical judgments; the calling order is the order in which the view layer method is called. Among them, the request mode may include but is not limited to the get (data acquisition) type, the post (data submission) type, the put (data update) type, and the delete (data deletion) type. The field type may include but is not limited to the boolean type, the string type, the integer type, the list type, and the enumeration type; the number of logical judgments may refer to the number of logical judgment symbols such as "if", "else", "else if" and "switch" in the code; the type of logical judgment may refer to the type of logical judgment condition associated with the logical judgment symbol.

[0048] Specifically, a certain algorithm is used to parse the code of each view layer method to obtain method parameter information of the view layer method.

[0049] Optionally, the method parameter information of the view layer method includes: view layer method parameters; parsing the code of the view layer method to obtain the method parameter information of the view layer method, including: obtaining at least one view layer method parameter identifier; for each view layer method parameter identifier, querying the method parameters associated with the view layer method parameter identifier in the code of the view layer method; determining each queried method parameter as the view layer method parameter.

[0050] The view layer method parameter may be a parameter of the view layer method itself, and may include but is not limited to at least one of a request path, a request method, a request parameter, and a field type of a request parameter, etc. The view layer method parameter identifier may be used to identify the view layer method parameter.

[0051] Specifically, the view layer method parameter identifier can be in the form of an identifier. For each view layer method parameter identifier, in the code of the view layer method, query the identifier corresponding to the view layer method identifier; for each identifier found, query the method parameter associated with the identifier; determine the queried method parameter as the view layer method parameter. Among them, the method parameter and the identifier can be associated by the developer through a fixed code format. For example, the view layer method parameter identifier is a request path identifier, and the identifier of the request path identifier can be "@:", then the developer can write the request path after "@:" when writing the code file to associate the request path with the request path identifier.

[0052] It can be understood that, by adopting the above technical solution, for each view layer method parameter identifier, the view layer method parameter identifier is queried in the code of the view layer method; then the method parameters associated with the view layer method parameter identifier are queried to obtain the view layer method parameters, thereby improving the efficiency of querying the view layer method parameters.

[0053] S104. Generate a test case for the view layer method according to the method parameter information of the view layer method.

[0054] Specifically, for each logical judgment in the view layer method parameter information, a test case for the logical judgment is generated according to the type of logical judgment corresponding to the logical judgment, and the request path, request method, and request parameters of the view layer method are recorded in the generated test case. For example, if there is a logical judgment to verify whether a user exists, that is, the type of logical judgment is to verify user existence, a test case for user existence is generated; if there is a logical judgment to verify whether the user's account and password are correct, a test case including the correct account and password combination is generated; if there is a logical judgment to determine the user status, a test case corresponding to each user status is generated.

[0055] S105: Determine the test cases of each view layer method as the test cases of the target development software.

[0056] Optionally, after determining the test cases of each view layer method as the test cases of the target development software, it also includes: responding to the deployment completion event of the target development software, testing the deployed target development software according to the test cases of the target development software to obtain test results.

[0057] Among them, the deployment completion event can be used to indicate that the deployment of the target development software is completed. Specifically, in response to the deployment completion event of the target development software, the test case is executed in the deployed target development software to obtain the test result of the test case. It can be understood that by adopting the above technical solution, the deployed target development software can be automatically tested through the automatically generated test cases, thereby improving the testing efficiency of the software.

[0058] The embodiment of the present invention obtains at least one view layer code file of the target development software; the view layer code file records a method identifier; for each view layer code file, the code in the view layer code file is split according to the method identifier in the view layer code file to obtain the code of at least one view layer method; for each view layer method code, the view layer method code is parsed to obtain the method parameter information of the view layer method; according to the method parameter information of the view layer method, a test case of the view layer method is generated; and the test case of each view layer method is determined as the test case of the target development software. The present invention can automatically split the code in the view layer code file into the codes of multiple view layer methods, and parse the code of each view layer method to obtain the method parameter information of each view layer method, thereby generating a test case for each view layer method, realizing the automatic generation of test cases and improving the test efficiency.

[0059] Embodiment 2

[0060] Figure 2 A flowchart of a test case generation method provided in the second embodiment of the present invention is provided. The embodiment of the present invention is optimized and improved on the basis of the technical solutions of the above embodiments.

[0061] Further, "parse the code of the view layer method to obtain the method parameter information of the view layer method" is refined into "in the code of the view layer method, query at least one target calling method associated with the calling method identifier, and determine the calling order of each target calling method; determine each target calling method as the first calling method; for each first calling method, obtain the code of the first calling method; query whether there is a target calling method associated with the calling method identifier in the code of the first calling method, and obtain the query result; if the query result is that the target calling method exists, determine the calling order of the target calling method queried in the code of the first calling method according to the calling order of the first calling method; update the first calling method to the target calling method queried in the first calling method, and return to the step of obtaining the code of the first calling method for each first calling method, until the query result is that the target calling method does not exist in the first calling method, and the target calling method of the view layer method and the calling order of each target calling method are obtained."

[0062] It should be noted that, for the parts not described in detail in the embodiments of the present invention, reference may be made to the descriptions in the aforementioned embodiments.

[0063] See also Figure 2 The test case generation method shown includes:

[0064] S201. Obtain at least one view layer code file of the target development software; a method identifier is recorded in the view layer code file.

[0065] S202: For each view layer code file, split the code in the view layer code file according to the method identifier in the view layer code file to obtain the code of at least one view layer method.

[0066] S203: for each view layer method code, search for at least one target calling method associated with the calling method identifier in the view layer method code, and determine the calling order of each target calling method.

[0067] In this embodiment, the view layer method parameter information may include the calling order of the target calling method called by the view layer method. The calling order may refer to the order in which the target calling method is called. The target calling method may be the called method. The calling method identifier may be in the form of an identifier for identifying the called method.

[0068] Specifically, in the code of the view layer method, the identifier corresponding to the calling method identifier is searched; for each identifier found, the method name associated with the identifier is searched; the method corresponding to the found method name is determined as the target calling method; according to the sequence of the positions of the found method names in the code, the calling order of the target calling methods is determined. Among them, the identifier corresponding to the method name and the calling method identifier can be associated by the developer through a fixed code format.

[0069] S204: Determine each target calling method as the first calling method.

[0070] In this embodiment, each target calling method is determined as the first calling method; for each calling method, the calling order of the first calling method is the calling order of the target calling method corresponding to the first calling method.

[0071] S205. For each first calling method, obtain the code of the first calling method.

[0072] Specifically, a candidate code file having a record of the first calling method is searched; and the code of the first calling method is obtained from the searched candidate code file.

[0073] S206: Query the code of the first calling method to see whether there is a target calling method associated with the calling method identifier, and obtain a query result.

[0074] It should be noted that the process of querying the target calling method in the code of the first calling method is similar to the process of querying the target calling method in the view layer method, which will not be repeated here.

[0075] S207: If the query result shows that the target calling method exists, determine the calling order of the target calling method found in the code of the first calling method according to the calling order of the first calling method.

[0076] Specifically, the auxiliary calling order of each target calling method in the first calling method is determined according to the method name of each target calling method queried in the code of the first calling method and the position in the code of the first calling method; for each target calling method queried in the first calling method, the calling order of the target calling method in the view layer method is determined according to the calling order of the first calling method and the auxiliary calling order of the target calling method in the first calling method. Exemplarily, the calling order of the target calling method in the view layer method is determined as the sum of the calling order of the first calling method and the auxiliary calling order of the target calling method in the first calling method.

[0077] S208. Update the first calling method to the target calling method queried in the first calling method, and return to execute the step of obtaining the code of the first calling method for each first calling method until the query result is that there is no target calling method in the first calling method, and obtain the target calling method of the view layer method and the calling order of each target calling method.

[0078] Specifically, the first calling method is updated to the target calling method queried in the first calling method; for each first calling method, the code of the first calling method is obtained; the code of the first calling method is queried to see whether there is a target calling method associated with the calling method identifier, and the query result is obtained; if the query result is that the target calling method exists, the calling order of the target calling method queried in the code of the first calling method is determined according to the calling order of the first calling method; the first calling method is updated to the target calling method queried in the first calling method, and the step of obtaining the code of the first calling method for each first calling method is returned to execute until the query result is that the target calling method does not exist in the first calling method, and the target calling method of the view layer method and the calling order of each target calling method are obtained.

[0079] Optionally, the method parameter information of the view layer method also includes: the calling method parameters of each target calling method; after obtaining the target calling method of the view layer method and the calling order of each target calling method, it also includes: obtaining at least one calling method parameter identifier; for each target calling method, obtaining the code of the target calling method; for each calling method parameter identifier, querying the calling method parameters associated with the calling method parameter identifier in the code of the target calling method; determining the queried calling method parameters as the calling method parameters of the target calling method.

[0080] The calling method parameter may be a parameter of the target calling method, such as a logic judgment type, a logic judgment type, a logic judgment condition, etc. The calling method parameter identifier may be in the form of an identifier for identifying the calling method parameter; each calling method parameter identifier corresponds to a different calling method parameter.

[0081] It should be noted that the code flow for obtaining the target calling method is similar to the code flow for obtaining the first calling method; the process for querying the calling method parameters is similar to the process for querying the view layer method parameters, which will not be repeated here.

[0082] It can be understood that, by adopting the above technical solution, at least one calling method parameter identifier is obtained; for each target calling method, the code of the target calling method is obtained; for each calling method parameter identifier, the calling method parameters associated with the calling method parameter identifier are queried in the code of the target calling method; the queried calling method parameters are determined as the calling method parameters of the target calling method, thereby improving the efficiency of querying the view layer method parameters.

[0083] S209: Generate a test case for the view layer method according to the method parameter information of the view layer method.

[0084] S210: Determine the test cases of each view layer method as the test cases of the target development software.

[0085] Optionally, the method parameter information of the view layer method includes the request path of the view layer method; after generating parameters according to the test case of the view layer method and generating the test case of the view layer method, it also includes: querying the test case database for historical test cases that match the request path of the view layer method to obtain query results; if the query result is that there are matching historical test cases, replacing the historical test cases with the test cases of the view layer method; if the query result is that there are no matching historical test cases, associating the request path of the view layer method and the test case of the view layer method; storing the associated request path of the view layer method and the test case of the view layer method in the test case database.

[0086] Among them, the test case database can be used to store historical test cases of the target development software. Among them, the generation time of the historical test cases is before the generation time of the test cases of the view layer methods in this embodiment. Specifically, for each view layer method, in the test case database, query the historical test cases that match the request path of the view layer method to obtain the query result; if the query result is that there is a matching historical test case, replace the historical test case with the test case of the view layer method; if the query result is that there is no matching historical test case, associate the request path of the view layer method and the test case of the view layer method; store the associated request path of the view layer method and the test case of the view layer method in the test case database.

[0087] It can be understood that by adopting the above-mentioned technical scheme, when there are historical test cases associated with the view layer method, the historical test cases can be replaced; when there are no historical test cases for the view layer method, the request path of the view layer method and the test cases of the view layer method can be associated and stored, so that when the target development software is tested, the pre-stored test cases can be obtained from the database, thereby improving the efficiency of software testing.

[0088] The embodiment of the present invention searches for at least one target calling method associated with the calling method identifier in the code of the view layer method, and determines the calling order of each target calling method; determines each target calling method as the first calling method; obtains the code of the first calling method for each first calling method; queries whether there is a target calling method associated with the calling method identifier in the code of the first calling method to obtain a query result; if the query result is that the target calling method exists, the calling order of the target calling method found in the code of the first calling method is determined according to the calling order of the first calling method; updates the first calling method to the target calling method found in the first calling method, and returns to execute the step of obtaining the code of the first calling method for each first calling method until the query result is that there is no target calling method in the first calling method, and obtains the target calling method of the view layer method and the calling order of each target calling method, so as to automatically determine the calling order and the target calling method, and further determine the method called by the target calling method by identifying whether the target calling method calls other methods, and when it is determined that other methods are called, the accuracy of determining the target calling method is improved.

[0089] Embodiment 3

[0090] Figure 3A schematic diagram of the structure of a test case generation device provided in Embodiment 3 of the present invention. This embodiment is applicable to the case of automatically generating test cases, the device can execute the test case generation method, the test case generation device can be implemented in the form of hardware and / or software, and the device can be configured in an electronic device, such as a server.

[0091] See also Figure 3 The test case generation device shown in the figure includes a code file acquisition module 301, a code splitting module 302, a parameter determination module 303, a test case generation module 304 and a test case determination module 305, wherein:

[0092] The code file acquisition module 301 is used to acquire at least one view layer code file of the target development software; the view layer code file records method annotations;

[0093] A code splitting module 302 is used to split the code in each view layer code file according to the method annotations in the view layer code file to obtain the code of at least one view layer method;

[0094] The parameter determination module 303 is used to parse the code of each view layer method to obtain method parameter information of the view layer method;

[0095] A test case generation module 304, used to generate a test case for the view layer method according to the method parameter information of the view layer method;

[0096] The use case determination module 305 is used to determine the test cases of each view layer method as the test cases of the target development software.

[0097] The embodiment of the present invention obtains at least one view layer code file of the target development software through a code file acquisition module; the view layer code file records method annotations; through a code splitting module, for each view layer code file, according to the method annotations in the view layer code file, the code in the view layer code file is split to obtain the code of at least one view layer method; through a parameter determination module, for each view layer method code, the code of the view layer method is parsed to obtain the method parameter information of the view layer method; through a case generation module, according to the method parameter information of the view layer method, a test case of the view layer method is generated; through a case determination module, the test case of each view layer method is determined as the test case of the target development software. The present invention can automatically split the code in the view layer code file into multiple view layer method codes, and parse the code of each view layer method to obtain the method parameter information of each view layer method, thereby generating test cases for each view layer method, realizing automatic generation of test cases and improving test efficiency.

[0098] Optionally, the method parameter information of the view layer method includes: view layer method parameters;

[0099] The parameter determination module 303 includes:

[0100] An identifier obtaining unit, used to obtain at least one view layer method parameter identifier;

[0101] A method parameter query unit, for querying, for each view layer method parameter identifier, the method parameter associated with the view layer method parameter identifier in the code of the view layer method;

[0102] The method parameter determination unit is used to determine each queried method parameter as a view layer method parameter.

[0103] Optionally, the view layer method parameter information includes: the calling order of the target calling method called by the view layer method;

[0104] The parameter determination module 303 includes:

[0105] A first query unit, configured to query at least one target calling method associated with a calling method identifier in the code of the view layer method, and determine a calling order of each of the target calling methods;

[0106] A first method determining unit, configured to determine each of the target calling methods as a first calling method;

[0107] A code acquisition unit, configured to acquire, for each first calling method, a code of the first calling method;

[0108] A second query unit is used to query whether there is a target calling method associated with the calling method identifier in the code of the first calling method, and obtain a query result;

[0109] An order determination unit, configured to determine, if the query result indicates that a target calling method exists, a calling order of the target calling method found in the code of the first calling method according to the calling order of the first calling method;

[0110] An updating unit is used to update the first calling method to a target calling method queried in the first calling method, and return to execute the step of obtaining the code of the first calling method for each first calling method until the query result is that there is no target calling method in the first calling method, and obtain the target calling method of the view layer method and the calling order of each target calling method.

[0111] Optionally, the method parameter information of the view layer method also includes: calling method parameters of each target calling method;

[0112] The device further comprises:

[0113] A second identifier acquisition module, used to acquire at least one calling method parameter identifier;

[0114] A code acquisition module is used to acquire the code of a target calling method for each target calling method;

[0115] A method parameter query module is used to query the calling method parameters associated with the calling method parameter identifier in the code of the target calling method for each calling method parameter identifier;

[0116] The method parameter determination module is used to determine the queried calling method parameters as the calling method parameters of the target calling method.

[0117] Optionally, the method parameter information of the view layer method includes the request path of the view layer method;

[0118] The device further comprises:

[0119] The test case query module is used to query the historical test cases matching the request path of the view layer method in the test case database to obtain the query results;

[0120] The test case replacement module is used to replace the historical test case with the test case of the view layer method if the query result shows that there is a matching historical test case;

[0121] The test case association module is used to associate the request path of the view layer method with the test case of the view layer method if the query result shows that there is no matching historical test case;

[0122] The test case storage module is used to store the associated request path of the view layer method and the test case of the view layer method in the test case database.

[0123] Optionally, the device further comprises:

[0124] A candidate file acquisition module, used to acquire at least one candidate code file of the target development software;

[0125] A level identification query module is used to query the level identification in the code recorded in the candidate code file for each candidate code file;

[0126] The view layer file determination module determines the candidate code file with the level identifier of the view layer as the view layer code file.

[0127] Optionally, the device further comprises:

[0128] The software testing module is used to respond to the deployment completion event of the target development software, test the deployed target development software according to the test cases of the target development software, and obtain the test results.

[0129] The test case generation device provided in the embodiment of the present invention can execute the test case generation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the test case generation method.

[0130] Embodiment 4

[0131] Figure 4 A schematic diagram of the structure of an electronic device 400 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0132] like Figure 4 As shown, the electronic device 400 includes at least one processor 401, and a memory connected to the at least one processor 401 in communication, such as a read-only memory (ROM) 402, a random access memory (RAM) 403, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 401 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 402 or the computer program loaded from the storage unit 408 to the random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 can also be stored. The processor 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0133] Multiple components in the electronic device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the electronic device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0134] Processor 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of processor 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. Processor 401 executes the various methods and processes described above, such as a method for generating test cases.

[0135] In some embodiments, the test case generation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 400 via the ROM 402 and / or the communication unit 409. When the computer program is loaded into the RAM 403 and executed by the processor 401, one or more steps of the test case generation method described above may be performed. Alternatively, in other embodiments, the processor 401 may be configured to execute the test case generation method in any other appropriate manner (e.g., by means of firmware).

[0136] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0137] The computer programs for implementing the method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable test case generation device, so that when the computer programs are executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer programs may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0138] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0139] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0140] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0141] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS (Virtual Private Server) services.

[0142] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0143] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for generating a test case, characterized in that: The method comprises: Acquire at least one view layer code file of the target development software; the view layer code file records a method identifier; For each view layer code file, split the code in the view layer code file according to the method identifier in the view layer code file to obtain the code of at least one view layer method; For each view layer method code, parse the view layer method code to obtain method parameter information of the view layer method; Generate a test case for the view layer method according to the method parameter information of the view layer method; The test cases of the view layer methods are determined as the test cases of the target development software.

2. The method according to claim 1, characterized in that The method parameter information of the view layer method includes: view layer method parameters; The code of the view layer method is parsed to obtain method parameter information of the view layer method, including: Get at least one view layer method parameter identifier; For each view layer method parameter identifier, query the method parameter associated with the view layer method parameter identifier in the code of the view layer method; The queried method parameters are determined as view layer method parameters.

3. The method according to claim 1, characterized in that The view layer method parameter information includes: the calling order of the target calling method called by the view layer method; The code of the view layer method is parsed to obtain method parameter information of the view layer method, including: In the code of the view layer method, query at least one target calling method associated with the calling method identifier, and determine the calling order of each of the target calling methods; Determine each of the target calling methods as a first calling method; For each first calling method, obtaining the code of the first calling method; Querying the code of the first calling method to determine whether there is a target calling method associated with the calling method identifier, and obtaining a query result; If the query result is that the target calling method exists, determining the calling order of the target calling method found in the code of the first calling method according to the calling order of the first calling method; Update the first calling method to the target calling method queried in the first calling method, and return to execute the step of obtaining the code of the first calling method for each first calling method until the query result is that there is no target calling method in the first calling method, and obtain the target calling method of the view layer method and the calling order of each target calling method.

4. The method according to claim 3, characterized in that The method parameter information of the view layer method also includes: the calling method parameters of each target calling method; After obtaining the target calling method of the view layer method and the calling order of each target calling method, it also includes: Get at least one calling method parameter identifier; For each target calling method, obtaining the code of the target calling method; For each calling method parameter identifier, searching for a calling method parameter associated with the calling method parameter identifier in the code of the target calling method; The queried calling method parameters are determined as the calling method parameters of the target calling method.

5. The method according to claim 1, characterized in that The method parameter information of the view layer method includes the request path of the view layer method; After generating the test case of the view layer method according to the test case generation parameters of the view layer method, the method further includes: In the test case database, query the historical test cases that match the request path of the view layer method to obtain the query result; If the query result shows that there is a matching historical test case, the historical test case is replaced with the test case of the view layer method; If the query result is that there is no matching historical test case, then associating the request path of the view layer method with the test case of the view layer method; The associated request path of the view layer method and the test case of the view layer method are stored in the test case database.

6. The method according to claim 1, characterized in that Before obtaining at least one view layer code file of the target development software, the method further includes: Obtaining at least one candidate code file of the target development software; For each candidate code file, query the code recorded in the candidate code file for a level identifier; The candidate code file with the hierarchy identifier being the view layer is determined as the view layer code file.

7. The method according to claim 1, characterized in that After determining the test cases of each of the view layer methods as the test cases of the target development software, the method further includes: In response to the deployment completion event of the target development software, the deployed target development software is tested according to the test case of the target development software to obtain a test result.

8. A test case generation device, characterized in that: The device comprises: A code file acquisition module, used to acquire at least one view layer code file of the target development software; the view layer code file records method annotations; A code splitting module, for splitting the code in each view layer code file according to the method annotations in the view layer code file, to obtain the code of at least one view layer method; A parameter determination module, used for parsing the code of each view layer method to obtain method parameter information of the view layer method; A test case generation module, used to generate a test case for the view layer method according to the method parameter information of the view layer method; The use case determination module is used to determine the test cases of each of the view layer methods as the test cases of the target development software.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the test case generation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the test case generation method according to any one of claims 1 to 7 when executed.