Test case generation method, device, electronic device and storage medium

By filtering and generating a collection of target test cases, the problems of low efficiency and insufficient accuracy of test case generation in the prior art are solved, and more efficient and accurate test results are achieved.

CN115185807BActive Publication Date: 2025-08-29CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110374398.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-07
Publication Date
2025-08-29
Estimated Expiration
2041-04-07

AI Technical Summary

Technical Problem

In the prior art, the generation of test cases is inefficient and insufficiently accurate, making it difficult to effectively identify potential defects in software products.

Method used

By obtaining the first test case set, filter out the target expected result set and the target key input parameter set, form the second test case set, ensure that it contains all the target key input parameter subsets, and generate the target test case set.

Benefits of technology

It improves the efficiency of test case generation, avoids the generation of repeated test cases, ensures the accuracy of test results, and avoids the omissions of important test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115185807B_ABST
    Figure CN115185807B_ABST
Patent Text Reader

Abstract

An embodiment of the present application discloses a test case generation method, apparatus, electronic device and storage medium, the method comprising: obtaining a first test case set; the first test case set comprising a plurality of test cases; each test case comprising an input parameter set and an expected result set; each input parameter set comprising a key input parameter subset; determining a target expected result set and a target key input parameter set based on the first test case set; wherein the target expected result set comprises a plurality of target expected result subsets, and the target key input parameter set comprises a plurality of target key input parameter subsets; determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set; and when it is determined that the second test case set comprises each target key input parameter subset in the target key input parameter set, using the second test case set as the target test case set.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software development and testing technology, and is related to, but not limited to, a test case generation method, device, electronic device, and storage medium. Background Art

[0002] As the application demand for software products increases, in order to improve the running quality and stability of software products, it is necessary to use test cases to test software products and find potential defects in the software during the testing process. Therefore, how to generate test cases is crucial. Summary of the Invention

[0003] In view of this, embodiments of the present application provide a test case generation method, device, electronic device, and storage medium.

[0004] In a first aspect, an embodiment of the present application provides a test case generation method, the method comprising: obtaining a first test case set; the first test case set includes multiple test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter set includes a key input parameter subset composed of key input parameters; the key input parameter is an input parameter whose correlation with at least one expected result in the expected result set is greater than a preset threshold; according to the first test case set, determining a target expected result set and a target key input parameter set; wherein the target expected result set includes multiple target expected result subsets, and the target key input parameter set includes multiple target key input parameter subsets; determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set; and when it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, using the second test case set as the target test case set.

[0005] In a second aspect, an embodiment of the present application provides a test case generation device, comprising: a first acquisition module, for acquiring a first test case set; the first test case set includes multiple test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter set includes a key input parameter subset composed of key input parameters; the key input parameter is an input parameter whose correlation with at least one expected result in the expected result set is greater than a preset threshold; a screening module, for determining a target expected result set and a target key input parameter set based on the first test case set; wherein the target expected result set includes multiple target expected result subsets, and the target key input parameter set includes multiple target key input parameter subsets; a first determination module, for determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set; a second determination module, for taking the second test case set as the target test case set when it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set.

[0006] In a third aspect, an embodiment of the present application provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the steps in any test case generation method described in the embodiment of the present application are implemented.

[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in any test case generation method described in the embodiment of the present application.

[0008] In an embodiment of the present application, by determining a second test case based on a target expected result set, and determining that the second test case set includes all target key input parameter subsets in the target key input parameter set, the second test case is determined as the target test case set. On the one hand, by taking the expected results into consideration when generating the test case, since the target expected result subsets in the target expected result set are all different, the test cases corresponding to the duplicate expected result subsets can be removed, thereby improving the testing efficiency; on the other hand, since the target key input parameter subsets are different from each other, by determining whether all target key input parameter subsets are included in the second test case set, it is possible to avoid missing important test cases and improve the accuracy of the test results. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] Figure 1 A flow chart of a test case generation method according to an embodiment of the present application;

[0010] Figure 2 This is a schematic diagram of the structure of a test case generation device according to an embodiment of the present application;

[0011] Figure 3 This is a flow chart of another test case generation method according to an embodiment of the present application;

[0012] Figure 4 A flowchart of another test case generation method according to an embodiment of the present application;

[0013] Figure 5 This is a schematic diagram of the composition structure of another test case generation device according to an embodiment of the present application;

[0014] Figure 6 A schematic diagram of a hardware entity of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0015] The technical solution of the present application is further described in detail below with reference to the accompanying drawings and embodiments.

[0016] Figure 1 This is a flow chart of a test case generation method according to an embodiment of the present application. Figure 1 As shown, the method includes:

[0017] Step 102: Obtain a first test case set; the first test case set includes a plurality of test cases; each test case includes an input parameter set and an expected result set; each input parameter set includes a key input parameter subset consisting of key input parameters; the key input parameter is an input parameter whose correlation with at least one expected result in the expected result set is greater than a preset threshold;

[0018] Among them, the first test case set is a set including multiple test cases; Table 1 is the first test case set managed by EXCEL, see Table 1, the first test case set includes test case 1 to test case 8; a test case is a set of test inputs (also called input parameters), execution conditions and expected results compiled for a special goal, which is used to verify whether a specific software requirement is met; the test input can be the parameters that need to be input to test the functions of the software to be tested, and the execution condition can be the prerequisite for the execution of the test case, which refers to what conditions need to be met to achieve the expected test results, and the execution condition can be the operating system for the software to be tested to run; the expected result can be the expected output value of the software to be tested after the parameters are input in the software to be tested under certain prerequisites, which can refer to the result that should be presented.

[0019] Table 1

[0020]

[0021] Referring to Table 1, each of the test cases may include an input parameter set and an expected result set, etc.; the input parameter set may include multiple input parameters; the expected result set may include multiple expected results; assuming that the specific software requirement is a violation judgment for an operation log, the input parameters may be sensitivity level, account type, whether there is a credential, etc.; the value of the sensitivity level may be greater than 0 (>0) or less than or equal to 0 (≤); the value of the account type may be 0 or 1, and the value of whether there is a credential may be true or false, where true indicates that there is a credential and false indicates that there is no credential; the expected result may be whether there is an unauthorized access or a violation, etc.; the value of whether there is an unauthorized access may be true or false, where true indicates an unauthorized access and false indicates that there is no unauthorized access; the value of whether there is a violation may be true or false, where true indicates a violation and false indicates that there is no violation.

[0022] Among them, the key input parameter can be an input parameter whose correlation with at least one expected result in the expected result set is greater than a preset threshold; the preset threshold can be 75%, 80%, 90%, etc.; assuming that the software testing requirement is to determine a violation of an operation log, then since the account type and whether there is a credential are strongly correlated with whether the expected result exceeds the authority and violates the rules, for example, the correlation between the account type and whether the expected result exceeds the authority and violates the rules are both greater than the preset threshold, and the correlation between whether there is a credential and whether the expected result exceeds the authority and violates the rules are also greater than the preset threshold, therefore, the account type and whether there is a credential can be determined as key input parameters, that is, the key input parameter subset includes the two key input parameters of account type and whether there is a credential.

[0023] Step 104: Determine a target expected result set and a target key input parameter set based on the first test case set; wherein the target expected result set includes multiple target expected result subsets, and the target key input parameter set includes multiple target key input parameter subsets;

[0024] Among them, since the expected result sets corresponding to multiple test cases in the first test case set may be the same or different, the first test case can be screened to obtain multiple different expected result sets, and each expected result set after screening corresponds to a target expected result subset; referring to Table 1, the target expected result set can be expressed as {overstepping authority & violation, overstepping authority & no violation, no overstepping authority & violation, no overstepping authority & no violation}, and can also be expressed as {(whether overstepping authority = true) & (whether violation = true), (whether overstepping authority = true) & (whether violation = false), (whether overstepping authority = false) & (whether violation = true), (whether overstepping authority = false) & (whether violation = false)}.

[0025] Similarly, the key input parameter sets corresponding to multiple test cases in the first test case set may be the same or different. Therefore, the first test case can be screened to obtain multiple different target key input parameter subsets; referring to Table 1, the target key input parameter set can be expressed as {(account type = 0) & has credentials, (account type = 0) & no credentials, (account type = 1) & has credentials, (account type = 1) & no credentials}, and can also be expressed as {(account type = 0) & (whether credentials = true), (account type = 0) & (whether credentials = false), (account type = 1) & (whether credentials = true), (account type = 1) & (whether credentials = false)}.

[0026] Step 106: Determine a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0027] Among them, assuming that the target expected result set includes the target expected result subset {(account type = 0) & has credentials}, the target expected result subset {(account type = 0) & no credentials}, the target expected result subset {(account type = 1) & no credentials} and the target expected result subset {(account type = 1) & has credentials}; the test case corresponding to the target expected result subset {(account type = 0) & has credentials} is test case 1, the test case corresponding to the target expected result subset {(account type = 0) & no credentials} is test case 2, the test case corresponding to the target expected result subset {(account type = 1) & no credentials} is test case 6, and the test case corresponding to the target expected result subset {(account type = 1) & has credentials} is test case 7, then the set {1, 2, 6, 7} consisting of test cases 1, 2, 6 and 7 can be determined as the second test case set.

[0028] Step 108: When it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set.

[0029] Among them, it is assumed that the second test case set can be {1, 2, 6, 7}; since the target key input parameter subset contained in test case 1 is {(account type = 0) & has credentials}, the target key input parameter subset contained in test case 2 is {(account type = 0) & no credentials}, the target key input parameter subset contained in test case 6 is {(account type = 1) & no credentials}, and the target key input parameter subset contained in test case 7 is {(account type = 1) & has credentials}, that is, test cases 1, 2, 6, and 7 contain all the target key input parameter subsets in the target key input parameter set. Therefore, {1, 2, 6, 7} can be directly determined as the target test case set.

[0030] In an embodiment of the present application, by determining a second test case based on a target expected result set, and determining that the second test case set includes all target key input parameter subsets, the second test case is determined as the target test case set. On the one hand, by taking the expected results into consideration when generating the test case, since the target expected result subsets in the target expected result set are all different, the test cases corresponding to the duplicate expected result sets can be removed, thereby improving the testing efficiency; on the other hand, since the target key input parameter subsets are different from each other, by determining whether the second test case set includes all target key input parameter subsets, the correlation between the input parameters and the expected results is taken into consideration, which can avoid missing important test cases and improve the accuracy of the test results.

[0031] The present invention also provides a method for generating a test case, the method comprising:

[0032] Step S202: Acquire a first test case set; the first test case set includes a plurality of test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters;

[0033] Step S204: determining a target expected result set and a target key input parameter set according to the first test case set; wherein the target expected result set includes multiple target expected result subsets, and the target key input parameter set includes multiple target key input parameter subsets;

[0034] Step S206: determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0035] Step S208: when it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set;

[0036] Step S210: When it is determined that each target key input parameter subset in the target key input parameter set is not included in the second test case set, a set consisting of test cases corresponding to the target key input parameter subset not included in the first test case set is selected as a third test case set;

[0037] Among them, it is assumed that the second test case set is {1, 2, 3, 6}; since the target key input parameter subset contained in test cases 1 and 3 is {(account type = 0) & has credentials}, the target key input parameter subset contained in test case 2 is {(account type = 0) & no credentials}, and the target key input parameter subset contained in test case 6 is {(account type = 1) & no credentials}, that is, test cases 1, 2, 3, and 6 do not contain the target key input parameter subset {(account type = 1) & has credentials}, while test case 5 and test case 7 both contain the target key input parameter subset {(account type = 1) & has credentials}, therefore, the set composed of test cases 5 and 7 can be used as the third test case set, or any test case modified from test cases 5 and 7 can be used as the third test case set.

[0038] Step S212: Merge the third test case set and the second test case set to obtain the target test case set.

[0039] Among them, assuming that the third test case set is {5, 7}, the target test case set is {1, 2, 3, 5, 6, 7}; assuming that the third test case set is {5}, the target test case set is {1, 2, 3, 5, 6}; assuming that the third test case set is {7}, the target test case set is {1, 2, 3, 6, 7}.

[0040] In an embodiment of the present application, by determining a second test case based on a target expected result set, and when it is determined that not all target key input parameter subsets are included in the second test case set, the second test case and a third test case consisting of test cases corresponding to the target key input parameter subsets not included are merged to obtain a target test case set. On the one hand, since the target expected result subsets in the target expected result set are all different, the test cases corresponding to the duplicate expected result sets can be removed, thereby improving the testing efficiency. On the other hand, since the target key input parameter subsets are different from each other, by determining that not all target key input parameter subsets are included in the second test case set, the target key input parameter subsets not included are added to the target key input parameter subset, taking into account the correlation between the input parameters and the expected results, thereby avoiding missing important test cases and improving the accuracy of the test results.

[0041] The present invention also provides a method for generating a test case, the method comprising:

[0042] Step S302: Obtain at least one initial input parameter, an initial expected result, and a test case generation formula;

[0043] Among them, assuming that the software to be tested is a violation judgment software for operation logs, the initial input parameters can be the user's log operations, log data, log user data, etc.; the initial expected results can be violation judgment results, etc.; the test case generation formula can be a test case generation method, such as conjunction or union, etc.

[0044] Step S304: performing attribute extraction on the at least one initial input parameter and the at least one initial expected result respectively to obtain at least one different input parameter and at least one different expected result;

[0045] Step S306: Generate a first test case set using the test case generation formula, the at least one input parameter and the at least one expected result;

[0046] Step S308: Acquire the first test case set; the first test case set includes multiple test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters;

[0047] Step S310: determining a target expected result set and a target key input parameter set according to the first test case set; wherein the target expected result set includes multiple target expected result subsets, and the target key input parameter set includes multiple target key input parameter subsets;

[0048] Step S312: determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0049] Step S314: when it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set.

[0050] In an embodiment of the present application, by performing attribute extraction on the at least one initial input parameter and the initial expected result, at least one input parameter and the expected result are obtained, and a test case is generated based on the test case generation formula, the input parameters and the expected results. This has low technical thresholds and experience requirements for the tester, and reduces the operational complexity of the tester. The input parameters and expected results obtained through attribute extraction and the test case generation formula can be used to generate test cases, thereby improving testing efficiency.

[0051] The present invention also provides a method for generating a test case, the method comprising:

[0052] Step S402: obtaining at least one initial input parameter, an initial expected result, and a test case generation formula;

[0053] Among them, each of the initial input parameters includes at least one attribute, and the at least one attribute of each of the initial input parameters includes public attributes and private attributes, and the attributes of different initial input parameters may be the same; similarly, each of the initial expected results includes at least one attribute, and the at least one attribute of each of the initial expected results includes public attributes and private attributes, and the attributes of different initial expected results may be the same.

[0054] Step S404: extracting the public attributes of the at least one initial input parameter to obtain different public attributes; extracting the private attributes of the at least one initial input parameter to obtain different private attributes; determining the different public attributes and the different private attributes as at least one input parameter;

[0055] Among them, the private attributes of the initial input parameters can be the unique attributes of the initial input parameters in the software requirements of each software to be tested, which are different from the attributes of other software features; the test case generation device can extract the private attributes of the initial input parameters based on the software requirements; the public attributes can be the attributes summarized and extracted from the general software input value features, such as field type, threshold, etc.; the public attributes are generally pre-stored in a public attribute pool; the test case generation device can extract the public attributes of the initial input parameters from the public attribute pool.

[0056] Attributes of initial input parameters such as log data and log user data can be extracted to obtain three different attributes: the sensitive category field of log data (also known as the sensitivity level), the account type and account credentials (also known as credentials) of log user data. These three different attributes are determined as three input parameters, and each input parameter has a corresponding value. For example, the value of the sensitivity level is >0 or ≤0; the attributes of multiple initial input parameters may be the same, and a certain initial input parameter may include multiple attributes.

[0057] Step S406: extracting the public attributes of the at least one initial expected result to obtain different public attributes; extracting the private attributes of the at least one initial expected result to obtain different private attributes; and determining the different public attributes and the different private attributes as at least one expected result;

[0058] Among them, the attributes of the initial expected result, such as the violation judgment result, can be extracted to obtain two different attributes: whether it is an overstepping of authority and whether it is a violation. These two different attributes are determined as two expected results, and each expected result has a corresponding value, such as whether the value of overstepping of authority is true or false; it should be noted that the attributes of multiple initial expected results may be the same, and a certain initial expected result may include multiple attributes.

[0059] Step S408: Generate a first test case set using the test case generation formula, the at least one input parameter and the at least one expected result;

[0060] Step S410: Acquire the first test case set; the first test case set includes a plurality of test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters;

[0061] Step S412: determining a target expected result set and a target key input parameter set based on the first test case set; wherein the target expected result set includes multiple target expected result subsets, and the target key input parameter set includes multiple target key input parameter subsets;

[0062] Step S414: determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0063] Step S416: When it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set.

[0064] In an embodiment of the present application, by selecting public attributes from a public attribute pool, the convenience of extracting public attributes is improved; by extracting attributes from the public attributes and private attributes of the initial input parameters and the initial expected results respectively, and using the extracted different attributes as input parameters and expected results, and generating test cases based on the input parameters, expected results and test case generation formula, without generating test cases by analyzing source code, the complexity of test case generation is reduced and the efficiency of test case generation is improved.

[0065] The present invention also provides a method for generating a test case, the method comprising:

[0066] Step S502: obtaining at least one initial input parameter, an initial expected result, and a test case generation formula;

[0067] Step S504: extracting public attributes and private attributes of each of the at least one initial input parameter;

[0068] Step S506: merging a public attribute selected from the common public attributes of the at least one initial input parameter with other mutually different public attributes except the common public attribute to obtain at least one mutually different public attribute;

[0069] Step S508: merging a private attribute selected from the same private attributes of the at least one initial input parameter with other different private attributes except the same private attribute to obtain at least one different private attribute;

[0070] Step S510: determining the mutually different public attributes and the mutually different private attributes as at least one input parameter;

[0071] In other embodiments, the test case generation device can receive a first public attribute selection instruction, and determine at least one public attribute from a public attribute pool in response to the first public attribute selection instruction; the test case generation device can also receive a first private attribute input instruction, and determine at least one private attribute in response to the first private attribute input instruction; and determine the at least one public attribute and the at least one private attribute as at least one input parameter.

[0072] Step S512: extracting public attributes and private attributes of each of the at least one initial expected result;

[0073] Among them, the public attributes of the initial expected results can also be pre-stored in the public attribute pool; the private attributes of the initial expected results can be the unique attributes of the initial expected results in the software requirements of each software to be tested, which are different from the attributes of other software features; the test case generation device can extract the private attributes of the initial expected results based on the software requirements.

[0074] Step S514: merging a public attribute selected from the public attributes with the same initial expected result and other public attributes that are different from each other except the same public attribute to obtain at least one public attribute that is different from each other;

[0075] Step S516: merging a private attribute selected from the at least one private attribute with the same initial expected result and other mutually different private attributes except the same private attribute to obtain at least one mutually different private attribute;

[0076] Step S518: Determine the mutually different public attributes and the mutually different private attributes as at least one expected result.

[0077] In other embodiments, the test case generation device can receive a second public attribute selection instruction, and determine at least one public attribute from a public attribute pool in response to the second public attribute selection instruction; the test case generation device can also receive a second private attribute input instruction, and determine at least one private attribute in response to the second private attribute input instruction, and determine the at least one public attribute and the at least one private attribute as at least one expected result.

[0078] Step S520: Generate a first test case set using the test case generation formula, the at least one input parameter and the at least one expected result.

[0079] Step S522: Acquire the first test case set; the first test case set includes a plurality of test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters;

[0080] The input parameter set includes at least one input parameter, and the expected result set includes at least one expected result.

[0081] Step S524: determining a target expected result set and a target key input parameter set based on the first test case set; wherein the target expected result set includes multiple target expected result subsets, and the target key input parameter set includes multiple target key input parameter subsets;

[0082] Step S526: determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0083] Step S528: When it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set.

[0084] In an embodiment of the present application, when extracting attributes of initial input parameters and initial expected results, the same attributes can be merged to obtain different attribute sets, and input parameters or expected results can be generated based on the different attribute sets, thereby improving the efficiency of test case generation and reducing the operational complexity of technicians.

[0085] The present invention also provides a method for generating a test case, the method comprising:

[0086] Step S602: Obtain at least one initial input parameter, an initial expected result, and a test case generation formula;

[0087] The test case generation formula may be a union.

[0088] Step S604: performing attribute extraction on the at least one initial input parameter and the at least one initial expected result respectively to obtain at least one input parameter and at least one expected result;

[0089] Step S606: determining all combinations of the at least one input parameter and the at least one expected result;

[0090] Among them, the full combination can be all possible actual situations of any combination of any value of each input parameter in the at least one input parameter and any value of each expected result in the at least one expected result determined according to the actual software testing requirement rules. Referring to Table 1, there are a total of 8 situations that conform to the actual combination of input parameters and expected results, and "√" indicates that the value of the corresponding position is selected.

[0091] Assuming that the at least one input parameter includes a sensitivity level, an account type, and whether there is a credential, the value of the sensitivity level can be greater than 0 (>0) or less than or equal to 0 (≤); the value of the account type can be 0 or 1, and the value of whether there is a credential can be true or false; the at least one expected result includes whether there is an overstepping of authority and whether there is a violation, the value of whether there is an overstepping of authority can be true or false, and the value of whether there is a violation can be true or false, then the full combination of the at least one input parameter and the at least one expected result includes: Combination 1: {(sensitive category>0), (account type=0), (whether there is a credential=true), (whether there is an overstepping of authority=true), (whether there is a violation=false)}, Combination 2: {(sensitive category>0), (account type=0), (whether there is a credential=false), (whether there is an overstepping of authority=true), (whether there is a violation=true)}. Similarly, other combinations can be determined.

[0092] Step S608: taking a union of the input parameters included in each combination in the full combination to obtain a first result;

[0093] Among them, taking combination 1 as an example, the sensitivity level value is >0, the account type is 0, and whether there is a credential is true, then the input parameters can be taken into account to obtain the first result, which can be expressed as: (sensitive category > 0) ∪ (account type = 0) ∪ (whether there is a credential = true).

[0094] Similarly, for combination 2, the sensitivity level value is >0, the account type is 0, and whether there is a credential is false. Then, the input parameters can be unioned to obtain the first result, which can be expressed as: (sensitive category > 0) ∪ (account type = 0) ∪ (whether there is a credential = false).

[0095] Step S610: taking the union of the expected results included in each combination to obtain a second result;

[0096] Among them, taking combination 1 as an example, the value of whether it exceeds the authority is true, and the value of whether it violates the law is false. Then the expected results can be taken into account to obtain the second result, which can be expressed as: (whether it exceeds the authority = true) ∪ (whether it violates the law = false).

[0097] Similarly, for combination 2, the value of whether it exceeds authority is true, and the value of whether it violates the law is true. Then we can take the union of the expected results to get the second result, which can be expressed as: (whether it exceeds authority = true) ∪ (whether it violates the law = true).

[0098] Step S612: Taking the union of the first result and the second result to obtain a first test case corresponding to each combination;

[0099] Here, taking combination 1 as an example, the union of the first result and the second result is (sensitive category>0)∪(account type=0)∪(whether there is a credential=true)∪(whether it exceeds authority=true)∪(whether it is a violation=false), and the union can be used as test case 1.

[0100] Similarly, for combination 2, the union of the first result and the second result is (sensitive category > 0) ∪ (account type = 0) ∪ (whether there is a credential = false) ∪ (whether it exceeds authority = true) ∪ (whether it is a violation = true), and the union can be used as test case 2.

[0101] Step S614: Utilize each of the first test cases to form a first test case set;

[0102] Step S616: Acquire the first test case set; the first test case set includes multiple test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters;

[0103] Step S618: Determine a target expected result set and a target key input parameter set based on the first test case set; wherein the target expected result set includes multiple target expected result subsets, and the target key input parameter set includes multiple target key input parameter subsets;

[0104] Step S620: determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0105] Step S622: When it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set.

[0106] In the embodiment of the present application, the convenience of test case generation is improved by taking the union of input parameters and expected results.

[0107] The present invention also provides a method for generating a test case, the method comprising:

[0108] Step S702: Obtain at least one initial input parameter, an initial expected result, and a test case generation formula;

[0109] Step S704: performing attribute extraction on the at least one initial input parameter and the at least one initial expected result respectively to obtain at least one different input parameter and at least one different expected result;

[0110] Step S706: Generate a first test case set using the test case generation formula, the at least one input parameter and the at least one expected result;

[0111] Step S708: Acquire the first test case set; the first test case set includes multiple test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters;

[0112] Step S710: screening the expected result sets in the first test case set, and determining the obtained different expected result sets as target expected result sets;

[0113] Step S712: screening the key input parameter subsets in the first test case set, and determining the obtained different key input parameter subsets as the target key input parameter set;

[0114] Assuming that the key input parameters in the key input parameter subset include account type and whether there is a credential, as shown in Table 1, the key input parameter subset corresponding to test cases 1 and 3 is {(account type = 0) & credential exists}, the key input parameter subset corresponding to test cases 2 and 4 is {(account type = 0) & no credential exists}, the key input parameter subset corresponding to test cases 5 and 7 is {(account type = 1) & credential exists}, and the key input parameter subset corresponding to test cases 6 and 8 is {(account type = 1) & no credential exists}. Therefore, the target key input parameter set can be {(account type = 0) & credential exists, (account type = 0) & no credential exists, (account type = 1) & credential exists, (account type = 1) & no credential exists}.

[0115] Step S714: determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0116] Step S716: When it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set.

[0117] In an embodiment of the present application, by screening the expected result set and the key input parameter subset respectively, a target expected result set containing all different expected result sets and a target key input parameter set containing the said different key input parameter subsets can be obtained. When determining the final target test case set, the expected results and key input parameters are fully taken into consideration, so that the test results can be more accurate.

[0118] The present invention also provides a method for generating a test case, the method comprising:

[0119] Step S802: Acquire a first test case set; the first test case set includes a plurality of test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters;

[0120] Step S804: selecting an expected result set from a plurality of identical expected result sets in the first test case set as a first expected result set;

[0121] Among them, referring to Table 1, since the target expected results corresponding to test cases 3, 4, 5, 7, and 8 are all no overstepping of authority and no violation of regulations, an expected result set {no overstepping of authority and no violation of regulations} can be screened out from the expected result sets of test cases 3, 4, 5, 7, and 8 as the first expected result set.

[0122] Step S806: Filtering out other different expected result sets from the first test case set except the multiple identical expected result sets as second expected result sets;

[0123] Among them, the target expected result corresponding to test case 1 is overstepping authority & no violation, the target expected result corresponding to test case 2 is overstepping authority & violation, and the target expected result corresponding to test case 6 is no overstepping authority & violation. Then {overstepping authority & no violation, overstepping authority & violation, no overstepping authority & violation} can be used as the second expected result set.

[0124] Step S808: merging the first expected result set and the second expected result set to obtain a target expected result set;

[0125] The first expected result set and the second expected result set may be merged to obtain a target expected result set {overstepping authority & no violation, overstepping authority & violation, no overstepping authority & violation, no overstepping authority & no violation}.

[0126] Step S810: screening the key input parameter subsets in the first test case set, and determining the obtained different key input parameter subsets as the target key input parameter set;

[0127] Step S812: determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0128] Step S814: When it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set.

[0129] In an embodiment of the present application, a first expected result set is first screened out from multiple identical expected result sets, and then the first expected result set is merged with other different expected result sets except the multiple identical expected result sets, so that a target expected result set containing all different expected result sets can be obtained. When determining the final target test case set, the expected results are fully taken into consideration, so that the test results can be more accurate.

[0130] The present invention also provides a method for generating a test case, the method comprising:

[0131] Step S902: Acquire a first test case set; the first test case set includes a plurality of test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters;

[0132] Step S904: determining the number of the test case corresponding to each of the plurality of identical expected result sets in the first test case set;

[0133] The test case numbers may be set according to the test case priorities or randomly set.

[0134] Step S906: Determine the expected result set corresponding to the test case with the smallest number as the first expected result set;

[0135] Among them, assuming that the target expected results corresponding to test cases 3, 4, 5, 7, and 8 are all no overstepping of authority and no violation of regulations, then since test case 3 has the smallest number, the expected result set corresponding to test case 3 can be determined as the first expected result set.

[0136] Step S908: Filtering out other mutually different expected result sets except the multiple identical expected result sets from the first test case set as second expected result sets;

[0137] Step S910: merging the first expected result set and the second expected result set to obtain a target expected result set;

[0138] Step S912: selecting a key input parameter subset from a plurality of identical key input parameter subsets in the first test case set as a first key input parameter subset;

[0139] Step S914: Filtering out other mutually different key input parameter subsets except the multiple identical expected result sets from the first test case set as second key input parameter subsets;

[0140] Step S916: merging the first key input parameter subset and the second key input parameter subset to obtain a target key input parameter set;

[0141] Step S918: determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0142] Step S920: When it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set.

[0143] In an embodiment of the present application, when filtering the first expected result set from multiple identical expected result sets, filtering can be performed according to the numbers of the test cases corresponding to the expected results, thereby improving the convenience of filtering.

[0144] The present invention also provides a method for generating a test case, the method comprising:

[0145] Step S1002: Acquire a first test case set; the first test case set includes a plurality of test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters;

[0146] Step S1004: determining any expected result set among the multiple identical expected result sets in the first test case set as a first expected result set;

[0147] Step S1006: Filtering out other mutually different expected result sets except the multiple identical expected result sets from the first test case set as second expected result sets;

[0148] Step S1008: merging the first expected result set and the second expected result set to obtain a target expected result set;

[0149] Step S1010: screening the key input parameter subsets in the first test case set, and determining the obtained different key input parameter subsets as the target key input parameter set;

[0150] Step S1012: determining a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0151] Step S1014: when it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set.

[0152] In the embodiment of the present application, when screening the first expected result set from multiple identical expected result sets, any expected result set in the identical expected result set can be used as the first expected result set, thereby improving the flexibility of screening.

[0153] In related technologies, when generating test cases, most of them need to analyze source code to generate test cases, or there are certain requirements on the experience of testers, and the process is cumbersome.

[0154] There are generally three methods for generating test cases in related technologies:

[0155] The first test case generation method is to analyze the source code of the software requirement document and write test code based on the configuration file input by the user. It requires high skills and experience of the tester and has high maintenance costs.

[0156] The second test case generation method is to combine the input parameter combination attributes with the pre-existing dependent combination attributes and the empirical rules in the test process, and finally obtain the meta-attribute empirical rule set and the individual combination attribute use case set to construct the test case; this method does not take into account the expected results. In actual software testing, the input values ​​are often not independent, but there is a certain correlation. This method does not take this correlation into account.

[0157] The third test case generation method is to generate test cases that contain test input values ​​and expected output values ​​for the software based on the software specifications; first generate the test input data, then add the expected output results to generate the test case; this method usually decomposes the test input and expected results into multiple steps, making the test case generation process more cumbersome.

[0158] However, when testing software functionality, testers often need to input certain test parameters (also known as input parameters), execution conditions, and expected results to construct test cases. When there are many input parameters and they are strongly correlated with each other or with the expected results, a test case generation method and device are needed to automatically generate test cases and improve testing efficiency.

[0159] The present application provides a method and device for generating a test case. Figure 2 This is a schematic diagram of the structure of a test case generation device according to an embodiment of the present application. Figure 2 The device 200 includes an input module 201, a storage module 202, an execution module 203 and an output module 204.

[0160] In one embodiment, the input module 201 can be used to obtain test input (also known as input parameters), execution conditions, and expected results; and decompose the test input (also known as input parameters), execution conditions, and expected results into corresponding attributes, and divide the attributes obtained by decomposing the test input, the execution conditions, and the expected results into private attributes 2022 and public attributes respectively. The input module 201 can obtain an attribute calculation strategy 2023 (also known as a test case generation strategy or a test case generation formula) and an expected result set 2024 (also known as a target expected result set) according to software requirements. The input module 201 can select public attributes from the public attribute pool 2021 of the storage module 202 and input the private attributes 2022 into the storage module 202. 22. Attribute calculation strategy 2023 and expected result set 2024. The execution module 203 can generate a test case attribute set from the storage module 202 according to the private attributes 2022 and the public attributes selected from the public attribute pool 2021; the execution module 203 constructs a first test case set according to the test case attribute set and the test case generation strategy, and then generates a second test case set (also called an expected output test case set) according to the first test case set and the expected result set 2024. The execution module 203 adds a third test case set (also called an associated attribute test case set) to the constructed second test case set to generate a target test case set (also called a final test case set), and outputs the final test case set through the output module 204.

[0161] The input module 201 can be an external input module provided to a user or other terminal device, such as a mouse, keyboard, or touchscreen. Through the input module, the user or other terminal device can input test inputs, execution conditions, expected results, as well as a test case generation strategy and target expected result set for the software under test. The storage module 202 can be a random access memory (RAM), read-only memory (ROM), or similar device; it can be used to store a public attribute pool 2021, private attributes 2022, a test case generation strategy 2023, an expected result set 2024, and the like. The execution module 203 can include a computing unit such as a central processing unit (CPU). The execution module 203 generates a test case attribute set and, based on the test case attribute set and the test case generation strategy, constructs multiple test cases to form a test case set. After the execution module 203 generates the test case set, the user or other terminal device can access the test case set through the output module 204.

[0162] In the above embodiment, the input module can decompose the acquired test input, execution conditions, and expected output into private attributes 2022, which together with the public attributes selected from the public attribute pool 2021 pre-stored in the storage module 202 form a test case attribute set. The test case attribute set is stored together with the attribute calculation strategy and the target expected result set in the storage module 202. The execution module 203 generates the expected output test case set based on the test case attribute set, the attribute calculation strategy 2023, and the expected result set 2024, adds the associated attribute set, and obtains the final test case set, which is output to the user or other terminal device through the output module 204.

[0163] In another embodiment, the user can obtain test input (also known as input parameters), execution conditions, and expected results; and decompose the test input (also known as input parameters), execution conditions, and expected results into corresponding attributes, and divide the attributes obtained by decomposing the test input, the execution conditions, and the expected results into private attributes 2022 and public attributes respectively. The user can obtain the attribute calculation strategy 2023 (also known as the test case generation strategy or test case generation formula) and the expected result set 2024 (also known as the target expected result set) according to software requirements. The user inputs the private attributes 2022, the attribute calculation strategy 2023, and the expected result set 2024 into the storage module 202 through the input module 201; the user can select public attributes from the public attribute pool 2021 of the storage module 202 through the input module 201. The execution module 203 can generate a test case attribute set from the storage module 202 based on the private attributes 2022 input by the user and the public attributes selected by the user from the public attribute pool 2021; the execution module 203 constructs a first test case set based on the test case attribute set and the test case generation strategy, and then generates a second test case set (also called an expected output test case set) based on the first test case set and the expected result set 2024. The execution module 203 adds a third test case set (also called an associated attribute test case set) to the constructed test case set, generates a target test case set (also called a final test case set), and outputs the final test case set through the output module 204.

[0164] The input module 201 can be an external input module provided to a user or other terminal device, such as a mouse, keyboard, or touchscreen. The user or other terminal device can use the input module to input the private attributes, attribute calculation strategy, and expected result set of the software under test. The storage module 202 can be a random access memory (RAM), read-only memory (ROM), or similar device; it can be used to store the public attribute pool 2021, private attributes 2022, attribute calculation strategy 2023, expected result set 2024, and the like. The execution module 203 can include a computing unit such as a central processing unit (CPU). The execution module 203 generates a test case attribute set and constructs multiple test cases based on the test case attribute set and the test case generation strategy to generate a test case set. After the execution module 203 generates the test case set, the user or other terminal device can access the test case set through the output module 204.

[0165] In the above embodiment, the user can decompose the obtained test input, execution conditions, and expected output into private attributes 2022, which together with the public attributes selected from the public attribute pool 2021 pre-stored in the storage module 202 form a test case attribute set. The test case attribute set is stored in the storage module 202 together with the attribute calculation strategy and the target expected result set by the input module 201. The execution module 203 generates the expected output test case set based on the test case attribute set, attribute calculation strategy 2023, and expected result set 2024, adds the associated attribute set, and obtains the final test case set, which is output to the user or other terminal device through the output module 204.

[0166] Figure 3 This is a flow chart of another test case generation method according to an embodiment of the present application, see Figure 3 , the method may include the following steps:

[0167] Step 301: The input module inputs private attributes.

[0168] Among them, private attributes can be unique attributes in each software requirement, which are different from the attributes of other software features. The input module can extract the private attributes of the initial test input, initial execution conditions, and initial expected results according to the software requirements to form a private attribute set. According to the test requirements, the initial test input, initial execution conditions, and initial expected results can all be decomposed into attributes. The initial test input can be the parameters required to test the software function, the initial execution conditions can be the preconditions for the execution of the test case, and the initial expected results can be the expected output value of the software after the parameters are input into the software under certain preconditions. For example, for the violation judgment of an operation log, the user's log operation, the log system, the violation judgment result, etc. are private attributes. Among them, the user's log operation can be the attribute decomposed from the initial test input in the violation judgment of the operation log, the log system can be the attribute decomposed from the initial execution conditions in the violation judgment of the operation log, and the violation judgment result can be the attribute decomposed from the initial expected result in the violation judgment of the operation log.

[0169] Step 302: The execution module generates a test case attribute set in combination with a pre-stored public attribute pool.

[0170] Among them, public attributes are attributes summarized and extracted from general software input value features, such as field type, threshold, etc., which are pre-stored in the public attribute pool 2021 and combined with the private attribute set obtained in step 302 to generate a test case attribute set of the software to be tested.

[0171] Step 303: The input module generates an attribute calculation strategy according to the requirement rules.

[0172] Among them, under normal circumstances, there is a certain correlation between input parameters and execution conditions, and multiple input parameters are not completely independent. For example, if log data and log user data are two types of input data, the attributes of three initial input parameters can be extracted from these two types of data as input parameters, namely the sensitive category field of log data (also known as sensitivity level), the account type and account credentials of log user data (also known as credentials); based on the requirements, it is finally determined whether the account has exceeded its authority and violated the rules, that is, the expected results include whether it has exceeded its authority and violated the rules. At this time, the attribute calculation strategy and target expected result set of the test case can be formulated for the input parameters and expected results according to the requirement rules. The first test case set can be generated based on the test case attribute set and the attribute calculation strategy, see Table 1. The first test case set includes test cases 1 to 8. Each test case can include an input parameter set and an expected result set. The input parameter set includes three input parameters: sensitivity level, account type, and whether there is a credential. The expected result set includes two expected results: whether it has exceeded its authority and whether it has violated the rules.

[0173] Refer to Table 1. Assuming that the attribute calculation strategy is a conjunction, the input parameters are sensitive category > 0, account type = 0, and whether there is a credential = true (that is, there is a credential), and the expected results are whether the authority is exceeded = true (that is, it is exceeded) and whether there is a violation = false (that is, there is no violation), then test case 1 can be expressed in conjunction as: (sensitive category > 0) ∧ (account type = 0) ∧ (whether there is a credential = true) ∧ (whether the authority is exceeded = true) ∧ (whether the violation = false). Other test cases can be expressed in this way.

[0174] Step 304: The input module generates a target expected result set according to the requirement rules.

[0175] Among them, the target expected result set R can be expressed as R={overstepping authority & violation, overstepping authority & no violation, no overstepping authority & violation, no overstepping authority & no violation}, which contains 4 elements.

[0176] Step 305: The execution module generates an expected output use case set Y.

[0177] Among them, according to the target expected result set R in step 304, test cases containing the target expected result set R can be extracted from the full amount of test cases (for example, test cases 1 to test cases 8) to form the expected output case set Y. Since the target expected result corresponding to test case 1 is overstepping authority & no violation, the target expected result corresponding to test case 2 is overstepping authority & violation, the target expected result corresponding to test case 6 is no overstepping authority & violation, and the target expected results corresponding to test cases 3, 4, 5, 7, and 8 are all no overstepping authority & no violation, the test case with the smallest test case number can be selected. 3 can be merged with test cases 1, 2, and 6 to generate the expected output use case set Y = {1, 2, 3, 6}; test case 8 with the largest test case number can be merged with test cases 1, 2, and 6 to generate the expected output use case set Y = {1, 2, 6, 8}; any test case in the same test case can also be merged with other test cases except the same test case to obtain the expected output use case set, that is, the expected output use case set Y can also be {1, 2, 4, 6}, {1, 2, 5, 6}, {1, 2, 6, 7} or {1, 2, 6, 8}.

[0178] Step 306: The execution module adds the associated attribute use case set.

[0179] Among the above three input parameters, assuming that the account type and whether there are credentials are attributes that are strongly associated with the expected results, that is, the correlation between the account type and whether there are credentials and whether the expected results are unauthorized and whether there are violations is greater than the preset threshold, then you can check whether all values ​​of these two input parameters are included in the expected output use case set. If not, add associated attribute use cases. If the expected output use case set already contains all combinations of associated attributes, there is no need to add them.

[0180] As shown in Table 1, the expected output case set Y = {1, 2, 3, 6} only includes three combinations of {account type, credential present}: (account type = 0) & (credential present = true), (account type = 0) & (credential present = false), (account type = 1) & (credential present = false), and does not include (account type = 1) & (credential present = true). However, the expected result combinations for test cases 5 and 7 are both (account type = 1) & (credential present = true). Therefore, test cases 5 or 7 can be added to ensure that all four combinations of {account type, credential present} are covered.

[0181] Step 307: The execution module obtains the final test case set.

[0182] Among them, the associated attribute use case set obtained in the above step 306 can be added to the expected output use case set in step 304 to obtain the final test case set. Assuming that the expected output use case set Y = {1, 2, 3, 6}, the added associated attribute use case set is {7}, that is, the final test case set W = {1, 2, 3, 6, 7}.

[0183] Figure 4 This is a flow chart of another test case generation method according to the embodiment of the present application, see Figure 4 , the method may include the following steps:

[0184] Step 401: The user inputs private attributes.

[0185] Among them, users can extract the private attributes of test input, execution conditions and expected results according to software requirements to form a private attribute set. According to test requirements, test input, execution conditions and expected results can all be decomposed into attributes.

[0186] Step 402: The execution module generates a test case attribute set in combination with a pre-stored public attribute pool.

[0187] Among them, public attributes are attributes summarized and extracted from general software input value features, such as field type, threshold, etc., which are pre-stored in the public attribute pool 2021 and combined with the private attribute set obtained in step 402 to generate a test case attribute set of the software to be tested.

[0188] Step 403: The user generates an attribute calculation strategy based on the required rules.

[0189] The user can extract the attributes of three initial input parameters from two types of data: log data and log user data. These parameters are the sensitive category field (also known as the sensitivity level) of the log data, and the account type and account credentials (also known as credentials) of the log user data. Based on the requirements, the user can ultimately determine whether the account has exceeded its authority or violated any regulations. The expected results include these factors. At this point, the user can formulate a test case attribute calculation strategy and a target expected result set for the input parameters and expected results according to the required rules. A first test case set can be generated based on the test case attribute set and the attribute calculation strategy.

[0190] Step 404: The user generates a target expected result set based on the requirement rules.

[0191] Among them, the target expected result set R can be expressed as R={overstepping authority & violation, overstepping authority & no violation, no overstepping authority & violation, no overstepping authority & no violation}, which contains 4 elements.

[0192] Step 405: The execution module generates an expected output use case set Y.

[0193] Among them, according to the target expected result set R in step 404, test cases containing the target expected result set R can be extracted from the full set of test cases (for example, test case 1 to test case 8) to form an expected output use case set Y, and the expected output use case set can be expressed as Y={1, 2, 6, 8}.

[0194] Step 406: The execution module adds the associated attribute use case set.

[0195] Among the above three input parameters, assuming that the account type and whether there are credentials are attributes that are strongly associated with the expected results, that is, the correlation between the account type and whether there are credentials and whether the expected results are unauthorized and whether there are violations is greater than the preset threshold, then you can check whether all values ​​of these two input parameters are included in the expected output use case set. If not, add associated attribute use cases. If the expected output use case set already contains all combinations of associated attributes, there is no need to add them.

[0196] Step 407: The execution module obtains the final test case set.

[0197] Among them, assuming that the expected output use case set Y = {1, 2, 3, 6}, the added associated attribute use case set is {7}, that is, the final test case set W = {1, 2, 3, 6, 7}.

[0198] An embodiment of the present application proposes a test case generation method and device, which decomposes test input, execution conditions and expected results into attributes to form a private attribute set, and generates a test case attribute set by combining the private attribute set with the public attributes in the public attribute pool. The test case attribute set is obtained together with the attribute calculation strategy and the target expected result set obtained according to the software requirements, and is stored in a storage module for the execution module to add the associated attribute use case set to generate the final test case set, and is provided to the user or other terminal device through the output module.

[0199] This application extracts the attributes of input parameters, takes into account the associations between input parameters, and improves the efficiency of test case generation.

[0200] The present invention provides a test case generation device comprising an input module, a storage module, an execution module, and an output module. A user or other terminal device inputs private attributes via the input module. The execution module combines these attributes with a pool of public attributes pre-stored in the storage module to generate a set of test case attributes. The resulting set of test cases is then output to the user or other terminal device via the output module.

[0201] This embodiment of the present application provides a method for generating a test case attribute set. This method breaks down input parameters, execution conditions, and expected results into a test case attribute set, and then generates an attribute calculation strategy based on required rules. The test attribute set also includes both private and public attribute sets. If an input attribute already exists in the public attribute pool, it can be used directly without re-entering it.

[0202] An embodiment of the present application provides a method for automatically generating test cases, which obtains an attribute calculation strategy and an expected result set according to a requirement rule table, represents the test cases as including but not limited to a conjunction normal form, obtains an expected output use case set, and then adds an associated attribute use case set to obtain a final test case set.

[0203] The test case generation method and device provided in the embodiments of the present application are practical by splitting the input parameters, execution conditions, and expected results into a test case attribute set, and generating test cases according to the test case generation strategy; the method and device have low technical threshold and experience requirements for testers, and only private attributes and test case generation strategies need to be input to generate test cases, thereby improving test efficiency; the method and device have high efficiency; the method splits the input parameters, execution conditions, and expected results into attributes to generate a test case attribute set, and provides a test case generation method containing associated attributes, thereby being innovative; the method and device have low technical threshold and experience requirements for testers, and only private attributes and test case generation strategies need to be input to generate test cases, thereby reducing the operation complexity of testers and being easy to use.

[0204] Based on the foregoing embodiments, an embodiment of the present application provides a test case generation device, which includes the modules included and can be implemented by a processor in an electronic device; of course, it can also be implemented by a specific logic circuit; during implementation, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.

[0205] Figure 5 This is a schematic diagram of the composition structure of another test case generation device according to an embodiment of the present application. Figure 5 As shown, the apparatus 500 includes a first acquisition module 501, a screening module 502, a first determination module 503 and a second determination module 504, wherein:

[0206] A first acquisition module 501 is configured to acquire a first test case set; the first test case set includes a plurality of test cases; each test case includes an input parameter set and an expected result set; each input parameter set includes a key input parameter subset consisting of key input parameters; the key input parameter is an input parameter whose correlation with at least one expected result in the expected result set is greater than a preset threshold;

[0207] A screening module 502 is configured to determine a target expected result set and a target key input parameter set based on the first test case set; wherein the target expected result set includes multiple target expected result subsets, and the target key input parameter set includes multiple target key input parameter subsets;

[0208] A first determining module 503 is configured to determine a set of test cases corresponding to each target expected result subset in the target expected result set as a second test case set;

[0209] The second determining module 504 is configured to use the second test case set as the target test case set if it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set.

[0210] In one embodiment, the device further includes: a selection module for selecting, when it is determined that the second test case set does not include each target key input parameter subset in the target key input parameter set, a set consisting of test cases corresponding to the target key input parameter subsets not included in the first test case set as a third test case set; and a merging module for merging the third test case set with the second test case set to obtain the target test case set.

[0211] In one embodiment, the device also includes: a second acquisition module, used to obtain at least one initial input parameter, an initial expected result and a test case generation formula; an extraction module, used to perform attribute extraction on the at least one initial input parameter and the at least one initial expected result respectively, to obtain at least one input parameter and at least one expected result that are different from each other; a generation module, used to generate the first test case set using the test case generation formula, the at least one input parameter and the at least one expected result.

[0212] In one embodiment, the attributes of each of the initial input parameters include public attributes and private attributes, and the attributes of each of the initial expected results include public attributes and private attributes; the extraction module includes: a first extraction unit, used to extract the public attributes of the at least one initial input parameter to obtain different public attributes; a second extraction unit, used to extract the private attributes of the at least one initial input parameter to obtain different private attributes; a first determination unit, used to determine the different public attributes and the different private attributes as at least one input parameter; a third extraction unit, used to extract the public attributes of the at least one initial expected result to obtain different public attributes; a fourth extraction unit, used to extract the private attributes of the at least one initial expected result to obtain different private attributes; a second determination unit, used to determine the different public attributes and the different private attributes as at least one expected result.

[0213] In one embodiment, the test case generation formula includes taking a union, and the generation module includes: a third determination unit, used to determine the full combination of the at least one input parameter and the at least one expected result; a first union unit, used to take a union of the input parameters included in each combination in the full combination to obtain a first result; a second union unit, used to take a union of the expected results included in each combination to obtain a second result; a third union unit, used to take a union of the first result and the second result to obtain a first test case corresponding to each combination; and a composition unit, used to use each of the first test cases to compose a first test case set.

[0214] In one embodiment, the screening module includes: a first screening unit, used to screen the expected result set in the first test case set, and determine the obtained different expected result sets as the target expected result set; a second screening unit, used to screen the key input parameter subset in the first test case set, and determine the obtained different key input parameter subsets as the target key input parameter set.

[0215] In one embodiment, the first screening unit includes: a first screening sub-unit, used to screen out an expected result set from multiple identical expected result sets in the first test case set as a first expected result set; a second screening sub-unit, used to screen out other different expected result sets except the multiple identical expected result sets from the first test case set as a second expected result set; and a merging sub-unit, used to merge the first expected result set and the second expected result set to obtain a target expected result set.

[0216] In one embodiment, the first screening subunit is used to determine the number of the test case corresponding to each of the multiple identical expected result sets; and determine the expected result set corresponding to the test case with the smallest number as the first expected result set.

[0217] In one embodiment, the first screening subunit is configured to determine any expected result set among the multiple identical expected result sets as the first expected result set.

[0218] It should be noted that in the embodiments of the present application, if the above-mentioned test case generation method is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling an electronic device (which can be a mobile phone, tablet computer, desktop computer, personal digital assistant, navigation system, digital phone, video phone, television, sensor device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a magnetic disk, or an optical disk. Thus, the embodiments of the present application are not limited to any specific combination of hardware and software.

[0219] The description of the above device embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of this application, please refer to the description of the method embodiment of this application for understanding.

[0220] Correspondingly, an embodiment of the present application provides an electronic device, Figure 6 This is a hardware entity diagram of an electronic device according to an embodiment of the present application, such as Figure 6 As shown, the hardware entity of the electronic device 600 includes: a memory 601 and a processor 602, wherein the memory 601 stores a computer program that can be run on the processor 602, and when the processor 602 executes the program, the steps in the test case generation method of the above embodiment are implemented.

[0221] The memory 601 is configured to store instructions and applications executable by the processor 602, and can also cache data to be processed or processed by the processor 602 and various modules in the electronic device 600 (for example, image data, audio data, voice communication data and video communication data), which can be implemented by flash memory (FLASH) or random access memory (RAM).

[0222] Correspondingly, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the test case generation method provided in the above embodiment.

[0223] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the device embodiments. For technical details not disclosed in the storage medium and method embodiments of this application, please refer to the description of the device embodiments of this application for understanding.

[0224] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.

[0225] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0226] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0227] The units described above as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, the functional units in the various embodiments of the present application may all be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0228] Those skilled in the art will understand that all or part of the steps in the above-described method embodiments can be implemented using hardware associated with program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as a mobile storage device, a read-only memory (ROM), a magnetic disk, or an optical disk. Alternatively, if the aforementioned integrated unit of the present application is implemented as a software functional module and sold or used as a standalone product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application, or the portion that contributes to the relevant art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (such as a mobile phone, tablet computer, desktop computer, personal digital assistant, navigation system, digital phone, video phone, television, sensor device, etc.) to execute all or part of the methods described in the various embodiments of the present application. The aforementioned storage medium includes various media capable of storing program code, such as a mobile storage device, a ROM, a magnetic disk, or an optical disk.

[0229] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined, if they do not conflict, to obtain new method embodiments. The features disclosed in the several product embodiments provided in this application can be arbitrarily combined, if they do not conflict, to obtain new product embodiments. The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined, if they do not conflict, to obtain new method embodiments or device embodiments.

[0230] The above is merely an embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A test case generation method, characterized in that: The method comprises: Obtain a first test case set; the first test case set includes a plurality of test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters; the key input parameters are input parameters whose correlation with at least one expected result in the expected result set is greater than a preset threshold; Determine a target expected result set and a target key input parameter set according to the first test case set; wherein the target expected result set includes multiple target expected result subsets, and the target key input parameter set includes multiple target key input parameter subsets; Determine a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set; In the case where it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set, the second test case set is used as the target test case set.

2. The method according to claim 1, characterized in that The method further includes: if it is determined that each target key input parameter subset in the target key input parameter set is not included in the second test case set, selecting, from the first test case set, a set consisting of test cases corresponding to the target key input parameter subsets not included as a third test case set; The third test case set and the second test case set are merged to obtain the target test case set.

3. The method according to claim 1, characterized in that The method further comprises: Obtain at least one initial input parameter, an initial expected result, and a test case generation formula; Performing attribute extraction on the at least one initial input parameter and the at least one initial expected result respectively to obtain at least one input parameter and at least one expected result that are different from each other; The first test case set is generated using the test case generation formula, the at least one input parameter, and the at least one expected result.

4. The method according to claim 3, characterized in that The attributes of each of the initial input parameters include public attributes and private attributes, and the attributes of each of the initial expected results include public attributes and private attributes; The extracting attributes of the at least one initial input parameter and the at least one initial expected result respectively to obtain at least one input parameter and at least one expected result that are different from each other includes: Extracting public attributes of the at least one initial input parameter to obtain different public attributes; extracting private attributes of the at least one initial input parameter to obtain different private attributes; and determining the different public attributes and the different private attributes as at least one input parameter; Extracting the public attributes of the at least one initial expected result to obtain different public attributes; extracting the private attributes of the at least one initial expected result to obtain different private attributes; and determining the different public attributes and the different private attributes as at least one expected result.

5. The method according to claim 3, characterized in that The test case generation formula includes taking a union, and generating the first test case set by using the test case generation formula, the at least one input parameter, and the at least one expected result includes: determining all combinations of the at least one input parameter and the at least one expected result; Taking a union of the input parameters included in each combination in the full combination to obtain a first result; Taking the union of the expected results included in each combination to obtain a second result; Taking a union of the first result and the second result to obtain a first test case corresponding to each combination; Each of the first test cases is used to form the first test case set.

6. The method according to any one of claims 1 to 5, characterized in that Determining a target expected result set and a target key input parameter set according to the first test case set includes: Screening the expected result sets in the first test case set, and determining the obtained different expected result sets as target expected result sets; The key input parameter subsets in the first test case set are screened, and the obtained different key input parameter subsets are determined as target key input parameter sets.

7. The method according to claim 6, characterized in that The screening of the expected result sets in the first test case set and determining the obtained different expected result sets as target expected result sets includes: Filtering out an expected result set from a plurality of identical expected result sets in the first test case set as a first expected result set; Filtering out other mutually different expected result sets except the multiple identical expected result sets from the first test case set as second expected result sets; The first expected result set and the second expected result set are merged to obtain a target expected result set.

8. The method according to claim 7, characterized in that The step of selecting an expected result set from a plurality of identical expected result sets in the first test case set as the first expected result set includes: Determine the number of the test case corresponding to each of the plurality of identical expected result sets; determine the expected result set corresponding to the test case with the smallest number as the first expected result set; or, Any expected result set among the multiple identical expected result sets is determined as a first expected result set.

9. A test case generating device, characterized in that: The device comprises: A first acquisition module is configured to acquire a first test case set; the first test case set includes a plurality of test cases; each of the test cases includes an input parameter set and an expected result set; each of the input parameter sets includes a key input parameter subset consisting of key input parameters; the key input parameters are input parameters whose correlation with at least one expected result in the expected result set is greater than a preset threshold; a screening module, configured to determine, based on the first set of test cases, a target expected result set and a target key input parameter set; wherein the target expected result set includes a plurality of target expected result subsets, and the target key input parameter set includes a plurality of target key input parameter subsets; A first determining module is configured to determine a set consisting of test cases corresponding to each target expected result subset in the target expected result set as a second test case set; The second determining module is configured to use the second test case set as the target test case set if it is determined that the second test case set includes each target key input parameter subset in the target key input parameter set.

10. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, wherein: When the processor executes the program, the steps in the test case generation method according to any one of claims 1 to 8 are implemented.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the test case generation method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Testing method and device

    CN107402878A

  • Test case automatic generation method and device, terminal and storage medium

    CN110334009A