A method and device for generating test cases
By automatically generating streamlined test cases and using equivalent class division rules to cover the characteristics of real business data, the problems of long test time and low coverage in software testing are solved, and efficient software testing is achieved.
Patent Information
- Application Number
- CN202111386016.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-22
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2041-11-22
AI Technical Summary
The prior art has problems such as long test time and low test coverage in software testing, which is difficult to meet the needs of rapid iteration of software versions.
By receiving software testing requests, we determine test cases that match the software identification, and automatically generate streamlined test cases using equivalent class division rules, thereby covering the characteristics of real business data and shortening the test time.
It has achieved the improvement of software testing efficiency, shortened test cycles, and ensured test coverage, thus solving the problems of long test time and low coverage in the prior art.
Smart Images

Figure CN113986762B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of software testing technology, and in particular to a method and device for generating a test case. Background Art
[0002] With the rapid development of Internet technology, in order to meet various business needs, the development of various types of software is gradually increasing. So, in order to ensure that the software (such as trading software or payment software) can run normally and efficiently after going online, it is usually necessary to test the various indicators of the software before the software goes online, or after updating a certain function or several functions of the software, it is also necessary to test. At the same time, some test cases are needed when testing the software. Based on this, when determining the test cases required for software testing, in order to ensure that the test cases can cover the real business scenarios of the software in the production environment, how to reasonably and effectively determine the test cases has become an urgent problem to be solved.
[0003] At present, there are usually two types of test cases for regression testing of software: the first type is simulation data, which is data generated by testers based on input variables, and the test case generation methods used are such as orthogonal test case design method or uniform test case design method; the second type is complete real data. However, if simulation data is used to perform regression testing on software, the test will exit abnormally due to the high coupling degree between artificially generated test data and parameters. At the same time, if complete real data is used to perform regression testing on software, it will take a long time to test, making it difficult for this method to meet the needs of rapid iteration of software versions.
[0004] In summary, there is an urgent need for a test case generation method to effectively improve the efficiency of software testing. Summary of the invention
[0005] The embodiment of the present invention provides a method and device for generating a test case, so as to effectively improve the efficiency of software testing.
[0006] In a first aspect, an embodiment of the present invention provides a method for generating a test case, comprising:
[0007] Receiving a test request for any software; the test request includes a software identifier;
[0008] Determine at least one test case that matches the software identifier; the at least one test case is generated by determining business data that meets the at least one equivalence class division rule that matches the software identifier from a business database; each equivalence class division rule corresponding to the software identifier is generated by analyzing each business field of the business data that serves as input and corresponds to each output file type associated with the software identifier;
[0009] Perform regression testing on the software corresponding to the software identifier through the at least one test case.
[0010] In the above technical solution, by analyzing the real business data corresponding to each output file type associated with any software identifier as input, that is, analyzing the distribution characteristics of the real business data corresponding to each output file type as input, the equivalence class division rules corresponding to each output file type can be automatically generated, without using the equivalence class division method for the real business data corresponding to each business field, so that it can be avoided that the traditional equivalence class division method cannot be directly used when facing real business data with high data dimensions, so that the streamlined number of test cases determined based on the equivalence class division rules corresponding to each output file type can well cover the characteristics of the real business data, so that the coverage of the test cases can be ensured, and the execution time consumed by the software during testing can be greatly shortened. Specifically, when receiving a test request for any software, at least one test case matching the software identifier can be automatically determined, and the software corresponding to the software identifier can be regression tested through the at least one test case. In this way, since the scheme automatically generates a streamlined number of test cases for regression testing of the software corresponding to the software identifier through the equivalence class division rules corresponding to the software identifier, without requiring complete real business data as test cases for software testing, the software testing cycle can be greatly shortened, thereby effectively improving the efficiency of software testing, and further effectively solving the problems of long testing time and low test coverage in the prior art.
[0011] Optionally, determining at least one test case matching the software identifier includes:
[0012] Determine at least one equivalence class division rule matching the software identifier from an equivalence class division rule library;
[0013] According to each equivalence class division rule, query the business data that meets the equivalence class division rule from the business database, and randomly select a set number of business data from the business data that meets the equivalence class division rule;
[0014] A set amount of business data corresponding to each of the at least one equivalence class division rules is used as a test case.
[0015] In the above technical scheme, when testing a certain software, at least one equivalence class division rule corresponding to the software can be matched in real time from the equivalence class division rule library, and the business data that meets the at least one equivalence class division rule can be automatically determined from the business database, and at the same time, for the business data of each equivalence class division rule, a set number of business data are selected as test cases, so that the generated test cases are streamlined, not complete business data, which can greatly shorten the execution time consumed by the software during testing, and can ensure that the test cases obtained by streamlining can well cover the characteristics of real business data, that is, the output file type of the test cases obtained by streamlining during the test process is consistent with the output file type of the real business data in the actual application environment. In addition, the scheme uses the equivalence class division rule library to uniformly manage the equivalence class division rules, which can facilitate the generation of test cases for the software through the equivalence class division rule library in a timely manner when testing any software.
[0016] Optionally, before receiving a test request for any software, the method further includes:
[0017] For any software, determine each equivalence class division rule corresponding to the software from the equivalence class division rule library;
[0018] According to each equivalence class division rule, query the business data that meets the equivalence class division rule from the business database, and randomly select a set number of business data from the business data that meets the equivalence class division rule;
[0019] Using a set amount of business data corresponding to each of the at least one equivalence class division rules as a test case;
[0020] Store the test cases corresponding to each software into the test case set;
[0021] Determining at least one test case matching the software identifier includes:
[0022] At least one test case matching the software identifier of the software is determined from the test case set.
[0023] In the above technical solution, before testing any software, the test cases of each software are generated in advance by dividing the rule base according to the equivalence class, and the test cases of each software are stored in the test case set. When it is necessary to test a certain software, the test cases of the software can be directly matched from the test case set, wherein the test cases of each software generated in advance can well cover the characteristics of the corresponding real business data, and at the same time, the test cases of each software generated in advance are streamlined. In this way, the solution can timely and effectively obtain the test cases of the software to test the software, and can greatly shorten the execution time consumed by the software during the testing process.
[0024] Optionally, the equivalence class division rule base is determined in the following manner:
[0025] For any software, determining each output file type of the software;
[0026] For each output file type, obtaining business data corresponding to the output file type as input from the business database;
[0027] Determine each key field and the value of each key field from each business field of the business data, and generate an equivalence class division rule corresponding to the output file type based on each key field and the value of each key field;
[0028] The equivalence class division rules corresponding to each output file type of the software are stored in the equivalence class division rule library.
[0029] In the above technical solution, for any software, by analyzing the business fields in the business data corresponding to each output file type of the software, an equivalence class division rule library can be automatically constructed, so that the equivalence class division rules can be uniformly managed by using the equivalence class division rule library. In this way, when testing any software, it is convenient to automatically generate test cases for the software through the equivalence class division rule library in a timely manner.
[0030] Optionally, acquiring the business data corresponding to the output file type as input from the business database includes:
[0031] Determine the data primary key identifier corresponding to the output file type;
[0032] Based on the data primary key identifier, the corresponding business data as input is matched from the business database.
[0033] In the above technical solution, through the data primary key identifier corresponding to each output file type of any software, the business data corresponding to the output file type as input can be matched from the business database in a timely and accurate manner, so as to provide data support for generating the equivalence class division rules corresponding to the output file type.
[0034] Optionally, the generating, based on the key fields and the values of the key fields, an equivalence class division rule corresponding to the output file type includes:
[0035] Processing the business data corresponding to the output file type as input through an information entropy algorithm to determine at least one first key field corresponding to the output file type and determine a value of the at least one first key field;
[0036] Determine at least one second key field corresponding to the output file type according to the business scenario associated with the output file type, and determine a value of the at least one second key field;
[0037] The at least one first key field and the value of the at least one first key field are associated with the at least one second key field and the value of the at least one second key field to generate an equivalence class division rule corresponding to the output file type.
[0038] In the above technical solution, by adopting the information entropy algorithm, the business data corresponding to each output file type as input is analyzed and processed, and at least one first key field and the respective values of the at least one first key field can be accurately determined. At the same time, since in each output file type, there are some business data that present different business characteristics with different business scenarios, the at least one second key field corresponding to the output file type and the value of the at least one second key field can be analyzed and determined through the business scenario involved in the output file type. Then, by associating at least one first key field, the value of at least one first key field, and at least one second key field, the value of at least one second key field, the equivalence class division rules required for software testing can be accurately generated.
[0039] Optionally, the processing of the business data corresponding to the output file type as input by an information entropy algorithm to determine at least one first key field corresponding to the output file type includes:
[0040] For each business field in the business data used as input corresponding to the output file type, determining the information entropy of the business field by using an information entropy algorithm;
[0041] If the information entropy of the service field meets a preset information entropy threshold, the service field is determined as a first key field.
[0042] In the above technical solution, by adopting the information entropy algorithm, the information entropy of each business field in the business data corresponding to each output file type can be accurately determined, and by comparing the information entropy of each business field with the preset information entropy threshold, the first key field with a greater impact on the business data can be accurately determined. In this way, the solution can help to eliminate some business fields with less impact, thereby reducing the amount of business data used when testing the software without the need for complete real business data, thereby reducing the amount of business data required when testing the software, and helping to shorten the execution time consumed when testing the software.
[0043] In a second aspect, an embodiment of the present invention further provides a test case generation device, comprising:
[0044] A receiving unit, configured to receive a test request for any software; the test request includes a software identifier;
[0045] A processing unit is used to determine at least one test case that matches the software identifier; the at least one test case is generated by determining business data that meets the at least one equivalence class division rule that matches the software identifier from a business database; each equivalence class division rule corresponding to the software identifier is generated by analyzing each business field of the business data used as input corresponding to each output file type associated with the software identifier; and regression testing is performed on the software corresponding to the software identifier through the at least one test case.
[0046] Optionally, the processing unit is specifically configured to:
[0047] Determine at least one equivalence class division rule matching the software identifier from an equivalence class division rule library;
[0048] According to each equivalence class division rule, query the business data that meets the equivalence class division rule from the business database, and randomly select a set number of business data from the business data that meets the equivalence class division rule;
[0049] A set amount of business data corresponding to each of the at least one equivalence class division rules is used as a test case.
[0050] Optionally, the processing unit is further configured to:
[0051] Before receiving a test request for any software, for any software, determining each equivalence class division rule corresponding to the software from an equivalence class division rule library;
[0052] According to each equivalence class division rule, query the business data that meets the equivalence class division rule from the business database, and randomly select a set number of business data from the business data that meets the equivalence class division rule;
[0053] Using a set amount of business data corresponding to each of the at least one equivalence class division rules as a test case;
[0054] Store the test cases corresponding to each software into the test case set;
[0055] The processing unit is specifically used for:
[0056] At least one test case matching the software identifier of the software is determined from the test case set.
[0057] Optionally, the processing unit is specifically configured to:
[0058] For any software, determining each output file type of the software;
[0059] For each output file type, obtaining business data corresponding to the output file type as input from the business database;
[0060] Determine each key field and the value of each key field from each business field of the business data, and generate an equivalence class division rule corresponding to the output file type based on each key field and the value of each key field;
[0061] The equivalence class division rules corresponding to each output file type of the software are stored in the equivalence class division rule library.
[0062] Optionally, the processing unit is specifically configured to:
[0063] Determine the data primary key identifier corresponding to the output file type;
[0064] Based on the data primary key identifier, the corresponding business data as input is matched from the business database.
[0065] Optionally, the processing unit is specifically configured to:
[0066] Processing the business data corresponding to the output file type as input through an information entropy algorithm to determine at least one first key field corresponding to the output file type and determine a value of the at least one first key field;
[0067] Determine at least one second key field corresponding to the output file type according to the business scenario associated with the output file type, and determine a value of the at least one second key field;
[0068] The at least one first key field and the value of the at least one first key field are associated with the at least one second key field and the value of the at least one second key field to generate an equivalence class division rule corresponding to the output file type.
[0069] Optionally, the processing unit is specifically configured to:
[0070] For each business field in the business data used as input corresponding to the output file type, determining the information entropy of the business field by using an information entropy algorithm;
[0071] If the information entropy of the service field meets a preset information entropy threshold, the service field is determined as a first key field.
[0072] In a third aspect, an embodiment of the present invention provides a computing device, comprising at least one processor and at least one memory, wherein the memory stores a computer program, and when the program is executed by the processor, the processor executes any test case generation method described in the first aspect above.
[0073] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing a computer program executable by a computing device, wherein when the program runs on the computing device, the computing device executes any test case generation method described in the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0075] Figure 1 A flow chart of a method for generating a test case provided by an embodiment of the present invention;
[0076] Figure 2 A schematic diagram of the structure of a test case generation device provided by an embodiment of the present invention;
[0077] Figure 3 A schematic diagram of the structure of a computing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0078] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0079] Figure 1 The flow of a method for generating a test case provided by an embodiment of the present invention is exemplarily shown, and the flow can be executed by a device for generating a test case.
[0080] like Figure 1 As shown in the figure, the process specifically includes:
[0081] Step 101: Receive a test request for any software.
[0082] In an embodiment of the present invention, software testing is usually required before a certain software is adjusted accordingly or a certain new software is launched. Then, when testing the software, a test request for the software will be initiated. The test request for the software includes the software identifier of the software, so that the software testing system can timely and accurately identify the corresponding software based on the software identifier, and can match at least one equivalence class division rule of the software according to the equivalence class division rule library for the software, and the test cases required for testing the software can be automatically generated through the at least one equivalence class division rule.
[0083] For example, before a new software (such as a customer payment application) is launched, or after the configuration or function of a software (such as a customer transaction application) is updated, regression testing needs to be performed on the new software or updated software to ensure that the software can run normally and efficiently when it is officially used. For example, taking software A as an example, after some functions of software A are updated, a test request can be sent to the software testing system for the updated software A, so that the software testing system can use some test cases to perform regression testing on software A.
[0084] Step 102: Determine at least one test case that matches the software identifier.
[0085] In an embodiment of the present invention, at least one test case is generated by determining business data that meets at least one equivalence class division rule from a business database based on at least one equivalence class division rule that matches the software identifier; each equivalence class division rule corresponding to the software identifier is generated by analyzing each business field of the business data used as input corresponding to each output file type associated with the software identifier.
[0086] Specifically, when determining at least one test case matching the software identifier, the first method is to generate the test case in real time when testing the software, and the second method is to generate the test case of the software in advance and directly obtain it when the software needs to be tested. For the first method, when testing the software corresponding to the software identifier, at least one equivalence class division rule matching the software identifier can be determined in real time from the equivalence class division rule library, and according to each equivalence class division rule, the business data that meets the equivalence class division rule is queried from the business database, and a set number of business data is selected from the business data that meets the equivalence class division rule in a random manner. Then, the set number of business data corresponding to at least one equivalence class division rule is used as a test case. In this way, the generated test case is streamlined, not complete business data, so that the execution time consumed by the software during testing can be greatly shortened, and it can be ensured that the test case obtained by streamlining can well cover the characteristics of the real business data, that is, the output file type of the test case obtained by streamlining during the test process is consistent with the output file type of the real business data in the actual application environment. For the second method, before receiving a test request for any software, for any software, determine the equivalence class division rules corresponding to the software from the equivalence class division rule library, and according to each equivalence class division rule, query the business data that meets the equivalence class division rule from the business database, and select a set number of business data from the business data that meets the equivalence class division rule in a random manner. Then, the set number of business data corresponding to at least one equivalence class division rule is used as a test case, and the test case corresponding to each software is stored in the test case set. When it is necessary to test a certain software, at least one test case corresponding to the software identifier can be directly matched from the test case set. Among them, the test cases of each software generated in advance can well cover the characteristics of the corresponding real business data, and at the same time, the test cases of each software generated in advance are streamlined. In this way, the solution can timely and effectively obtain the test cases of the software to test the software, and can greatly shorten the execution time consumed by the software during the test process.
[0087] Among them, the equivalence class division rule base can be determined in the following manner: for any software, each output file type of the software can be determined, and for each output file type, the business data corresponding to the output file type as input can be obtained from the business database. Then, each key field and the value of each key field are determined from each business field of the business data, and based on each key field and the value of each key field, the equivalence class division rule corresponding to the output file type can be accurately generated. Then, the equivalence class division rules corresponding to each output file type of the software can be stored in the equivalence class division rule base. In this way, by analyzing the business fields in the business data corresponding to each output file type of any software, the equivalence class division rule base can be automatically constructed, so that the equivalence class division rules can be uniformly managed by using the equivalence class division rule base, so that when testing any software, the test cases of the software can be automatically generated in time through the equivalence class division rule base.
[0088] In addition, when the business data corresponding to the output file type can be obtained from the business database as input, the data primary key identifier corresponding to the output file type is first determined, and then based on the data primary key identifier, the business data corresponding to the output file type as input can be matched from the business database in a timely and accurate manner, so as to provide data support for generating equivalence class division rules corresponding to the output file type.
[0089] Among them, when generating the equivalence class division rule corresponding to the output file type, by using the information entropy algorithm, the business data corresponding to the output file type as input is processed, and at least one first key field corresponding to the output file type can be accurately determined, and the value of the at least one first key field can be determined. At the same time, since in each output file type, there are some business data that present different business characteristics with different business scenarios, therefore, through the business scenario associated with the output file type, at least one second key field corresponding to the output file type can be accurately determined, and the value of the at least one second key field can be determined. Then, by associating at least one first key field, at least one first key field value, and at least one second key field, at least one second key field value, the equivalence class division rule required for software testing can be accurately generated.
[0090] Furthermore, when determining at least one first key field corresponding to the output file type, by using an information entropy algorithm, each business field in the business data corresponding to the output file type as input is processed, and the information entropy of each business field can be determined, and by comparing the information entropy of each business field with a preset information entropy threshold, if the information entropy of the business field meets the preset information entropy threshold, the business field can be determined as the first key field. In this way, the scheme can accurately determine the first key field with a greater impact on the business data, and at the same time help to eliminate some business fields with less impact, so that the amount of business data used when testing the software can be reduced without the need for complete real business data, thereby reducing the amount of business data required when testing the software, and helping to shorten the execution time consumed when testing the software. Among them, the preset information entropy threshold can be set according to the experience of those skilled in the art, or can be set according to the actual application scenario, and the embodiment of the present invention is not limited to this.
[0091] Exemplarily, when automatically generating an equivalence partitioning class rule base, for any software, first, according to the output files of different output file types of the software, the real data of the data source table is inverted and queried to obtain a data set with an output file type label. Then, the equivalence class partitioning rules corresponding to each output file type are generated respectively, and the equivalence class partitioning rules corresponding to each output file type are stored in an equivalence class partitioning rule base. Among them, in order to evaluate the influence of the value of each business field on the data, the information entropy algorithm is used to determine the information entropy of each business field in the business data associated with the same output file type. Assume that the proportion of k value samples of the i-th business field in the sample set D composed of output file type 1 is p(k). According to the definition of information entropy, the higher the set purity, the lower the information entropy. Therefore, the lower the information entropy, the greater the influence of the business field on the output file type, so the business field with an information entropy lower than the preset information entropy threshold (such as the information entropy average) can be selected as a key field to determine whether a business data will enter the output file of output file type 1. Among them, the calculation formula of information entropy satisfies the following form:
[0092]
[0093] Among them, H(i) is used to represent the information entropy of any business field of any output file type, and p(k) is used to represent the probability of occurrence of each value in the business field, that is, the ratio of the number of occurrences of a certain value in the business field to the total number of occurrences of all values in the business field.
[0094] The above formula can be used to calculate the key fields corresponding to each output file type of the software. For example, as shown in Table 1, the key fields of each output file type of the software are shown, and the values in brackets are the values of the key fields. For example, the key fields of output file type 1 are: business field 3, and the values of business field 3 are c1 and c2; business field 6, and the value of business field 6 is f1. It should be noted that Table 1 is only a simple example for the convenience of explaining the technical solution in the embodiment of the present invention, and does not constitute a limitation on the technical solution in the embodiment of the present invention.
[0095] Table 1
[0096]
[0097]
[0098]
[0099] After determining the key fields (i.e., the first type of key fields) corresponding to each output file type of a certain software in the above manner, the business data extracted by the first type of key fields can be output to the output file of the corresponding output file type. In addition, since in each output file type, there are some business data that present different business characteristics with different business scenarios, the second type of key fields can be analyzed and determined by the business scenarios involved in the output file type. Moreover, from the perspective of the integrity of software testing, the second type of key fields should also be included in the business rules of output file type 1. The equivalence class partitioning rule base composed of the first type of key fields and the second type of key fields can be used for sampling of real business data. In this way, the regression test for the software can not only cover all output file types, but also cover different business scenarios corresponding to each output file type, so that the real business data extracted according to the new rules can better cover the characteristics of the real business data, and finally the business rule set of all output file types can be obtained, i.e., R={R1, R2, ..., Rn}, and the business rule set R constitutes the equivalence class partitioning rule base. For example, the business scenario associated with output file type 1 involves business field 1, that is, business field 1 is a parameter directly related to the business scenario of output file type 1. Therefore, business field 1 needs to be added to business rule R1 (that is, equivalence class division rule). In this way, business rule R1 of output file type 1 is: business field 1 takes all values; business field 3 takes c1, c2; business field 6 takes f1.
[0100] Then, the equivalence class partitioning rule base generated in the above manner can complete the random sampling of real business data in turn, and integrate the determined random samples to obtain a complete test data set for regression testing, so that the coverage for each output file type can be calculated. If there are a small number of output file types that are not covered, or other test scenarios require it, you can manually add business rules to the equivalence class partitioning rule base, and then re-execute the generation of streamlined test cases.
[0101] As an example, when a certain software (such as software A) needs to be tested, the output file types of the software A are classified, and the business data of each output file type as input is obtained from the business database based on the data primary key identifier corresponding to each output file type. At the same time, the business data corresponding to each output file type is marked with an output file type label. At the same time, corresponding business data can be obtained from the business database based on other business data features to supplement the field information of the output file type, and a test data set as shown in Table 2 can be obtained.
[0102] Table 2
[0103]
[0104] For any output file type in Table 2, by using the information entropy algorithm, each business field in the business data corresponding to the output file type is analyzed and processed to determine the information entropy of each business field. For example, for output file type 1, when calculating the information entropy of business field 1, there are 6 values in business field 1, each of which has only 1 value, so p(k) = 1 / 6 for each value, then the information entropy of business field 1 can be calculated as Similarly, H(2)=0, H(3)=0, etc. can be calculated. By comparing the information entropy of each business field with the preset information entropy threshold (such as the information entropy average value), it can be determined that the information entropy of business field 2, business field 3, and business field 6 is less than the information entropy average value. Therefore, business field 2, business field 3, and business field 6 can be selected as the first type of key fields of output file type 1. At the same time, according to the business scenario associated with output file type 1, it can be determined that business field 1 is a parameter directly related to the business scenario of output file type 1, so it is necessary to add business field 1 to the business rules corresponding to output file type 1 (i.e., equivalence class division rules). In this way, the business rules of output file type 1 finally obtained are a={a1, a2,…, a6}, b={b1}, c={c1}, f={f3}. Similarly, the business rules of other output file types can be determined by the above method, so the business rules of each output file type can together form an equivalence class division rule library.
[0105] Then, each equivalence classification rule in the equivalence classification rule library that matches the software identifier of the software A is traversed, and a certain amount of business data is randomly extracted from the business database as test cases. For example, for the business rules of output file type 1 (i.e., equivalence class division rules): a={a1,a2,…,a6}&&b={b1}&&c={c1}&&={f3}, business data that meets the business rules are queried from the business database, and a certain number of business data are randomly selected as test cases. For example, the first query condition is a={a1}&&b={b1}&&c={c1}&&={f3}, the second query condition is a={a2}&&b={b1}&&c={c1}&&={f3}, the third query condition is a={a3}&&b={b1}&&c={c1}&&={f3}, etc. In this way, business data that meets the query condition can be queried through each query condition, and 10 business data are randomly selected from the business data queried by each query condition as test cases and added to the test case collection of output file type 1. Similarly, by following the above method, a subset of test cases for other output file types can be obtained, and a subset of test cases for each output file type can be integrated into the test case set corresponding to software A. In this way, through this solution, a certain amount of business data (such as 50,000 business data) can be extracted from the real business data corresponding to software A (such as 500 million business data) through at least one equivalence class division rule corresponding to software A to be used as a test case, and regression testing can be performed on software A in a test environment. Then, under the premise of ensuring test coverage, the execution time consumed when using test cases for software testing can be greatly shortened. In addition, regression testing of the software can be performed based on the real business data in the streamlined test case set, and coverage for each output file type can be obtained. If there is a small amount of output file type that is not covered, equivalence class division rules can also be added manually, and streamlined test cases can be regenerated after adding. It should be noted that if there is a specific demand for the scale of test data, the number of random extractions corresponding to each output file type can be adjusted, and the streamlined test case set of the software can be regenerated after adjustment.
[0106] Step 103: Perform regression testing on the software corresponding to the software identifier through the at least one test case.
[0107] In an embodiment of the present invention, regression testing is performed on the software corresponding to the software identifier through at least one test case of the software corresponding to the software identifier determined as above, so as to obtain the test results. At the same time, it can be determined whether the software corresponding to the software identifier can be put into use in a production environment based on the test results.
[0108] The above embodiment shows that by analyzing the real business data corresponding to each output file type associated with any software identifier as input, that is, analyzing the distribution characteristics of the real business data corresponding to each output file type as input, the equivalence class division rules corresponding to each output file type can be automatically generated, without using the equivalence class division method for the real business data corresponding to each business field, so that it can be avoided that the traditional equivalence class division method cannot be directly used when facing real business data with high data dimensions, so that the streamlined number of test cases determined by the equivalence class division rules corresponding to each output file type can well cover the characteristics of the real business data, so that the coverage of the test cases can be ensured, and the execution time consumed by the software during testing can be greatly shortened. Specifically, when receiving a test request for any software, at least one test case matching the software identifier can be automatically determined, and the software corresponding to the software identifier can be regression tested through the at least one test case. In this way, since the scheme automatically generates a streamlined number of test cases for regression testing of the software corresponding to the software identifier through the equivalence class division rules corresponding to the software identifier, without requiring complete real business data as test cases for software testing, the software testing cycle can be greatly shortened, thereby effectively improving the efficiency of software testing, and further effectively solving the problems of long testing time and low test coverage in the prior art.
[0109] Based on the same technical concept, Figure 2 An apparatus for generating a test case provided by an embodiment of the present invention is exemplarily shown, and the apparatus can execute the process of a method for generating a test case.
[0110] like Figure 2 As shown, the device comprises:
[0111] The receiving unit 201 is used to receive a test request for any software; the test request includes a software identifier;
[0112] The processing unit 202 is used to determine at least one test case that matches the software identifier; the at least one test case is generated by determining business data that meets the at least one equivalence class division rule that matches the software identifier from a business database; each equivalence class division rule corresponding to the software identifier is generated by analyzing each business field of the business data used as input corresponding to each output file type associated with the software identifier; and regression testing is performed on the software corresponding to the software identifier through the at least one test case.
[0113] Optionally, the processing unit 202 is specifically configured to:
[0114] Determine at least one equivalence class division rule matching the software identifier from an equivalence class division rule library;
[0115] According to each equivalence class division rule, query the business data that meets the equivalence class division rule from the business database, and randomly select a set number of business data from the business data that meets the equivalence class division rule;
[0116] A set amount of business data corresponding to each of the at least one equivalence class division rules is used as a test case.
[0117] Optionally, the processing unit 202 is further configured to:
[0118] Before receiving a test request for any software, for any software, determining each equivalence class division rule corresponding to the software from an equivalence class division rule library;
[0119] According to each equivalence class division rule, query the business data that meets the equivalence class division rule from the business database, and randomly select a set number of business data from the business data that meets the equivalence class division rule;
[0120] Using a set amount of business data corresponding to each of the at least one equivalence class division rules as a test case;
[0121] Store the test cases corresponding to each software into the test case set;
[0122] The processing unit 202 is specifically used for:
[0123] At least one test case matching the software identifier of the software is determined from the test case set.
[0124] Optionally, the processing unit 202 is specifically configured to:
[0125] For any software, determining each output file type of the software;
[0126] For each output file type, obtaining business data corresponding to the output file type as input from the business database;
[0127] Determine each key field and the value of each key field from each business field of the business data, and generate an equivalence class division rule corresponding to the output file type based on each key field and the value of each key field;
[0128] The equivalence class division rules corresponding to each output file type of the software are stored in the equivalence class division rule library.
[0129] Optionally, the processing unit 202 is specifically configured to:
[0130] Determine the data primary key identifier corresponding to the output file type;
[0131] Based on the data primary key identifier, the corresponding business data as input is matched from the business database.
[0132] Optionally, the processing unit 202 is specifically configured to:
[0133] Processing the business data corresponding to the output file type as input through an information entropy algorithm to determine at least one first key field corresponding to the output file type and determine a value of the at least one first key field;
[0134] Determine at least one second key field corresponding to the output file type according to the business scenario associated with the output file type, and determine a value of the at least one second key field;
[0135] The at least one first key field and the value of the at least one first key field are associated with the at least one second key field and the value of the at least one second key field to generate an equivalence class division rule corresponding to the output file type.
[0136] Optionally, the processing unit 202 is specifically configured to:
[0137] For each business field in the business data used as input corresponding to the output file type, determining the information entropy of the business field by using an information entropy algorithm;
[0138] If the information entropy of the service field meets a preset information entropy threshold, the service field is determined as a first key field.
[0139] Based on the same technical concept, the embodiment of the present invention also provides a computing device, such as Figure 3 As shown, it includes at least one processor 301 and a memory 302 connected to the at least one processor. The specific connection medium between the processor 301 and the memory 302 is not limited in the embodiment of the present invention. Figure 3 For example, the processor 301 and the memory 302 are connected via a bus. The bus can be divided into an address bus, a data bus, a control bus, etc.
[0140] In the embodiment of the present invention, the memory 302 stores instructions that can be executed by at least one processor 301. The at least one processor 301 can execute the steps included in the aforementioned test case generation method by executing the instructions stored in the memory 302.
[0141] Among them, the processor 301 is the control center of the computing device, and can use various interfaces and lines to connect various parts of the computing device, and realize data processing by running or executing instructions stored in the memory 302 and calling data stored in the memory 302. Optionally, the processor 301 may include one or more processing units, and the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes the issuance of instructions. It is understandable that the above-mentioned modem processor may not be integrated into the processor 301. In some embodiments, the processor 301 and the memory 302 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on independent chips.
[0142] The processor 301 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the method for generating a test case may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0143] The memory 302 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 302 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 302 is any other medium that can be used to carry or store the desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 302 in the embodiment of the present invention can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0144] Based on the same technical concept, an embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program executable by a computing device. When the program runs on the computing device, the computing device executes the steps of the above-mentioned test case generation method.
[0145] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0146] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0147] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0148] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0149] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0150] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of this application and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for generating a test case, characterized in that: include: Receiving a test request for any software; the test request includes a software identifier; Determining at least one test case that matches the software identifier; The at least one test case is generated by determining business data that meets the at least one equivalence class division rule matched with the software identifier from a business database; each equivalence class division rule corresponding to the software identifier is generated by analyzing each business field of the business data as input corresponding to each output file type associated with the software identifier; Performing regression testing on the software corresponding to the software identifier through the at least one test case; The equivalence class division rules corresponding to the software identifiers are determined in the following manner: For any software, determining each output file type of the software; For each output file type, obtaining business data corresponding to the output file type as input from the business database; Each key field and the value of each key field are determined from each business field of the business data, and based on each key field and the value of each key field, an equivalence class division rule corresponding to the output file type is generated.
2. The method according to claim 1, characterized in that The determining of at least one test case matching the software identifier includes: Determine at least one equivalence class division rule matching the software identifier from an equivalence class division rule library; According to each equivalence class division rule, query the business data that meets the equivalence class division rule from the business database, and randomly select a set number of business data from the business data that meets the equivalence class division rule; A set amount of business data corresponding to each of the at least one equivalence class division rules is used as a test case.
3. The method according to claim 1, characterized in that Before receiving a test request for any software, also include: For any software, determine each equivalence class division rule corresponding to the software from the equivalence class division rule library; According to each equivalence class division rule, query the business data that meets the equivalence class division rule from the business database, and randomly select a set number of business data from the business data that meets the equivalence class division rule; Using a set amount of business data corresponding to each of the at least one equivalence class division rules as a test case; Store the test cases corresponding to each software into the test case set; Determining at least one test case matching the software identifier includes: At least one test case matching the software identifier of the software is determined from the test case set.
4. The method according to claim 2 or 3, characterized in that The equivalence class partitioning rule base is determined in the following manner: The equivalence class division rules corresponding to each output file type of the software are stored in the equivalence class division rule library.
5. The method according to claim 4, characterized in that The acquiring, from the business database, business data corresponding to the output file type as input includes: Determine the data primary key identifier corresponding to the output file type; Based on the data primary key identifier, the corresponding business data as input is matched from the business database.
6. The method according to claim 4, characterized in that The generating, based on the key fields and the values of the key fields, the equivalence class division rules corresponding to the output file type comprises: Processing the business data corresponding to the output file type as input through an information entropy algorithm, determining at least one first key field corresponding to the output file type, and determining a value of the at least one first key field; Determine at least one second key field corresponding to the output file type according to the business scenario associated with the output file type, and determine a value of the at least one second key field; The at least one first key field and the value of the at least one first key field are associated with the at least one second key field and the value of the at least one second key field to generate an equivalence class division rule corresponding to the output file type.
7. The method according to claim 6, characterized in that The step of processing the business data corresponding to the output file type as input by using an information entropy algorithm to determine at least one first key field corresponding to the output file type includes: For each business field in the business data used as input corresponding to the output file type, determining the information entropy of the business field by using an information entropy algorithm; If the information entropy of the service field meets a preset information entropy threshold, the service field is determined as a first key field.
8. A test case generation device, characterized in that: include: A receiving unit, configured to receive a test request for any software; the test request includes a software identifier; A processing unit, configured to determine at least one test case matching the software identifier; the at least one test case is generated by determining business data that meets the at least one equivalence class division rule from a business database based on at least one equivalence class division rule matching the software identifier; each equivalence class division rule corresponding to the software identifier is generated by analyzing each business field of the business data as input corresponding to each output file type associated with the software identifier; and regression testing is performed on the software corresponding to the software identifier through the at least one test case; The processing unit is further used to: for any software, determine each output file type of the software; for each output file type, obtain business data corresponding to the output file type as input from the business database; Each key field and the value of each key field are determined from each business field of the business data, and based on each key field and the value of each key field, an equivalence class division rule corresponding to the output file type is generated.
9. A computing device, characterized in that The method comprises at least one processor and at least one memory, wherein the memory stores a computer program, and when the program is executed by the processor, the processor executes the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: It stores a computer program executable by a computing device, and when the program is run on the computing device, the computing device executes the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for generating test case, computer equipment and storage medium
CN110221960A
Test case generation method and device, equipment and storage medium
CN110750442A