CN113986762A - Test case generation method and device - Google Patents

Test case generation method and device Download PDF

Info

Publication number
CN113986762A
CN113986762A CN202111386016.7A CN202111386016A CN113986762A CN 113986762 A CN113986762 A CN 113986762A CN 202111386016 A CN202111386016 A CN 202111386016A CN 113986762 A CN113986762 A CN 113986762A
Authority
CN
China
Prior art keywords
software
division rule
equivalence class
output file
service
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111386016.7A
Other languages
Chinese (zh)
Inventor
孙书彤
杨晓冬
张剑楠
李蓓璇
于文庆
戎珈
李伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Unionpay Co Ltd
Original Assignee
China Unionpay Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Unionpay Co Ltd filed Critical China Unionpay Co Ltd
Priority to CN202111386016.7A priority Critical patent/CN113986762A/en
Publication of CN113986762A publication Critical patent/CN113986762A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention provides a method and a device for generating test cases. And determining the business data which accords with the at least one equivalence class division rule from a business database based on the at least one equivalence class division rule matched with the software identifier to generate the at least one test case. Therefore, according to the scheme, a reduced number of test cases are automatically generated through each equivalence class division rule corresponding to the software identification and used for performing regression testing on the software corresponding to the software identification, and complete real service data are not needed to be used as the test cases for software testing, so that the period of software testing can be greatly shortened, and the efficiency of software testing can be effectively improved.

Description

Test case generation method and device
Technical Field
The embodiment of the invention relates to the technical field of software testing, in particular to a method and a device for generating a test case.
Background
With the rapid development of internet technology, various kinds of software are developed to meet various business requirements. Then, in order to ensure that software (such as transaction software or payment software) can normally and efficiently run after online, it is usually necessary to perform a test on each index of the software before online, or after a certain function or certain functions of the software are updated, a test is also necessary, and at the same time, some test cases are necessary to perform a test on the software. Therefore, when the test case required by the software test is determined, how to reasonably and effectively determine the test case becomes a problem which needs to be solved urgently in order to ensure that the test case can cover the real service scene of the software in the production environment.
At this stage, the test cases for regression testing of software are generally classified into two types: the first type is simulation data, the simulation data is data generated by testers based on input variables, and the adopted test case generation method is an orthogonal test case design method or a uniform test case design method and the like; the second type is full real data. However, if the simulation data is used for performing the regression test on the software, the coupling degree between the artificially generated test data and the parameters is high, the test may be abnormally exited, and meanwhile, if the complete real data is used for performing the regression test on the software, a long test time needs to be consumed, so that the method is difficult to meet the requirement of fast iteration of the software version.
In summary, a method for generating test cases is needed to effectively improve the efficiency of software testing.
Disclosure of Invention
The embodiment of the invention provides a method and a device for generating a test case, which are used for effectively improving the efficiency of software test.
In a first aspect, an embodiment of the present invention provides a method for generating a test case, where the method includes:
receiving a test request for any software; the test request comprises a software identification;
determining at least one test case matched with the software identifier; the at least one test case is generated by determining service data which accords with the at least one equivalence class division rule from a service database based on the at least one equivalence class division rule matched with the software identifier; each equivalence class division rule corresponding to the software identifier is generated by analyzing each service field which is used as input service data and corresponds to each output file type associated with the software identifier;
and performing regression testing on the software corresponding to the software identification through the at least one test case.
In the above technical solution, by analyzing the real service data as input corresponding to each output file type associated with any software identifier, that is, analyzing the distribution characteristics of the real service data as input corresponding to each output file type, the equivalence class division rule corresponding to each output file type can be automatically generated, without adopting an equivalence class division mode for the real service data corresponding to each service field, the method can avoid that the traditional equivalence class division mode can not be directly applied when facing the real service data with high data dimension, so that the reduced number of test cases determined based on the equivalence class division rule corresponding to each output file type can well cover the characteristics of real service data, therefore, the coverage of the test case can be ensured, and the execution time consumed by the software during testing can be greatly shortened. Specifically, when a test request of any software is received, at least one test case matched with the software identifier can be automatically determined, and regression testing is performed on the software corresponding to the software identifier through the at least one test case. Therefore, according to the scheme, a reduced number of test cases are automatically generated through each equivalence class division rule corresponding to the software identification for regression testing of the software corresponding to the software identification, and complete real service data are not needed to be used as the test cases for software testing, so that the period of software testing can be greatly shortened, the efficiency of software testing can be effectively improved, and the problems of long testing time and low testing coverage in the prior art can be effectively solved.
Optionally, the determining at least one test case matching the software identifier includes:
determining at least one equivalence class division rule matched with the software identifier from an equivalence class division rule base;
inquiring the service data which accords with the equivalence class division rule from the service database according to each equivalence class division rule, and selecting a set number of service data from the service data which accords with the equivalence class division rule in a random mode;
and taking the set number of service data corresponding to the at least one equivalence class division rule as test cases.
In the technical scheme, when a certain software is tested, at least one equivalence class division rule corresponding to the software can be matched from the equivalence class division rule base in real time, and automatically determining the business data meeting the at least one equivalence class division rule from the business database, meanwhile, the set number of service data is selected as the test case aiming at the service data of each equivalence class division rule, so the generated test case is simplified and is not complete service data, therefore, the execution time consumed by the software during testing can be greatly shortened, and the characteristics that the real service data can be well covered by the obtained test case through simplification can be ensured, namely, the output file type of the obtained test case in the testing process is simplified to be consistent with the output file type of the real service data in the actual application environment. In addition, the scheme uniformly manages the equivalence class division rules by using the equivalence class division rule base, so that the generation of the test case of the software can be conveniently performed by the equivalence class division rule base in time when any software is tested.
Optionally, before receiving a test request for any software, the method further includes:
aiming at any software, determining each equivalence class division rule corresponding to the software from an equivalence class division rule base;
inquiring the service data which accords with the equivalence class division rule from the service database according to each equivalence class division rule, and selecting a set number of service data from the service data which accords with the equivalence class division rule in a random mode;
using the set number of service data corresponding to the at least one equivalence class division rule as test cases;
storing the test cases corresponding to the software into a test case set;
determining at least one test case matched with the software identifier, including:
and determining at least one test case matched with the software identifier of the software from the test case set.
In the technical scheme, before any software is tested, the rule base is divided according to the equivalence class, the test cases of each software are generated in advance, the test cases of each software are stored in the test case set, and when a certain software needs to be tested, the test cases of the software can be directly matched from the test case set. Therefore, the scheme can effectively acquire the test case of the software in time to test the software, and can greatly shorten the execution time consumed by the software in the test process.
Optionally, the equivalence class partitioning rule base is determined by:
determining each output file type of any software;
for each output file type, acquiring input business data corresponding to the output file type from the business database;
determining each key field and the value of each key field from each service field of the service data, and generating an equivalence class division rule corresponding to the output file type based on each key field and the value of each key field;
and storing the equivalent class division rule corresponding to each output file type of the software into the equivalent class division rule base.
In the above technical solution, for any software, the service field in the service data corresponding to each output file type of the software is analyzed, so that the equivalence class division rule base can be automatically constructed, and each equivalence class division rule is uniformly managed by using the equivalence class division rule base, so that when any software is tested, the test case of the software can be automatically generated in time through the equivalence class division rule base.
Optionally, the obtaining, from the service database, the service data corresponding to the output file type and serving as an input includes:
determining a data primary key identifier corresponding to the output file type;
and matching corresponding service data serving as input from the service database based on the data primary key identification.
In the above technical solution, through the data primary key identifier corresponding to each output file type of any software, the service data corresponding to the output file type as input can be matched out from the service database accurately in time, so as to provide data support for generating the equivalence class division rule corresponding to the output file type.
Optionally, the generating an equivalence class division rule corresponding to the output file type based on the key fields and the values of the key fields includes:
processing the business data which is used as input and corresponds to the output file type through an information entropy algorithm, determining at least one first key field corresponding to the output file type, and determining the value of the at least one first key field;
determining at least one second key field corresponding to the output file type according to the service scene associated with the output file type, and determining the value of the at least one second key field;
and associating the value of the at least one first key field and the value of the at least one first key field with the value of 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.
In the technical scheme, by adopting an information entropy algorithm and analyzing and processing the business data which is used as input and corresponds to each output file type, the at least one first key field and the value of the at least one first key field can be accurately determined. Meanwhile, in each output file type, the service characteristics of some service data presented along with different service scenes are different, so that 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 according to the service scene related to the output file type. And then, associating the value of the at least one first key field and the value of the at least one first key field with the value of the at least one second key field and the value of the at least one second key field, namely accurately generating the equivalent class division rule required by the software test.
Optionally, the processing, by using an information entropy algorithm, the service data corresponding to the output file type and serving as an input to determine at least one first key field corresponding to the output file type includes:
determining the information entropy of the service field by an information entropy algorithm aiming at each service field in the service data which is used as input and corresponds to the output file type;
and if the information entropy of the service field meets a preset information entropy threshold, determining the service field as a first key field.
In the technical scheme, the information entropy algorithm is adopted, so that the information entropy of each service field in the service data corresponding to each output file type can be accurately determined, and the first key field with larger influence on the service data can be accurately determined by comparing the information entropy of each service field with the preset information entropy threshold. Therefore, the scheme can help to eliminate some service fields with smaller influence, so that the service data volume used in the software testing can be reduced, complete real service data is not needed, the service data volume required in the software testing can be reduced, and the execution time consumed in the software testing can be shortened.
In a second aspect, an embodiment of the present invention further provides a device for generating a test case, where the device includes:
a receiving unit configured to receive a test request for any software; the test request comprises a software identification;
the processing unit is used for determining at least one test case matched with the software identifier; the at least one test case is generated by determining service data which accords with the at least one equivalence class division rule from a service database based on the at least one equivalence class division rule matched with the software identifier; each equivalence class division rule corresponding to the software identifier is generated by analyzing each service field which is used as input service data and corresponds to each output file type associated with the software identifier; and performing regression testing on the software corresponding to the software identification through the at least one test case.
Optionally, the processing unit is specifically configured to:
determining at least one equivalence class division rule matched with the software identifier from an equivalence class division rule base;
inquiring the service data which accords with the equivalence class division rule from the service database according to each equivalence class division rule, and selecting a set number of service data from the service data which accords with the equivalence class division rule in a random mode;
and taking the set number of service data corresponding to the at least one equivalence class division rule as test cases.
Optionally, the processing unit is further configured to:
before a test request aiming at any software is received, aiming at any software, determining each equivalence class division rule corresponding to the software from an equivalence class division rule base;
inquiring the service data which accords with the equivalence class division rule from the service database according to each equivalence class division rule, and selecting a set number of service data from the service data which accords with the equivalence class division rule in a random mode;
using the set number of service data corresponding to the at least one equivalence class division rule as test cases;
storing the test cases corresponding to the software into a test case set;
the processing unit is specifically configured to:
and determining at least one test case matched with the software identifier of the software from the test case set.
Optionally, the processing unit is specifically configured to:
determining each output file type of any software;
for each output file type, acquiring input business data corresponding to the output file type from the business database;
determining each key field and the value of each key field from each service field of the service data, and generating an equivalence class division rule corresponding to the output file type based on each key field and the value of each key field;
and storing the equivalent class division rule corresponding to each output file type of the software into the equivalent class division rule base.
Optionally, the processing unit is specifically configured to:
determining a data primary key identifier corresponding to the output file type;
and matching corresponding service data serving as input from the service database based on the data primary key identification.
Optionally, the processing unit is specifically configured to:
processing the business data which is used as input and corresponds to the output file type through an information entropy algorithm, determining at least one first key field corresponding to the output file type, and determining the value of the at least one first key field;
determining at least one second key field corresponding to the output file type according to the service scene associated with the output file type, and determining the value of the at least one second key field;
and associating the value of the at least one first key field and the value of the at least one first key field with the value of 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.
Optionally, the processing unit is specifically configured to:
determining the information entropy of the service field by an information entropy algorithm aiming at each service field in the service data which is used as input and corresponds to the output file type;
and if the information entropy of the service field meets a preset information entropy threshold, determining the service field as a first key field.
In a third aspect, an embodiment of the present invention provides a computing device, including at least one processor and at least one memory, where the memory stores a computer program, and when the program is executed by the processor, the processor is caused to execute the method for generating a test case according to any of the first aspect.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores a computer program executable by a computing device, and when the program runs on the computing device, the program causes the computing device to execute the method for generating a test case according to any one of the above first aspects.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flow chart of a method for generating a test case according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a test case generation apparatus according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a computing device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 exemplarily shows a flow of a test case generation method provided by an embodiment of the present invention, where the flow may be executed by a test case generation apparatus.
As shown in fig. 1, the process specifically includes:
step 101, a test request for any software is received.
In the embodiment of the invention, before a certain software is correspondingly adjusted or a certain new software is on-line, software testing is usually required, so that when the software is tested, a testing request for the software is initiated, the testing request of the software comprises a software identifier of the software, so that a software testing system can timely and accurately identify the corresponding software based on the software identifier, and at least one equivalence class division rule of the software can be matched according to an equivalence class division rule base aiming at the software, and a testing case required when the software is tested can be automatically generated through the at least one equivalence class division rule.
For example, before a certain new software (such as a customer payment application) is brought online, or after the configuration or function of a certain software (such as a customer transaction application) is updated, a regression test needs to be performed on the brought-online new software or the updated software, so as to ensure that the software can normally and efficiently run in formal use. For example, taking the software a as an example for description, after some functions of the software a are updated, a test request may be sent to the software testing system for the updated software a, so that the software testing system performs a regression test on the software a using some test cases.
And 102, determining at least one test case matched with the software identification.
In the embodiment of the invention, at least one test case is generated by determining the service data which accords with at least one equivalence class division rule from a service database based on at least one equivalence class division rule matched with the software identifier; and each equivalence class division rule corresponding to the software identifier is generated by analyzing each service field of the service data which is used as input and corresponds to each output file type associated with the software identifier.
Specifically, when at least one test case matched with the software identifier is determined, the first mode is a test case generated in real time when the software is tested, and the second mode is a test case generated in advance and directly acquired when the software is required to be tested. For the first mode, when testing the software corresponding to the software identifier, at least one equivalence class division rule matched with the software identifier can be determined from the equivalence class division rule base in real time, the business data meeting the equivalence class division rules is inquired from the business database according to each equivalence class division rule, and meanwhile, a set number of business data are selected from the business data meeting the equivalence class division rules in a random mode. Then, the set number of service data corresponding to at least one equivalence class division rule is used as a test case. Therefore, the generated test case is simplified and is not complete service data, so that the execution time consumed by software in the test can be greatly shortened, and the characteristic that the real service data can be well covered by the simplified test case can be ensured, namely, the output file type of the simplified test case in the test process is consistent with the output file type of the real service data in the actual application environment. For the second mode, before a test request for any software is received, for any software, determining each equivalent class division rule corresponding to the software from an equivalent class division rule base, inquiring service data conforming to the equivalent class division rule from a service database according to each equivalent class division rule, and simultaneously selecting a set number of service data from the service data conforming to the equivalent class division rule in a random mode. Then, the set number of service data corresponding to at least one equivalence class division rule is used as test cases, and the test cases corresponding to each software are stored in a test case set. When a certain software needs to be tested, at least one test case corresponding to the software identifier can be directly matched from the test case set. The test cases of each software generated in advance can well cover the characteristics of the corresponding real service data, and meanwhile, the test cases of each software generated in advance are simplified. Therefore, the scheme can effectively acquire the test case of the software in time to test the software, and can greatly shorten the execution time consumed by the software in the test process.
Wherein, the equivalence class division rule base can be determined by the following method: for any software, each output file type of the software can be determined, and for each output file type, the service data corresponding to the output file type can be acquired from the service database as input. And determining each key field and the value of each key field from each service field of the service data, and based on each key field and the value of each key field, accurately generating an equivalence class division rule corresponding to the output file type. Then, the equivalence class division rule corresponding to each output file type of the software can be stored in an equivalence class division rule base. In this way, the equivalence class division rule base can be automatically constructed by analyzing the service field in the service data corresponding to each output file type of any software, so that the equivalence class division rules can be uniformly managed by using the equivalence class division rule base, and the test case of the software can be automatically generated by the equivalence class division rule base in time when any software is tested.
In addition, when the service data corresponding to the output file type can be obtained from the service database as input, the data primary key identifier corresponding to the output file type is determined first, and then based on the data primary key identifier, the service data corresponding to the output file type as input can be matched from the service database timely and accurately, so as to provide data support for generating the equivalence class division rule corresponding to the output file type.
When the equivalence class division rule corresponding to the output file type is generated, the information entropy algorithm is adopted to process the input business data corresponding to the output file type, so that 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 is determined. Meanwhile, in each output file type, the business characteristics of some business data presented along with the difference of the business scenes are different, so that at least one second key field corresponding to the output file type can be accurately determined through the business scene related to the output file type, and the value of the at least one second key field is determined. And then, associating the value of the at least one first key field and the value of the at least one first key field with the value of the at least one second key field and the value of the at least one second key field, namely accurately generating the equivalent class division rule required by the software test.
Furthermore, when at least one first key field corresponding to the output file type is determined, by adopting an information entropy algorithm, processing is performed on each service field in the service data which is used as input and corresponds to the output file type, so that the information entropy of each service field can be determined, and by comparing the information entropy of each service field with a preset information entropy threshold, if the information entropy of the service field meets the preset information entropy threshold, the service field can be determined as the first key field. Therefore, the scheme can accurately determine the first key field with larger influence on the service data and is beneficial to removing some service fields with smaller influence, so that the service data volume used in the software testing can be reduced without complete real service data, the service data volume required in the software testing can be reduced, and the execution time consumed in the software testing can be shortened. The preset information entropy threshold may be set according to experience of a person skilled in the art, or may be set according to an actual application scenario, which is not limited in the embodiment of the present invention.
Illustratively, when an equivalent division classification rule base is automatically generated, for any software, firstly, real data of a data source table is reversely inquired according to output files of different output file types of the software, and a data set with output file type labels is obtained. Then, respectively generating an equivalence class division rule corresponding to each output file type, and storing the equivalence class division rule corresponding to each output file type into an equivalence class division rule base. In order to evaluate the influence degree of the value of each service field on the data, the information entropy of each service field in the service data associated with the same output file type is determined by using an information entropy algorithm. Assume that the proportion of k value samples of the ith traffic field in the sample set D composed of the output file type 1 is p (k). According to the definition of the information entropy, the higher the collection purity is, the lower the information entropy is. Therefore, the lower the information entropy, the greater the influence degree of the service field on the output file type, the service field with the information entropy lower than a preset information entropy threshold (such as an information entropy average) may be selected as a key field for determining whether a piece of service data will enter the output file of the output file type 1. Wherein, the calculation formula of the information entropy satisfies the following form:
Figure BDA0003367056660000121
h (i) is used to indicate the information entropy of any service field of any output file type, and p (k) is used to indicate the probability of each value appearing in the service field, that is, the ratio of the number of a value appearing in the service field to the total number of all values appearing in the service field.
The key fields corresponding to the output file types of the software can be calculated through the formula. For example, as shown in table 1, for the key field of each output file type of the software, the value in the parenthesis is the value of the key field, for example, the key field of the output file type 1 is: a service field 3, wherein the value of the service field 3 is c1 and c 2; traffic field 6, and the value of traffic field 6 is f 1. It should be noted that table 1 is only a simple example, is for convenience of describing the technical solutions in the embodiments of the present invention, and does not limit the technical solutions in the embodiments of the present invention.
TABLE 1
Figure BDA0003367056660000131
Figure BDA0003367056660000141
Figure BDA0003367056660000151
After the key fields (namely the first-class key fields) corresponding to each output file type of a certain software are determined in the above manner, the service data extracted through the first-class key fields can be output to the output files of the corresponding output file types. In addition, because some service data in each output file type present different service features with different service scenes, the second type key fields can be analyzed and determined according to the service scenes related to the output file type. Moreover, from the integrity of software testing, the second type key field should also be included in the business rule of output file type 1. The equivalence class division rule base composed of the first class key field and the second class key field can be used for sampling real service data, so that regression testing for software can cover not only all output file types, but also different service scenes corresponding to each output file type, so that the real service data extracted according to a new rule can better cover the characteristics of the real service data, finally, a service rule set of all output file types can be obtained, namely, R (R) (R1, R2, … …, Rn) is obtained, and the service rule set R forms the equivalence class division rule base. For example, the service scenario associated with the output file type 1 relates to the service field 1, that is, the service field 1 is a parameter directly related to the service scenario of the output file type 1, and therefore the service field 1 needs to be added to the service rule R1 (i.e., the equivalence class division rule), and thus, the service rule R1 of the output file type 1 is: the value of the service field 1 is all the values; the service field 3 takes the values of c1 and c 2; the traffic field 6 takes the value f 1.
Then, by the equivalence class division rule base generated in the above manner, random sampling of real service data can be sequentially completed, and the determined random sampling is integrated to obtain a complete test data set for regression testing, so that the coverage degree for each output file type can be calculated. If a small number of output file types are not covered or other test scenarios are needed, the business rules can be manually supplemented into the equivalence class division rule base, and then the generation of the simplified test case is executed again.
As an example, when a certain software (for example, software a) needs to be tested, output file types are classified for the software a, and the service data of each output file type is obtained from the service database as input based on the data primary key identifier corresponding to each output file type, and meanwhile, an output file type label is marked on the service data corresponding to each output file type, and meanwhile, corresponding service data can be obtained from the service database based on other service data characteristics to supplement the field information of the output file type, so that a test data set as shown in table 2 can be obtained.
TABLE 2
Figure BDA0003367056660000161
For any output file type in table 2, by adopting an information entropy algorithm, each service field in the service data corresponding to the output file type is analyzed, and the information entropy of each service field can be determined. For example, for output file type 1, when calculating the information entropy of service field 1, there are 6 values in service field 1, where each value has only 1, and therefore p (k) of each value is 1/6, then the information entropy of service field 1 can be calculated as
Figure BDA0003367056660000162
Similarly, H (2) ═ 0, H (3) ═ 0, and the like can be calculated, and the information entropy of each service field is compared with a preset information entropy threshold (such as an information entropy average), so that it can be determined that the information entropy of the service fields 2, 3, and 6 is smaller than the information entropy average, and therefore, the service fields 2, 3, and 6 can be selected as the first-class key fields of the output file type 1. Meanwhile, according to the service scenario associated with the output file type 1, it may be determined that the service field 1 is a parameter directly related to the service scenario of the output file type 1, and therefore the service field 1 needs to be added to the service rule (i.e., the equivalence class division rule) corresponding to the output file type 1. Thus, the traffic rule of the finally obtained output file type 1 is a ═ a1, a2, …, a6, b ═ b1, c ═ c1, and f ═ f 3. Similarly, the business of each other output file type can be determined by the methodAnd then, the business rules of all the output file types can jointly form an equivalence class division rule base.
Then, traversing each equivalence class division rule matched with the software identifier of the software A in the equivalence class division rule base, and sequentially randomly extracting a certain amount of service data from the service database as test cases. For example, the business rule (i.e., the equivalence class division rule) for output file type 1: a, 1, a2, …, a6, and b, b1, c1, and f3, querying the service database for service data meeting the service rule, and randomly selecting a certain amount of service data 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} and so on, and thus passes through each query condition, the service data meeting the query condition can be queried, and 10 service data are randomly selected from the service data queried by each query condition and used as test cases to be added into the test case set of the output file type 1. Similarly, test case subsets of other output file types can be obtained according to the above method, and the test case subsets of the output file types are integrated into the test case set corresponding to the software A. Therefore, by the scheme, a certain amount of service data (for example, 5 ten thousand service data) can be extracted from the real service data (for example, 5 hundred million service data) corresponding to the software a by using at least one equivalence class division rule corresponding to the software a to be used as a test case, and a regression test is performed on the software a in a test environment. In addition, regression testing is carried out on the software according to real service data in the simplified test case set, coverage for each output file type can be obtained, if a small number of output file types are not covered, the equivalence class division rule can be manually added, and the simplified test case is regenerated after the equivalence class division rule is added. It should be noted that, if there is a specific requirement for the scale of the test data, the number of random samples corresponding to each output file type may be adjusted, and the simplified test case set of the software may be regenerated after the adjustment.
And 103, performing regression testing on the software corresponding to the software identification through the at least one test case.
In the embodiment of the invention, the regression test is performed on the software corresponding to the software identifier through the determined at least one test case of the software corresponding to the software identifier, so that a test result can be obtained, and whether the software corresponding to the software identifier can be used in a production environment can be determined according to the test result.
The above embodiment shows that by analyzing the real service data as input corresponding to each output file type associated with any software identifier, that is, by analyzing the distribution characteristics of the real service data as input corresponding to each output file type, the equivalence class division rule corresponding to each output file type can be automatically generated, without adopting an equivalence class division mode for the real service data corresponding to each service field, the method can avoid that the traditional equivalence class division mode can not be directly applied when facing the real service data with high data dimension, so that the reduced number of test cases determined based on the equivalence class division rule corresponding to each output file type can well cover the characteristics of real service data, therefore, the coverage of the test case can be ensured, and the execution time consumed by the software during testing can be greatly shortened. Specifically, when a test request of any software is received, at least one test case matched with the software identifier can be automatically determined, and regression testing is performed on the software corresponding to the software identifier through the at least one test case. Therefore, according to the scheme, a reduced number of test cases are automatically generated through each equivalence class division rule corresponding to the software identification for regression testing of the software corresponding to the software identification, and complete real service data are not needed to be used as the test cases for software testing, so that the period of software testing can be greatly shortened, the efficiency of software testing can be effectively improved, and the problems of long testing time and low testing coverage in the prior art can be effectively solved.
Based on the same technical concept, fig. 2 exemplarily shows a test case generation apparatus provided by an embodiment of the present invention, and the apparatus can execute a flow of a test case generation method.
As shown in fig. 2, the apparatus includes:
a receiving unit 201, configured to receive a test request for any software; the test request comprises a software identification;
a processing unit 202, configured to determine at least one test case matching the software identifier; the at least one test case is generated by determining service data which accords with the at least one equivalence class division rule from a service database based on the at least one equivalence class division rule matched with the software identifier; each equivalence class division rule corresponding to the software identifier is generated by analyzing each service field which is used as input service data and corresponds to each output file type associated with the software identifier; and performing regression testing on the software corresponding to the software identification through the at least one test case.
Optionally, the processing unit 202 is specifically configured to:
determining at least one equivalence class division rule matched with the software identifier from an equivalence class division rule base;
inquiring the service data which accords with the equivalence class division rule from the service database according to each equivalence class division rule, and selecting a set number of service data from the service data which accords with the equivalence class division rule in a random mode;
and taking the set number of service data corresponding to the at least one equivalence class division rule as test cases.
Optionally, the processing unit 202 is further configured to:
before a test request aiming at any software is received, aiming at any software, determining each equivalence class division rule corresponding to the software from an equivalence class division rule base;
inquiring the service data which accords with the equivalence class division rule from the service database according to each equivalence class division rule, and selecting a set number of service data from the service data which accords with the equivalence class division rule in a random mode;
using the set number of service data corresponding to the at least one equivalence class division rule as test cases;
storing the test cases corresponding to the software into a test case set;
the processing unit 202 is specifically configured to:
and determining at least one test case matched with the software identifier of the software from the test case set.
Optionally, the processing unit 202 is specifically configured to:
determining each output file type of any software;
for each output file type, acquiring input business data corresponding to the output file type from the business database;
determining each key field and the value of each key field from each service field of the service data, and generating an equivalence class division rule corresponding to the output file type based on each key field and the value of each key field;
and storing the equivalent class division rule corresponding to each output file type of the software into the equivalent class division rule base.
Optionally, the processing unit 202 is specifically configured to:
determining a data primary key identifier corresponding to the output file type;
and matching corresponding service data serving as input from the service database based on the data primary key identification.
Optionally, the processing unit 202 is specifically configured to:
processing the business data which is used as input and corresponds to the output file type through an information entropy algorithm, determining at least one first key field corresponding to the output file type, and determining the value of the at least one first key field;
determining at least one second key field corresponding to the output file type according to the service scene associated with the output file type, and determining the value of the at least one second key field;
and associating the value of the at least one first key field and the value of the at least one first key field with the value of 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.
Optionally, the processing unit 202 is specifically configured to:
determining the information entropy of the service field by an information entropy algorithm aiming at each service field in the service data which is used as input and corresponds to the output file type;
and if the information entropy of the service field meets a preset information entropy threshold, determining the service field as a first key field.
Based on the same technical concept, an embodiment of the present invention further provides a computing device, as shown in fig. 3, including at least one processor 301 and a memory 302 connected to the at least one processor, where a specific connection medium between the processor 301 and the memory 302 is not limited in the embodiment of the present invention, and the processor 301 and the memory 302 are connected through a bus in fig. 3 as an example. The bus may be divided into an address bus, a data bus, a control bus, etc.
In the embodiment of the present invention, the memory 302 stores instructions that can be executed by the at least one processor 301, and the at least one processor 301 can execute the steps included in the foregoing test case generation method by executing the instructions stored in the memory 302.
The processor 301 is a control center of the computing device, and may be connected to various parts of the computing device through various interfaces and lines, and may perform data processing by executing or executing instructions stored in the memory 302 and calling up 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, where the application processor mainly processes an operating system, a user interface, an application program, and the like, and the modem processor mainly processes an issued instruction. It will be appreciated that the modem processor described above 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, or in some embodiments, they may be implemented separately on separate chips.
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, discrete gate or transistor logic, discrete hardware components, or any combination thereof, and may implement or perform the methods, steps, and logic blocks disclosed in the embodiments of the present invention. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the method disclosed in the embodiment of the method for generating a test case may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor.
Memory 302, which is a non-volatile computer-readable storage medium, may 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, and may include, for example, a flash Memory, a hard disk, a multimedia card, a card-type Memory, a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Programmable Read Only Memory (PROM), a Read Only Memory (ROM), a charge Erasable Programmable Read Only Memory (EEPROM), a magnetic Memory, a magnetic disk, an optical disk, and so on. The memory 302 is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The memory 302 of embodiments of the present invention may also be circuitry or any other device capable of performing a storage function to store program instructions and/or data.
Based on the same technical concept, the embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program executable by a computing device, and when the program runs on the computing device, the computer program causes the computing device to execute the steps of the test case generation method.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present application and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A method for generating a test case is characterized by comprising the following steps:
receiving a test request for any software; the test request comprises a software identification;
determining at least one test case matched with the software identifier; the at least one test case is generated by determining service data which accords with the at least one equivalence class division rule from a service database based on the at least one equivalence class division rule matched with the software identifier; each equivalence class division rule corresponding to the software identifier is generated by analyzing each service field which is used as input service data and corresponds to each output file type associated with the software identifier;
and performing regression testing on the software corresponding to the software identification through the at least one test case.
2. The method of claim 1, wherein said determining at least one test case that matches said software identification comprises:
determining at least one equivalence class division rule matched with the software identifier from an equivalence class division rule base;
inquiring the service data which accords with the equivalence class division rule from the service database according to each equivalence class division rule, and selecting a set number of service data from the service data which accords with the equivalence class division rule in a random mode;
and taking the set number of service data corresponding to the at least one equivalence class division rule as test cases.
3. The method of claim 1, prior to receiving a test request for any software, further comprising:
aiming at any software, determining each equivalence class division rule corresponding to the software from an equivalence class division rule base;
inquiring the service data which accords with the equivalence class division rule from the service database according to each equivalence class division rule, and selecting a set number of service data from the service data which accords with the equivalence class division rule in a random mode;
using the set number of service data corresponding to the at least one equivalence class division rule as test cases;
storing the test cases corresponding to the software into a test case set;
determining at least one test case matched with the software identifier, including:
and determining at least one test case matched with the software identifier of the software from the test case set.
4. A method according to claim 2 or 3, wherein the equivalence class partitioning rule base is determined by:
determining each output file type of any software;
for each output file type, acquiring input business data corresponding to the output file type from the business database;
determining each key field and the value of each key field from each service field of the service data, and generating an equivalence class division rule corresponding to the output file type based on each key field and the value of each key field;
and storing the equivalent class division rule corresponding to each output file type of the software into the equivalent class division rule base.
5. The method of claim 4, wherein the obtaining the service data corresponding to the output file type as input from the service database comprises:
determining a data primary key identifier corresponding to the output file type;
and matching corresponding service data serving as input from the service database based on the data primary key identification.
6. The method of claim 4, wherein the generating the equivalence class division rule corresponding to the output file type based on the key fields and values of the key fields comprises:
processing the business data which is used as input and corresponds to the output file type through an information entropy algorithm, determining at least one first key field corresponding to the output file type, and determining the value of the at least one first key field;
determining at least one second key field corresponding to the output file type according to the service scene associated with the output file type, and determining the value of the at least one second key field;
and associating the value of the at least one first key field and the value of the at least one first key field with the value of 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 of claim 6, wherein the determining at least one first key field corresponding to the output file type by processing the service data corresponding to the output file type as input through an information entropy algorithm comprises:
determining the information entropy of the service field by an information entropy algorithm aiming at each service field in the service data which is used as input and corresponds to the output file type;
and if the information entropy of the service field meets a preset information entropy threshold, determining the service field as a first key field.
8. An apparatus for generating a test case, comprising:
a receiving unit configured to receive a test request for any software; the test request comprises a software identification;
the processing unit is used for determining at least one test case matched with the software identifier; the at least one test case is generated by determining service data which accords with the at least one equivalence class division rule from a service database based on the at least one equivalence class division rule matched with the software identifier; each equivalence class division rule corresponding to the software identifier is generated by analyzing each service field which is used as input service data and corresponds to each output file type associated with the software identifier; and performing regression testing on the software corresponding to the software identification through the at least one test case.
9. A computing device comprising at least one processor and at least one memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the method of any of claims 1 to 7.
10. A computer-readable storage medium, storing a computer program executable by a computing device, the program, when run on the computing device, causing the computing device to perform the method of any of claims 1 to 7.
CN202111386016.7A 2021-11-22 2021-11-22 Test case generation method and device Pending CN113986762A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111386016.7A CN113986762A (en) 2021-11-22 2021-11-22 Test case generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111386016.7A CN113986762A (en) 2021-11-22 2021-11-22 Test case generation method and device

Publications (1)

Publication Number Publication Date
CN113986762A true CN113986762A (en) 2022-01-28

Family

ID=79749785

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111386016.7A Pending CN113986762A (en) 2021-11-22 2021-11-22 Test case generation method and device

Country Status (1)

Country Link
CN (1) CN113986762A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116308738A (en) * 2023-02-10 2023-06-23 之江实验室 Model training method, business wind control method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116308738A (en) * 2023-02-10 2023-06-23 之江实验室 Model training method, business wind control method and device
CN116308738B (en) * 2023-02-10 2024-03-08 之江实验室 Model training method, business wind control method and device

Similar Documents

Publication Publication Date Title
US10943181B2 (en) Just in time classifier training
CN112612813B (en) Test data generation method and device
CN111767227A (en) Recording playback test method and device
CN111767350A (en) Data warehouse testing method and device, terminal equipment and storage medium
CN111752846A (en) Interface testing method and device
CN111985930A (en) Client number generation method and device
US11921713B2 (en) Systems and methods for automating mapping of repair procedures to repair information
CN113986762A (en) Test case generation method and device
CN114490413A (en) Test data preparation method and device, storage medium and electronic equipment
CN112882956B (en) Method and device for automatically generating full-scene automatic test cases through data combination calculation, storage medium and electronic equipment
CN112527573B (en) Interface testing method, device and storage medium
CN112801222A (en) Multi-classification method and device based on two-classification model, electronic equipment and medium
CN110177006B (en) Node testing method and device based on interface prediction model
CN110428156B (en) Method and device for checking service data and electronic equipment
CN112069269A (en) Big data and multidimensional feature-based data tracing method and big data cloud server
CN116204396A (en) Test method and device for performance of analytical database
CN114860608A (en) Scene construction based system automation testing method, device, equipment and medium
CN115185833A (en) Abnormal code processing method and device, computer equipment and storage medium
CN114722401A (en) Equipment safety testing method, device, equipment and storage medium
CN116340127A (en) Interface testing method and device
CN113886373A (en) Data processing method and device and electronic equipment
CN111859985A (en) AI customer service model testing method, device, electronic equipment and storage medium
CN112035364A (en) Function test result evaluation method and device
CN113282478A (en) Test data processing method and device
CN112396513B (en) Data processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination