Test case automatic acquisition method and device, equipment and storage medium

By splitting and building algorithm element matrix to generate test cases in the development stage, the problem of the generation of test cases in the existing technology affecting the timeliness of software testing is solved, and efficient and extensive automatic acquisition of test cases is achieved, which is suitable for iterative updates of software products.

CN120492323APending Publication Date: 2025-08-15SHANGHAI RUIDE HUIZHI TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510466999.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The existing test case generation method needs to be generated after the software product or its components are developed, which affects the timeliness of software testing, and test cases need to be regenerated when the software product is iteratively updated, further affecting the timeliness.

Method used

The target algorithm expressions of software products in the development stage are split into the first type of algorithm elements and the second type of algorithm elements, and the algorithm element matrix is ​​built, and a complete logical combination of algorithm elements is generated, and a test case set is automatically generated. When receiving the request of the specified test object, the corresponding test case set is matched for testing.

Benefits of technology

It improves the timeliness and coverage of software testing, reduces the time to generate test cases during iterative updates, and enhances the scalability and applicability of software testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120492323A_ABST
    Figure CN120492323A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of software testing, and provides an automatic test case obtaining method and device, equipment and a storage medium, and the method comprises the steps: splitting a target algorithm expression of a software product in a development stage into a first type of algorithm elements and a second type of algorithm elements; the first type of algorithm elements comprise variables, constants and / or functions, and the second type of algorithm elements comprise operators; constructing an algorithm element matrix according to the first type of algorithm elements; generating a full-amount algorithm element logic combination according to the algorithm element matrix and the second type of algorithm elements; automatically generating a test case subset corresponding to each algorithm element logic combination; and when a test case acquisition request for a specified test object associated with the target algorithm expression is received, matching a test case subset corresponding to the specified test object so as to test the specified test object. According to the embodiment of the invention, the timeliness of software testing can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of software testing technology, and in particular to a method, apparatus, device, and storage medium for automatically acquiring test cases. Background Art

[0002] A test case is a set of test inputs, execution conditions, and expected results compiled for a specific goal, used to test whether a specific software product meets the expected requirements. The inventors of this application have found that existing test case generation methods usually require that the software product or its components be developed before test cases for the software product or its components can be generated for testing; since generating test cases takes a relatively long time, this method affects the timeliness of software testing. Moreover, in most cases, software products will be iteratively updated regularly or irregularly, and each update requires the regeneration of test case solutions, which will further affect the timeliness of software testing. Summary of the Invention

[0003] The purpose of the embodiments of this specification is to provide a method, apparatus, device and storage medium for automatically acquiring test cases to improve the timeliness of software testing.

[0004] To achieve the above objectives, on the one hand, an embodiment of this specification provides a method for automatically acquiring test cases, including:

[0005] Splitting a target algorithm expression of a software product in a development phase into first-category algorithm elements and second-category algorithm elements; the first-category algorithm elements include variables, constants, and / or functions, and the second-category algorithm elements include operators;

[0006] Constructing an algorithm element matrix according to the first type of algorithm elements;

[0007] generating a full range of algorithm element logical combinations according to the algorithm element matrix and the second type of algorithm elements;

[0008] Automatically generate a set of test cases corresponding to each logical combination of the algorithm elements;

[0009] When a test case acquisition request for a specified test object associated with the target algorithm expression is received, a set of test case examples corresponding to the specified test object is matched for use in testing the specified test object.

[0010] In the test case automatic acquisition method of the embodiment of this specification, the specified test object includes any one of the following:

[0011] a component of the software product corresponding to the target algorithmic expression;

[0012] The component corresponding to the target algorithm expression in the iterative product of the software product.

[0013] In the test case automatic acquisition method of the embodiment of this specification, splitting the target algorithm expression of the software product in the development stage into the first type of algorithm elements and the second type of algorithm elements includes:

[0014] Split the target algorithm expression of the software product in the development stage into multiple algorithm elements based on syntax parsing tools or preset regular expressions;

[0015] Variables, constants, and functions in the plurality of algorithm elements are identified as first-category algorithm elements, and operators in the plurality of algorithm elements are identified as second-category algorithm elements.

[0016] In the test case automatic acquisition method of the embodiment of this specification, constructing an algorithm element matrix based on the first type of algorithm elements includes:

[0017] The first type of algorithm elements are combined into an algorithm element matrix.

[0018] In the test case automatic acquisition method of the embodiment of this specification, constructing an algorithm element matrix based on the first type of algorithm elements includes:

[0019] The first type of algorithm elements and additional algorithm elements are combined into an algorithm element matrix; wherein the additional algorithm elements are influencing factors that have no intersection with the first type of algorithm elements.

[0020] In the test case automatic acquisition method of the embodiment of this specification, generating a full set of algorithm element logical combinations based on the algorithm element matrix and the second type of algorithm elements includes:

[0021] Determining an algorithm element combination set from the algorithm element matrix, wherein the algorithm element combination set is a collection of all algorithm element combinations;

[0022] For each algorithm element combination, determining a corresponding operator combination set from the second type of algorithm elements, the operator combination set being a collection of all algorithm element combinations corresponding to the algorithm element combination;

[0023] For each algorithm element combination, it is logically combined with each algorithm element combination in the corresponding operator combination set, and a full set of algorithm element logical combinations under each algorithm element combination is generated accordingly.

[0024] In the test case automatic acquisition method of the embodiment of this specification, after determining the algorithm element combination set from the algorithm element matrix, the method further includes:

[0025] Delete the algorithm element combination set that does not meet the constraint conditions.

[0026] In the test case automatic acquisition method of the embodiment of this specification, the constraint conditions include:

[0027] The denominator is not zero;

[0028] The function parameters are valid.

[0029] In the test case automatic acquisition method of the embodiment of this specification, matching the test case set corresponding to the specified test object includes:

[0030] Determining an algorithmic expression in the specified test object;

[0031] Determine the most similar logical combination of algorithm elements to the algorithm expression among all logical combinations of algorithm elements;

[0032] The test case set corresponding to the most similar logical combination of algorithm elements is determined as the test case set corresponding to the designated test object.

[0033] On the other hand, the embodiment of this specification also provides a device for automatically acquiring test cases, including:

[0034] A formula splitting module is used to split the target algorithm expression of the software product in the development stage into a first type of algorithm elements and a second type of algorithm elements; the first type of algorithm elements includes variables, constants and / or functions, and the second type of algorithm elements includes operators;

[0035] a matrix construction module, configured to construct an algorithm element matrix according to the first type of algorithm elements;

[0036] A formula generation module, configured to generate a full range of algorithm element logical combinations based on the algorithm element matrix and the second type of algorithm elements;

[0037] A use case generation module, configured to automatically generate a set of test case examples corresponding to each logical combination of the algorithm elements;

[0038] The use case matching module is used to match a set of test case examples corresponding to a specified test object when receiving a test case acquisition request for the specified test object associated with the target algorithm expression, so as to be used for testing the specified test object.

[0039] On the other hand, an embodiment of this specification further provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the computer program executes instructions of the above method when executed by the processor.

[0040] On the other hand, an embodiment of this specification further provides a computer storage medium having a computer program stored thereon, wherein the computer program executes the instructions of the above method when executed by a processor of a computer device.

[0041] On the other hand, an embodiment of this specification further provides a computer program product, which includes a computer program. When the computer program is executed by a processor of a computer device, the computer program executes the instructions of the above method.

[0042] It can be seen from the technical solutions provided by the above embodiments of this specification that the embodiments of this specification can pre-split the algorithm expression of the software product in the development stage into multiple algorithm elements and combine them into an algorithm element matrix, and then use the algorithm element matrix to generate all possible logical combinations of algorithm elements, and automatically generate a test case set corresponding to each logical combination of algorithm elements (i.e., generate test cases related to the algorithm expression in advance before the software product or its iterative product is developed); on this basis, each time a test case acquisition request for a specified test object associated with the algorithm expression is received, a test case set corresponding to the specified test object can be directly matched from multiple test case sets for the test of the specified test object, thereby greatly improving the timeliness of software testing. In addition, since the algorithm element matrix can be used to systematically and comprehensively generate all possible logical combinations of algorithm elements, the embodiments of this specification can also improve the coverage of the generated test cases. Not only that, considering that the algorithm element matrix is easy to expand, the embodiments of this specification can also improve the scalability of software testing application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are only some of the embodiments described in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without inventive work. In the drawings:

[0044] Figure 1 A schematic diagram of an application environment for automatic acquisition of test cases in some embodiments of this specification is shown;

[0045] Figure 2 A flowchart of a method for automatically acquiring test cases in some embodiments of this specification is shown;

[0046] Figure 3 Shown Figure 2 The method shown is a flow chart for splitting a target algorithm expression of a software product in the development phase into first-category algorithm elements and second-category algorithm elements;

[0047] Figure 4 Shown Figure 2 A flowchart of a method for generating a full set of algorithm element logical combinations based on an algorithm element matrix and a second type of algorithm element;

[0048] Figure 5 Shown Figure 2 Another flowchart of the method shown in which a full amount of algorithm element logical combinations is generated based on the algorithm element matrix and the second type of algorithm elements;

[0049] Figure 6 Shown Figure 2 A flowchart of a set of test cases matching a specified test object in the method shown;

[0050] Figure 7 It shows a structural block diagram of a device for automatically acquiring test cases in some embodiments of this specification;

[0051] Figure 8 It shows a structural block diagram of a computer device in some embodiments of this specification.

[0052] [Description of Reference Numerals]

[0053] 10. Client;

[0054] 20. Server;

[0055] 71. Formula splitting module;

[0056] 72. Matrix building blocks;

[0057] 73. Formula generation module;

[0058] 74. Use case generation module;

[0059] 75. Use case matching module;

[0060] 802. Computer equipment;

[0061] 804, processor;

[0062] 806, memory;

[0063] 808, driving mechanism;

[0064] 810, input / output interface;

[0065] 812. Input devices;

[0066] 814. Output device;

[0067] 816. Presentation equipment;

[0068] 818. Graphical User Interface;

[0069] 820, network interface;

[0070] 822, communication link;

[0071] 824. Communication bus. DETAILED DESCRIPTION

[0072] To help those skilled in the art better understand the technical solutions in this specification, the following will provide a clear and complete description of the technical solutions in the embodiments of this specification, in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. All other embodiments derived by those skilled in the art based on the embodiments in this specification without creative effort shall fall within the scope of protection of this specification.

[0073] It should be noted that in the embodiments of this specification, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user and fully authorized by all parties, that is, the acquisition, transmission, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.

[0074] Figure 1 : A schematic diagram of the application environment in some embodiments of the present specification is shown in the figure; the application environment includes a client 10 and a server 20. The server 20 can split the target algorithm expression of the software product in the development stage into a first type of algorithm elements and a second type of algorithm elements; the first type of algorithm elements include variables, constants and / or functions, and the second type of algorithm elements include operators; an algorithm element matrix is constructed based on the first type of algorithm elements; a full set of algorithm element logical combinations is generated based on the algorithm element matrix and the second type of algorithm elements; a set of test case examples corresponding to each of the algorithm element logical combinations is automatically generated; when a test case acquisition request for a specified test object associated with the target algorithm expression is received from the client 10, a set of test case examples corresponding to the specified test object is matched for testing the specified test object; the timeliness of software testing can be improved through the embodiments of the present specification.

[0075] In some embodiments of this specification, the client 10 may be a self-service terminal device, a mobile terminal (i.e., a smartphone), a display, a desktop computer, a tablet computer, a laptop computer, a digital assistant, or a smart wearable device. Among these, smart wearable devices may include smart bracelets, smart watches, smart glasses, or smart helmets. Of course, the client 10 is not limited to the aforementioned electronic devices with a certain physical form; it may also be software running on the aforementioned electronic devices.

[0076] In some embodiments of the present specification, the server 20 may be an electronic device with computing and network interaction functions; or it may be software running in the electronic device and providing business logic for data processing and network interaction.

[0077] In addition, it should be noted that Figure 1 What is shown is only an application environment provided by this specification. In actual application, there may be multiple clients 10 and multiple servers 20, and this specification does not impose any restrictions.

[0078] This specification provides a method for automatically obtaining test cases, which can be applied to the above-mentioned server side. Figure 2 As shown, in some embodiments of this specification, the test case automatic acquisition method may include the following steps:

[0079] Step 201: Split the target algorithm expression of the software product in the development stage into first-category algorithm elements and second-category algorithm elements; the first-category algorithm elements include variables, constants and / or functions, and the second-category algorithm elements include operators.

[0080] Step 202: Construct an algorithm element matrix according to the first type of algorithm elements.

[0081] Step 203: Generate a full set of algorithm element logical combinations based on the algorithm element matrix and the second type of algorithm elements.

[0082] Step 204: Automatically generate a set of test cases corresponding to each logical combination of the algorithm elements.

[0083] Step 205: When a test case acquisition request for a specified test object associated with the target algorithm expression is received, a set of test case examples corresponding to the specified test object is matched for use in testing the specified test object.

[0084] In the embodiment of this specification, the algorithm expression of the software product in the development stage can be split into multiple algorithm elements in advance and combined into an algorithm element matrix, and then the algorithm element matrix is used to generate all possible logical combinations of algorithm elements, and the test case set corresponding to each logical combination of algorithm elements is automatically generated (that is, the test case related to the algorithm expression is generated in advance before the software product or its iterative product is completed); on this basis, each time a test case acquisition request for a specified test object associated with the algorithm expression is received, the test case set corresponding to the specified test object can be directly matched from multiple test case sets for the test of the specified test object, thereby greatly improving the timeliness of software testing. In addition, since the algorithm element matrix can be used to systematically and comprehensively generate all possible logical combinations of algorithm elements, the embodiment of this specification can also improve the coverage of the generated test cases. Not only that, considering that the algorithm element matrix is easy to expand, the embodiment of this specification can also improve the scalability of software testing application scenarios.

[0085] Please note that the automatic acquisition scheme for test cases in the embodiments of this specification can be applied to application scenarios such as business or content recommendation, credit assessment, business forecasting (such as early repayment trial calculation in the financial field). The software products in these application scenarios may involve comprehensive calculations of multiple input parameters (such as weighted sum calculations or more complex calculations), and the iterative updates of software products are likely to involve more or fewer input parameters; therefore, the test cases generated in advance in the embodiments of this specification can most likely be directly applied to the testing of iterative products of software products, that is, when the software product is subsequently iteratively updated regularly or irregularly, there is no need to temporarily generate a test case scheme each time it is updated, but it can be directly matched from the test cases generated in advance, thereby improving the timeliness of software testing.

[0086] In some embodiments of the present specification, a software product in the development stage refers to a software product that has not yet been fully developed; for example, in the process of developing a component of a certain software product, the component has not yet been completed, but the algorithm used by the component has been determined, then the expression of the algorithm can be pre-split into multiple algorithm elements and combined into an algorithm element matrix, and then the algorithm element matrix is used to generate all possible logical combinations of algorithm elements, and a set of test case examples corresponding to each logical combination of algorithm elements is automatically generated; in this way, once the component is completed, it can be directly tested using the matching test case set, thereby saving the time spent on generating test cases after the component is completed, thereby improving the timeliness of software testing.

[0087] Furthermore, the embodiments of this specification can also help to discover possible problems with the algorithm in advance (such as input and output problems, etc.), thereby facilitating timely adjustments during the development process and reducing the error rate.

[0088] refer to Figure 3 As shown, in some embodiments of this specification, splitting the target algorithm expression of a software product in the development stage into first-category algorithm elements and second-category algorithm elements may include the following steps:

[0089] Step 301: Split the target algorithm expression of the software product in the development stage into multiple algorithm elements according to a syntax parsing tool or a preset regular expression.

[0090] In some embodiments of this specification, the target algorithm expression of the software product in the development stage can be parsed according to a syntax parsing tool (such as an abstract syntax tree AST) to obtain the various algorithm elements (such as variables, constants, functions and operators) of the target algorithm expression. It should be noted that in the embodiments of this specification, as algorithm elements, variables, constants and functions all refer to input parameters, that is, variables are input variables, constants are input constants, and functions are functions that serve as input parameters. For example, in an exemplary embodiment of this specification, if the target algorithm expression is the formula f=x×y+sin(z), the following algorithm elements can be split out:

[0091] Variables: x, y, z

[0092] Constant: None

[0093] Operators: ×, +

[0094] Function: sin(z)

[0095] In other embodiments of the present specification, a preset regular expression may also be used to match algorithm elements (such as variables, constants, functions, and operators) from a target algorithm expression of a software product in the development stage.

[0096] Step 302: Identify the variables, constants, and functions in the plurality of algorithm elements as first-category algorithm elements, and identify the operators in the plurality of algorithm elements as second-category algorithm elements.

[0097] For example, taking the above expression f=x×y+sin(z) as an example, the variables (x, y, z) and the function (sin(z)) can be identified as first-class algorithm elements, and the operators "×" and "+" can be identified as second-class algorithm elements.

[0098] In some embodiments of the present specification, constructing an algorithm element matrix according to the first-category algorithm elements may include: combining the first-category algorithm elements into an algorithm element matrix.

[0099] For example, taking the variables (x, y, z) and function (sin(z)) in the first type of algorithm element as an example, in the first type of algorithm element, since in the formula f=x×y+sin(z), the variable z is only contained in sin(z), therefore, the algorithm element matrix can be constructed using the variables x, y and function sin(z). Since the sum of the number of x, y and sin(z) is a prime number, an m×m matrix (i.e., a square matrix) cannot be directly formed; in order to facilitate the formation of the algorithm element matrix, a placeholder with a value of 0 can be added as the element in the mth row and nth column, thereby forming the algorithm element matrix shown below:

[0100]

[0101] In some other embodiments of this specification, constructing an algorithm element matrix based on the first type of algorithm elements may include combining the first type of algorithm elements and additional algorithm elements into an algorithm element matrix; wherein the additional algorithm elements are influencing factors that have no intersection with the first type of algorithm elements. This helps to improve or expand the scope of application of the pre-generated set of test cases.

[0102] For example, taking the above formula f = x × y + sin (z) as an example, this formula may only consider the input parameters x, y, and sin (z) that have a relatively large impact on the output f, in order to take into account the computational cost. However, in reality, the parameters j, k, and r will also have an impact on the output f, but their impact is relatively low and can be ignored. However, the possibility of reconsidering the parameters j, k, and r in the future to further enhance the accuracy of the output f cannot be ruled out. Therefore, the parameters j, k, and r can be used as additional algorithm elements, thereby forming the algorithm element matrix shown below together with the parameters x, y, and sin (z) (the last row in the matrix is a placeholder):

[0103]

[0104] Taking the above formula f=x×y+sin(z) as an example, the second type of algorithm elements may include {×,+}.

[0105] Similarly, in other embodiments of this specification, the second type of algorithm elements may be supplemented as needed. For example, by adding "-" and "÷" to the second type of algorithm element {×, +}, the supplemented second type of algorithm element {×, +, -, ÷} is obtained, thereby further improving or expanding the scope of application of the pre-generated test case set.

[0106] refer to Figure 4 As shown, in some embodiments of this specification, generating a full set of algorithm element logical combinations based on the algorithm element matrix and the second type of algorithm elements may include the following steps:

[0107] Step 401: Determine an algorithm element combination set from the algorithm element matrix, where the algorithm element combination set is a collection of all algorithm element combinations.

[0108] For example, taking the above algorithm element matrix For example, we can get the following algorithm element combination:

[0109] (1) Consider the algorithm element combination of two algorithm elements:

[0110] {x,y}、{x,sin(z)}、{y,sin(z)}

[0111] (2) Consider the algorithm element combination of three algorithm elements:

[0112] {x,y,sin(z)}

[0113] Step 402: For each algorithm element combination, determine a corresponding operator combination set from the second type of algorithm elements, where the operator combination set is a collection of all algorithm element combinations corresponding to the algorithm element combination.

[0114] For example, taking the above-mentioned algorithm element combination of two algorithm elements {x, y}, {x, sin(z)}, {y, sin(z)} as an example, the corresponding operator combination can be {×}, {+}; taking the above-mentioned algorithm element combination of three algorithm elements as an example, the corresponding operator combination can be {×, +}.

[0115] Step 403: For each algorithm element combination, traverse and logically combine it with each algorithm element combination in the corresponding operator combination set, and generate a full set of algorithm element logical combinations under each algorithm element combination.

[0116] For example, taking the above algorithm element combination {x, y} as an example, its corresponding operator combinations include {×} and {+}, then two algorithm element logical combinations f=x+y and f=x×y can be logically combined.

[0117] Taking the above algorithm element combination {x, sin(z)} as an example, its corresponding operator combinations include {×} and {+}, then two algorithm element logical combinations f=x+sin(z) and f=x×sin(z) can be logically combined.

[0118] Taking the above algorithm element combination {y, sin(z)} as an example, its corresponding operator combinations include {×} and {+}, then two algorithm element logical combinations f=y+sin(z) and f=y×sin(z) can be logically combined.

[0119] Taking the above algorithm element combination {x, y, sin(z)} as an example, its corresponding operator combination includes {×, +}, then the four algorithm element logical combinations can be logically combined: f = x+y+sin(z), f = x×y+sin(z), f = x+y×sin(z), f = x×y×sin(z).

[0120] Therefore, f=x+y, f=x×y, f=x+sin(z), f=x×sin(z), f=y+sin(z), f=y×sin(z), f=x+y+sin(z), f=x×y+sin(z), f=x+y×sin(z), f=x×y×sin(z) form the full logical combination of algorithm elements.

[0121] Since the matrix-based idea can systematically and comprehensively generate all possible logical combinations of algorithm elements, the embodiments of this specification can improve the coverage of the generated test cases; moreover, considering that the algorithm element matrix is easy to expand, the embodiments of this specification can also improve the scalability of software testing application scenarios; in addition, when generating all possible logical combinations of algorithm elements based on the matrix idea, parallel processing can also be achieved, which is efficient and intuitive.

[0122] refer to Figure 5 As shown, in some other embodiments of this specification, generating a full set of algorithm element logical combinations based on the algorithm element matrix and the second type of algorithm elements may include the following steps:

[0123] Step 501: Determine an algorithm element combination set from the algorithm element matrix, where the algorithm element combination set is a collection of all algorithm element combinations.

[0124] Step 502: Delete the algorithm element combinations that do not meet the constraint conditions from the algorithm element combination set.

[0125] In the embodiments of this specification, the constraints can be customized as needed. For example, in some embodiments of this specification, the constraints may include but are not limited to the denominator being non-zero and the function parameters being legal (i.e., the function and parameters are both legal inputs).

[0126] Step 503: For each algorithm element combination, determine a corresponding operator combination set from the second type of algorithm elements, where the operator combination set is a collection of all algorithm element combinations corresponding to the algorithm element combination.

[0127] Step 504: For each algorithm element combination, traverse and logically combine it with each algorithm element combination in the corresponding operator combination set, and generate a full set of algorithm element logical combinations under each algorithm element combination.

[0128] and Figure 4 Compared to the embodiment shown in Figure 5 In the embodiment shown, after obtaining the full set of algorithm element combinations, the algorithm element combinations that do not meet the constraint conditions are deleted from the algorithm element combination set; by introducing constraint conditions, some algorithm element combinations that are illogical or do not meet the requirements can be deleted, thereby reducing the computational complexity and storage resource overhead of subsequent processing.

[0129] In some embodiments of this specification, automatically generating a set of test cases corresponding to each logical combination of the algorithm elements may include:

[0130] (1) Automatically generate a set of parameter values corresponding to each parameter according to predefined parameter generation rules.

[0131] The parameter generation rules can be customized according to the properties of the algorithm elements and the test objectives. For example, in some embodiments of this specification, the parameter generation rules may include but are not limited to the following rules:

[0132] Boundary value rules: generate minimum, maximum, 0, 1 and other boundary values of algorithm elements;

[0133] Outlier rules: Generate outlier values of algorithm elements (such as negative numbers, non-numeric values, null values, etc.);

[0134] Random value rules: Generate random values for algorithm elements to cover more test scenarios;

[0135] Conditional rules: Generate use cases based on the conditions of algorithm elements. For example, taking the above f=x+y+sin(z) as an example, you can define that if x>10, generate x=15, y=2, z=3; if y=0, generate x=1, y=0, z=0, and so on.

[0136] Therefore, according to the above parameter generation rules, a parameter value set corresponding to each parameter can be automatically generated.

[0137] (2) For each logical combination of algorithm elements, calculate the Cartesian product of the parameter value sets corresponding to its input parameters, so as to obtain all possible parameter value combinations of the logical combination of the algorithm elements.

[0138] For example, taking the above f = x × y as an example, if the parameter value set corresponding to x is {a1, a2}, and the parameter value set corresponding to y is {b1, b2, b3}, the Cartesian product of {a1, a2} and {b1, b2, b3} can be calculated to obtain the following parameter value combinations: {a1, b1}, {a1, b2}, {a1, b3}, {a2, b1}, {a2, b2}, {a2, b3}.

[0139] Similarly, taking the above f=x+y+sin(z) as an example, if the parameter value set corresponding to x is A, the parameter value set corresponding to y is B, and the parameter value set corresponding to z is C, the Cartesian product of set A, set B, and set C can be calculated.

[0140] (3) For each logical combination of algorithm elements, the corresponding test case template is assigned according to the generated parameter value combination, and a set of test case examples corresponding to the logical combination of algorithm elements is generated.

[0141] For example, taking the above-mentioned f=x×y as an example, if its parameter value combinations are: {a1,b1}, {a1,b2}, {a1,b3}, {a2,b1}, {a2,b2}, {a2,b3}, then these parameter value combinations can be filled into the test case template corresponding to f=x×y respectively, thereby obtaining six test cases corresponding to f=x×y, that is, generating a set of test cases corresponding to f=x×y.

[0142] refer to Figure 6 As shown, in some other embodiments of this specification, matching a set of test cases corresponding to the specified test object may include the following steps:

[0143] Step 601: Determine the algorithm expression in the specified test object.

[0144] In some embodiments of this specification, the designated test object may be a component of a software product corresponding to the target algorithm expression, or a component in an iterative product of a software product corresponding to the target algorithm expression (i.e., a component in an upgraded version of a software product corresponding to the target algorithm expression).

[0145] For example, if the designated test object is a component in a software product, the algorithm expression in the component is f=x+y+sin(z).

[0146] Step 602: Determine the algorithm element logical combination that is most similar to the algorithm expression among all the algorithm element logical combinations.

[0147] In some embodiments of the present specification, by calculating the similarity between the algorithm expression and each algorithm element logical combination in the full set of algorithm element logical combinations, the most similar algorithm element logical combination that matches the algorithm expression can be obtained. For example, if the algorithm expression in the specified test object is f=x+y+sin(z), the algorithm element logical combination f'=x+y+sin(z) can be matched from the full set of algorithm element logical combinations.

[0148] Step 603: Determine the test case set corresponding to the logical combination of the most similar algorithm elements as the test case set corresponding to the designated test object.

[0149] For example, if the algorithm expression in the specified test object is f=x+y+sin(z), and the algorithm element logical combination f'=x+y+sin(z) is matched from the full set of algorithm element logical combinations, then the test case set corresponding to the algorithm element logical combination f'=x+y+sin(z) can be used as the test case set corresponding to f=x+y+sin(z).

[0150] Although the process flows described above include multiple operations occurring in a particular order, it should be understood that these processes may include more or fewer operations, which may be performed sequentially or in parallel (eg, using parallel processors or a multi-threaded environment).

[0151] Corresponding to the above-mentioned test case automatic acquisition method, the embodiment of this specification also provides a test case automatic acquisition device, which can be configured on the above-mentioned server, referring to Figure 7 As shown, in some embodiments of this specification, the test case automatic acquisition device may include:

[0152] A formula splitting module 71 is used to split the target algorithm expression of the software product in the development stage into a first type of algorithm elements and a second type of algorithm elements; the first type of algorithm elements includes variables, constants and / or functions, and the second type of algorithm elements includes operators;

[0153] a matrix construction module 72, configured to construct an algorithm element matrix according to the first type of algorithm elements;

[0154] A formula generating module 73, configured to generate a full range of algorithm element logical combinations based on the algorithm element matrix and the second type of algorithm elements;

[0155] A use case generation module 74 is used to automatically generate a set of test case examples corresponding to each logical combination of the algorithm elements;

[0156] The use case matching module 75 is configured to, upon receiving a test case acquisition request for a specified test object associated with the target algorithm expression, match a set of test case examples corresponding to the specified test object for use in testing the specified test object.

[0157] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0158] The embodiment of this specification also provides a computer device. Figure 8 As shown, in some embodiments of this specification, the computer device 802 may include one or more processors 804, such as one or more central processing units (CPUs) or graphics processing units (GPUs), each of which may implement one or more hardware threads. The computer device 802 may also include any memory 806 for storing any type of information, such as code, settings, data, etc. In one specific embodiment, the computer program on the memory 806 and executable by the processor 804, when executed by the processor 804, may execute the instructions of the automatic test case acquisition method described in any of the above embodiments. For example, and without limitation, the memory 806 may include any one or more combinations of the following: any type of RAM, any type of ROM, a flash memory device, a hard disk, an optical disk, etc. More generally, any memory may use any technology to store information. Furthermore, any memory may provide volatile or non-volatile retention of information. Furthermore, any memory may represent a fixed or removable component of the computer device 802. In one embodiment, when the processor 804 executes the associated instructions stored in any memory or combination of memories, the computer device 802 may perform any operation of the associated instructions. The computer device 802 also includes one or more drive mechanisms 808 for interacting with any storage, such as a hard disk drive mechanism, an optical disk drive mechanism, and the like.

[0159] The computer device 802 may also include an input / output interface 810 (I / O) for receiving various inputs (via input devices 812) and for providing various outputs (via output devices 814). A specific output mechanism may include a presentation device 816 and an associated graphical user interface 818 (GUI). In other embodiments, the input / output interface 810 (I / O), input devices 812, and output devices 814 may not be included, and the computer device 802 may simply be a computer device in a network. The computer device 802 may also include one or more network interfaces 820 for exchanging data with other devices via one or more communication links 822. One or more communication buses 824 couple the components described above together.

[0160] The communication link 822 can be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 822 can include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc., governed by any protocol or combination of protocols.

[0161] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), computer-readable storage media, and computer program products of some embodiments of the present specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processor to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processor generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0162] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processor to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, the instruction device being implemented in the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0163] These computer program instructions can also be loaded onto a computer or other programmable data processor so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0164] In a typical configuration, a computer device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0165] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0166] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computer device. As defined in this specification, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0167] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, the embodiments of this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0168] Embodiments of this specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. Embodiments of this specification may also be practiced in distributed computing environments where tasks are performed by remote processors connected via a communications network. In distributed computing environments, program modules may be located in local and remote computer storage media, including storage devices.

[0169] It should also be understood that in the embodiments of this specification, the term "and / or" is merely a description of the association relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. Furthermore, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.

[0170] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.

[0171] In the description of this specification, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of this specification. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.

[0172] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A method for automatically acquiring test cases, characterized in that: include: Splitting a target algorithm expression of a software product in a development phase into first-category algorithm elements and second-category algorithm elements; the first-category algorithm elements include variables, constants, and / or functions, and the second-category algorithm elements include operators; Constructing an algorithm element matrix according to the first type of algorithm elements; generating a full range of algorithm element logical combinations according to the algorithm element matrix and the second type of algorithm elements; Automatically generate a set of test cases corresponding to each logical combination of the algorithm elements; When a test case acquisition request for a specified test object associated with the target algorithm expression is received, a set of test case examples corresponding to the specified test object is matched for use in testing the specified test object.

2. The test case automatic acquisition method according to claim 1, characterized in that: The specified test object includes any one of the following: a component of the software product corresponding to the target algorithmic expression; The component corresponding to the target algorithm expression in the iterative product of the software product.

3. The test case automatic acquisition method according to claim 1, wherein: The target algorithm expression of the software product in the development stage is split into the first type of algorithm elements and the second type of algorithm elements, including: Split the target algorithm expression of the software product in the development stage into multiple algorithm elements based on the syntax parsing tool or preset regular expression; Variables, constants, and functions in the plurality of algorithm elements are identified as first-category algorithm elements, and operators in the plurality of algorithm elements are identified as second-category algorithm elements.

4. The test case automatic acquisition method according to claim 1, wherein: Constructing an algorithm element matrix based on the first type of algorithm elements, including: The first type of algorithm elements are combined into an algorithm element matrix.

5. The test case automatic acquisition method according to claim 1, wherein: Constructing an algorithm element matrix based on the first type of algorithm elements, including: The first type of algorithm elements and additional algorithm elements are combined into an algorithm element matrix; wherein the additional algorithm elements are influencing factors that have no intersection with the first type of algorithm elements.

6. The test case automatic acquisition method according to claim 1, characterized in that: Generating a full set of algorithm element logical combinations according to the algorithm element matrix and the second type of algorithm elements includes: Determining an algorithm element combination set from the algorithm element matrix, wherein the algorithm element combination set is a collection of all algorithm element combinations; For each algorithm element combination, determining a corresponding operator combination set from the second type of algorithm elements, the operator combination set being a collection of all algorithm element combinations corresponding to the algorithm element combination; For each algorithm element combination, it is logically combined with each algorithm element combination in the corresponding operator combination set, and a full set of algorithm element logical combinations under each algorithm element combination is generated accordingly.

7. The test case automatic acquisition method according to claim 6, characterized in that: After determining the algorithm element combination set from the algorithm element matrix, the method further includes: Delete the algorithm element combination set that does not meet the constraint conditions.

8. The test case automatic acquisition method according to claim 7, characterized in that: The constraints include: The denominator is not zero; The function parameters are valid.

9. The test case automatic acquisition method according to claim 1, wherein: A set of test cases corresponding to the specified test object is matched, including: Determining an algorithmic expression in the specified test object; Determine the most similar logical combination of algorithm elements to the algorithm expression among all logical combinations of algorithm elements; The test case set corresponding to the most similar logical combination of algorithm elements is determined as the test case set corresponding to the designated test object.

10. A device for automatically acquiring test cases, characterized in that: include: A formula splitting module is used to split the target algorithm expression of the software product in the development stage into a first type of algorithm elements and a second type of algorithm elements; the first type of algorithm elements includes variables, constants and / or functions, and the second type of algorithm elements includes operators; a matrix construction module, configured to construct an algorithm element matrix according to the first type of algorithm elements; A formula generation module, configured to generate a full range of algorithm element logical combinations based on the algorithm element matrix and the second type of algorithm elements; A use case generation module, configured to automatically generate a set of test case examples corresponding to each logical combination of the algorithm elements; The use case matching module is used to match a set of test case examples corresponding to a specified test object when receiving a test case acquisition request for the specified test object associated with the target algorithm expression, so as to be used for testing the specified test object.

11. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that: When the computer program is executed by the processor, the computer program executes the instructions of the method according to any one of claims 1 to 9.

12. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor of a computer device, the computer program executes the instructions of the method according to any one of claims 1 to 9.

13. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor of a computer device, the computer program executes instructions of the method according to any one of claims 1 to 9.