CN115587045A - Test case generation method, device, equipment, storage medium and program product - Google Patents

Test case generation method, device, equipment, storage medium and program product Download PDF

Info

Publication number
CN115587045A
CN115587045A CN202211388067.8A CN202211388067A CN115587045A CN 115587045 A CN115587045 A CN 115587045A CN 202211388067 A CN202211388067 A CN 202211388067A CN 115587045 A CN115587045 A CN 115587045A
Authority
CN
China
Prior art keywords
interface
generating
field
test case
test
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
CN202211388067.8A
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.)
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology Co Ltd
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology 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 Industrial and Commercial Bank of China Ltd ICBC, ICBC Technology Co Ltd filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202211388067.8A priority Critical patent/CN115587045A/en
Publication of CN115587045A publication Critical patent/CN115587045A/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

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 disclosure provides a test case generation method, relates to the technical field of automatic testing, and can be applied to the technical field of financial science and technology. The method comprises the following steps: responding to a generating instruction of the test case, and acquiring an interface standardization document; generating target test data according to the interface standardization file; generating a test case set according to the target test data and the interface standardized document; and outputting the test case set, wherein the interface standardization document comprises an interface table, a rule ID and a business rule. The disclosure also provides a device, equipment, storage medium and program product for generating the test case.

Description

Test case generation method, device, equipment, storage medium and program product
Technical Field
The present disclosure relates to the field of automated testing technologies, and in particular, to the field of interface testing technologies, and in particular, to a method, an apparatus, a device, a storage medium, and a program product for generating a test case.
Background
With the rapid development of staging and service, the back-end test is more and more important, the interface test is intermediate between the interface test and the unit test, the back-end service can be directly tested, the interface test is closer to the code program on the server, the interface test is simpler and faster than the unit test, and the bug with wide influence can be found more easily and is a mainstream test type. Interface test cases are generally written by methods such as equivalence classes, boundary values, cause-effect graphs and the like, but interface fields of a financial system are many and hundreds of interface fields, the writing of the cases is time-consuming and labor-consuming, and a case generation method is urgently needed to release labor power.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
In view of the foregoing, the present disclosure provides a method, an apparatus, a device, a storage medium, and a program product for generating a test case that improve test efficiency.
According to a first aspect of the present disclosure, a method for generating a test case is provided, the method including:
responding to a generation instruction of a test case, and acquiring an interface standardization document;
generating target test data according to the interface standardized document;
generating a test case set according to the target test data and the interface standardized document; and
outputting the test case set to the test system,
wherein the interface standardization document comprises an interface table, a rule ID and a business rule.
According to an embodiment of the present disclosure, the interface table includes a field type, a field length, a field attribute, and an enumerated value, and the generating target test data according to the interface standardized document includes:
generating standardized test data according to the field attribute; and
and modifying the standardized test data according to the field type, the field length, the enumeration value and the service rule to generate target test data.
According to an embodiment of the present disclosure, the generating a test case set according to the target test data and the interface standardization document includes:
generating a test case set from a first field of an interface according to the business rule, the enumerated value, the character type, the character length and the field attribute;
and removing the duplicate of the test case set according to the target test data so as to delete the duplicate cases.
According to the embodiment of the present disclosure, generating a test case set according to the business rule, the enumerated value, the character type, the character length, and the field attribute from a first field of an interface includes;
carrying out case design from a first field of an interface according to the business rule, the enumerated value, the character type, the character length and the field attribute;
generating a test case name and a precondition corresponding to each field according to the interface standardization document;
determining a testing step corresponding to each use case according to the system parameters;
generating an expected result of each use case according to the system parameters and the business rules;
and generating a test case set according to the case design, the test case name, the precondition, the test step and the expected result.
According to an embodiment of the present disclosure, the business rules include linkage rules, independent rules, explanatory rules, output rules of positive examples, and output rules of negative examples.
A second aspect of the present disclosure provides an apparatus for generating a test case, where the apparatus includes:
the acquisition module is used for responding to a generation instruction of the test case and acquiring an interface standardization document;
the first generation module is used for generating target test data according to the interface standardized document;
the second generation module is used for generating a test case set according to the target test data and the interface standardized document; and
an output module for outputting the test case set,
wherein the interface standardization document comprises an interface table, a rule ID and a business rule.
According to an embodiment of the present disclosure, the interface table includes a field type, a field length, a field attribute, and an enumerated value, and the first generation module includes:
the first generation submodule is used for generating standardized test data according to the field attribute; and
and the second generation submodule is used for modifying the standardized test data according to the field type, the field length, the enumeration value and the service rule so as to generate target test data.
According to an embodiment of the present disclosure, the second generating module includes:
a third generation submodule, configured to generate a test case set according to the business rule, the enumerated value, the character type, the character length, and the field attribute from a first field of an interface;
and the duplication elimination submodule is used for carrying out duplication elimination on the test case set according to the target test data so as to delete the repeated cases.
According to an embodiment of the present disclosure, the third generation submodule includes:
the case design unit is used for carrying out case design from a first field of an interface according to the business rule, the enumerated value, the character type, the character length and the field attribute;
the first generating unit is used for generating a test case name and a precondition corresponding to each field according to the interface standardized document;
the second generation unit is used for determining the test step corresponding to each use case according to the system parameters;
the third generating unit is used for generating an expected result of each use case according to the system parameters and the business rules;
and the fourth generating unit is used for generating a test case set according to the case design, the test case name, the precondition, the testing step and the expected result.
A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the above-described method.
A fourth aspect of the present disclosure also provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the above-described method.
A fifth aspect of the disclosure also provides a computer program product comprising a computer program which, when executed by a processor, implements the above method.
According to the method for generating the test case, the target test data is generated through the interface standardization document, the test case set is generated according to the interface table and the business rule in the interface standardization document, and the interface test case set can be generated after the interface definition design is completed. Compared with the method for generating the test case through the interface table in the related technology, the test case generation method provided by the embodiment of the disclosure generates the test case through the interface standardization document, and the interface case covers logic between fields and covers business rules. The labor cost of the testers for inputting the interface test is greatly reduced, the capability requirements of the interface test on the testers are effectively reduced, the use case evaluation cost is reduced due to the standardized use cases, and the test efficiency is improved.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following description of embodiments of the disclosure, taken in conjunction with the accompanying drawings of which:
FIG. 1 is a diagram schematically illustrating an application scenario of a method, an apparatus, a device, a storage medium, and a program product for generating test cases according to an embodiment of the present disclosure;
FIG. 2 is a system architecture diagram schematically illustrating a method for generating test cases according to an embodiment of the present disclosure;
FIG. 3 is a flowchart schematically illustrating a method for generating a test case according to an embodiment of the present disclosure;
FIG. 4 schematically illustrates a flow chart of a method of determination of target test data provided in accordance with an embodiment of the present disclosure;
FIG. 5 schematically shows one of flowcharts of a test case suite generation method provided according to an embodiment of the present disclosure;
FIG. 6 schematically shows a second flowchart of a test case set generation method provided in accordance with an embodiment of the present disclosure;
FIG. 7 is a block diagram schematically illustrating a device for generating test cases according to an embodiment of the present disclosure;
fig. 8 schematically shows a block diagram of an electronic device suitable for implementing a method for generating test cases according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs, unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B, and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B, and C" would include but not be limited to systems that have A alone, B alone, C alone, A and B together, A and C together, B and C together, and/or A, B, and C together, etc.).
In the related art, the method for generating the interface test case roughly includes the following steps: for example, an interface test case is directly generated according to the interface definition information; for example, firstly designing a mind map and then producing a test case according to a defined rule; for example, according to path scanning, a test scene is obtained, and then a test case is generated; for example, the interface use case set is generated according to a pre-designed use case generation template. However, these methods have the following disadvantages:
(1) The method has no universality and is only suitable for a specific interface.
(2) The interface use case does not cover logic between fields.
(3) The interface use case does not cover the rule.
(4) The quality of the use case is uncontrollable, and the efficiency is low.
Based on the above technical problem, an embodiment of the present disclosure provides a method for generating a test case, where the method includes: responding to a generating instruction of the test case, and acquiring an interface standardization document; generating target test data according to the interface standardization file; generating a test case set according to the target test data and the interface standardized document; and outputting the test case set, wherein the interface standardization document comprises an interface table, a rule ID and a business rule.
Fig. 1 schematically illustrates an application scenario diagram of a test case generation method, apparatus, device, storage medium and program product according to an embodiment of the present disclosure.
As shown in FIG. 1, an application scenario 100 according to this embodiment may include an auto-generation scenario of test cases. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have installed thereon various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a test case generation server, which provides an automatic test case generation service, and automatically generates a test case for a received instruction for generating a test case, for example, in response to a test case generation instruction initiated by a user through the terminal devices 101, 102, and 103, the test case generation server generates target test data according to the interface standardized document, and then generates and outputs a test case set.
It should be noted that the test case generation method provided by the embodiment of the present disclosure may be generally executed by the server 105. Accordingly, the test case generation apparatus provided by the embodiment of the present disclosure may be generally disposed in the server 105. The test case generation method provided by the embodiment of the present disclosure may also be executed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the test case generation apparatus provided in the embodiment of the present disclosure may also be disposed in a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for an implementation.
It should be noted that the method and the apparatus for generating the test case determined by the embodiment of the present disclosure may be used in the field of automatic testing technology, may also be used in the field of financial technology, and may also be used in any field other than the field of financial technology.
Fig. 2 is a system architecture diagram schematically illustrating a method for generating a test case according to an embodiment of the present disclosure. The system architecture workflow of the embodiment of the present disclosure is described with reference to fig. 2, and as shown in fig. 2, the system architecture provided by the embodiment of the present disclosure is divided into five modules, including a system parameter management module, a data generation method management module, a standard test data processing module, a test case generation module, and a test case output module, where the system parameter management includes environment configuration, a special character set, a preset security character string, a positive example output rule, a negative example output rule, and a test step. The data generation method mainly comprises the methods of character type, character length, enumeration processing, necessary item input processing, rule processing and the like; the standard test data processing includes standard test data generation and standard test data maintenance functions. The test case generation module generates a test case from the first field of the interface according to the service rule, the enumeration value, the character type, the length and the necessary input sequence, and finally the test case output module outputs the test case to the EXCEL.
The method for generating the test case according to the embodiment of the present disclosure is described in detail below with reference to fig. 3 based on the scenario described in fig. 1 and the system architecture of fig. 2.
Fig. 3 schematically shows a flowchart of a test case generation method provided in an embodiment of the present disclosure. As shown in FIG. 3, the test case generation method of this embodiment includes operations S210 to S240, and the method may be executed by a server or other computing device.
Before explaining the technical solution provided by the embodiment of the present disclosure, the standard for writing a standard case summarized in this embodiment is explained:
1. at least 1 positive case and 1+ N negative cases are contained in each field.
2. The case design method comprises an equivalence class, a boundary value and a causal graph.
3. When the enumerated value exceeds 5, at most 5 positive examples are randomly generated according to the idea of the equivalence class.
4. The use case name is "Chinese name in field (English name in field) + XXX + positive and negative examples", where XXX is the design basis of the use case, such as linkage rule, independent rule, necessary input item, etc.
5. Preconditions are weakened, the preconditions for each field being a field description in the API interface document.
6. The testing steps are weakened and the testing steps are the same for all use cases.
7. The difference of the test case is mainly embodied in case name and test data.
8. If the expected result is not specified in the business rule, the positive example defaults to 'outputting the correct result', and the negative example defaults to 'system prompting error'.
In operation S210, an interface standardization document is acquired in response to a test case generation instruction.
In operation S220, target test data is generated according to the interface standardized document.
In operation S230, a test case set is generated according to the target test data and the interface standardized document.
In operation S240, the test case set is output.
According to an embodiment of the present disclosure, the interface standardization document includes an interface table, a rule ID, and a business rule.
According to the embodiment of the disclosure, the business rules include linkage rules, independent rules, explanatory rules, output rules of positive examples, and output rules of negative examples.
In one example, the interface standardization document is obtained by adding fields such as type supplementary description fields, rule IDs, business rules and the like on the basis of an API interface document, the interface document includes an interface table and business rules, and the general interface table includes interface chinese names, english names, data types, lengths, input/output requirements, enumerated values and the like. The tester can maintain the information of the type supplementary description field, the rule ID, the business rule and the like of the interface standardized form.
The type supplementary notes field includes: 1 represents no letters, 2 represents no numbers, 3 represents no special characters, 4 represents no spaces, and 5 represents no design related cases.
The business rules comprise linkage rules, independent rules, explanatory rules, positive example output rules and negative example output rules, wherein the linkage rules indicate that more than 2 fields have linkage or mutual exclusion relations; different field values are separated by commas, and a plurality of linkage rules are separated by semicolons; for example, when No003 is "0-No", no014 must equal 1000, otherwise the output prompt is "when No003 is" 0-No ", no014 must equal 1000", the rule shows No003= 0-No, no014=1000, output |! = "when No003 is" 0-No ", no014 must be equal to 1000". The independent rules indicate that the field has a specific rule, and a plurality of independent rules are separated by semicolons; such as: the No001 rule generates: the date [8 bits ] + the running number [7 bits ], is expressed as "date [8 bits ] + running number [7 bits ]". The explanatory rules are special explanations for fields and need to be embodied by cases, and a plurality of explanatory rules are separated by semicolons; such as: the field requirement is as follows: the 12-bit serial number, without distinguishing the region, is added with the 4-bit region number in front of the serial number for 16 bits when returning to the CM 2002. The code is directly expressed as "12-bit serial number without distinguishing regions", and when the code is returned to the CM2002, a 4-bit region number is added in front of the serial number for 16 bits ".
In one example, the must-input items of all fields are read first, a piece of standardized use case data is generated, the non-must-input items are all null, and the must-input items are all 1; modifying the value of the standardized test data according to the type and the length of the field, wherein the type is required to be in accordance with, and the length is required to be equal to the maximum length; reading the enumeration value of the field, and modifying the value of the standardized test data; finally, reading the linkage rule of the field, and modifying the standard test data according to the linkage and mutual exclusion rules of the rules between the fields; if the rule is a linkage rule, two values with linkage relation are taken, and if the rule is a mutual exclusion rule, a non-mutual exclusion value is taken as standard test data. The specific generation process of the target test data may be referred to as operation S221 and operation S222 shown in fig. 4.
In one example, a test case is generated from a first field of an interface according to a business rule, an enumerated value, a character type, a length and a necessary input sequence, and the test case is output to excel.
According to the method for generating the test case, the target test data is generated through the interface standardization file, the test case set is generated according to the interface table and the business rule in the interface standardization file, the interface test case set can be generated after the interface definition design is completed, the labor cost of testers for inputting the interface test is greatly reduced, the capability requirements of the interface test on the testers are effectively reduced, the case review cost is reduced due to the standardized case, and the test efficiency is improved.
Fig. 4 schematically shows a flowchart of a method for determining target test data provided according to an embodiment of the present disclosure. As shown in fig. 4, operation S220 includes operations S221 and S222.
In operation S221, standardized test data is generated according to the field attributes.
In operation S222, the standardized test data is modified according to the field type, the field length, the enumeration value, and the business rule to generate target test data.
In one example, a field attribute of a field is used to determine whether the field is a must-fail item, and all fields of the field that are must-fail items are read to generate a piece of standardized test data. And modifying the standardized test data according to the service rule, the field type, the field length and the enumeration value of the interface standardized document.
Specifically, whether a linkage rule exists is judged, and if the linkage rule exists, 1 positive example and 1 negative example are generated; replacing relevant fields in the standard test data by values in the linkage rule; if the business rules contain a plurality of rules, the rules are separated by semicolons to respectively generate test cases; if no linkage rule exists, judging whether an independent rule exists or not, and if the independent rule exists, generating 1 positive example and 1 negative example; replacing the value of the relevant field in the standard test data with the value in the independent rule; if the business rules contain a plurality of rules, the rules are separated by semicolons to respectively generate test cases.
If no independent rule exists, judging whether an explanatory rule exists or not, and if yes, generating 1 positive case and no negative case; replacing the value of the relevant field in the standard test data with the value in the explanatory rule; judging whether an enumeration value exists or not, if so, generating N pieces of arrangement, and 1 counter example; reading all enumerated values of the field, if the enumerated values are less than 5, traversing to generate corresponding number of positive examples, respectively replacing the field values in the standard test data with the enumerated values, if the enumerated values are more than or equal to 5, randomly generating 5 use cases, if the enumerated values are used in the rule cases, skipping the enumerated values, and finally generating 1 counter example.
And then case design is carried out according to the character type and the character length, if the character type is the character type, the character string is randomly generated according to the character length and the type supplementary explanation to form 2 positive examples and 3 negative examples, the positive examples are respectively character type conformity, the length is equal to the maximum length of minus 1, the character conformity and the length is equal to the maximum length of 2 character strings, the negative examples are respectively character nonconformity, the length is equal to the maximum length, the character conformity is realized, the length is greater than the maximum length of plus 1, the character conformity is realized, and the length is equal to the maximum character string plus 100 and 3 character strings. Aiming at the character type use case, a safety use case needs to be supplemented, the character string of the safety verification reads the preset character string in the parameters to generate 1 positive example of the safety verification, and the system can prepare representative test cases with the lengths of 5, 10, 15, 20, 25 and 30 in advance according to the character type and the character length. If the character string is a digital type, generating 3 positive examples and 2 negative examples according to the combination of the length of only an integer, only a decimal, and the integer and the decimal, wherein the positive examples are respectively 6 character strings with the length of only the integer and the length of equal to the maximum length-1 of the integer, the length of only the integer and the length of equal to the maximum length-1 of the decimal, the length of only the decimal and the length of equal to the maximum length-1 of the decimal, the negative examples are respectively character strings with the length of not consistent and the length of equal to the maximum length, the characters are consistent, the character strings with the length of more than the maximum length +1 are consistent, and the character strings with the length of equal to the maximum character strings +100, 0 and the negative number are 5 character strings. If the strain is of a Boolean type; then 2 positive examples and 1 negative example are generated.
Fig. 5 schematically shows one of the flowcharts of the test case suite generation method provided in an embodiment of the present disclosure. Fig. 6 schematically shows a second flowchart of a test case set generation method provided in accordance with an embodiment of the present disclosure. As shown in fig. 5, the operation S230 includes operations S231 to S232.
In operation S231, a test case set is generated from a first field of an interface according to the business rule, the enumerated value, the character type, the character length, and the field attribute.
As shown in fig. 6, the operation S231 includes operations S2311 through S2315.
In operation S2311, case design is performed according to the business rule, the enumerated value, the character type, the character length, and the field attribute from a first field of an interface.
In operation S2312, a test case name and a precondition corresponding to each field are generated according to the interface standardized document.
In operation S2313, a testing procedure corresponding to each use case is determined according to the system parameters.
In operation S2314, an expected result for each use case is generated according to the system parameters and the business rules.
In operation S2315, a test case set is generated according to the case design, the test case name, the preconditions, the testing steps, and the expected results.
In operation S232, the test case set is deduplicated according to the target test data to delete duplicate cases.
In one example, the above-described operational steps are further explained below in conjunction with the api interface document of Table 1.
TABLE 1api interface document
Figure BDA0003929082220000121
S1, firstly, adding field information such as rule ID, business team rule, type supplement description and the like on the basis of an api interface table of an upper table to obtain an interfaced standard table shown in a table 2:
table 2 interfacing standard tables
Figure BDA0003929082220000122
Figure BDA0003929082220000131
S2, automatically generating standard test data according to linkage rules in necessary input items, character types, lengths, enumeration values and business rules; the standardized test data are as follows:
no001: "rule generation: date [8 bit ] + running number [7 bit ] ", and the like
No002:NULL
No003∶0
No004:Y
No005∶1000
And S3, checking and maintaining the standardized test data, wherein the standardized test data is automatically generated to be correct without modification due to the simple rule in the example.
S4, case design is carried out from the first field according to the business rule, the enumerated value, the character type, the length and the necessary input sequence; as shown in table 2, the first field is No001, and it is determined whether or not the field has a linkage rule, no, and then whether or not there is an independent rule, and if yes, 2 test cases, 1 positive case and 1 negative case are generated.
S5, calling a method for generating the use case name to respectively generate the use case name of 'field Chinese 1 (field English 1) -independent rule-positive example', 'field Chinese 1 (field English 1) -independent rule-negative example', and storing the use case name in a use case name list.
S6, calling the method for generating the precondition to respectively generate 2 preconditions, namely reading the re-line remarks: "request sequence number. The rule is 8-bit working date + 7-bit serial number, and is stored in a precondition list.
S7, calling a method for generating test data, reading the standardized test data and writing the standardized test data into the test data of the positive example and the test data of the negative example respectively, and replacing the No001 value of the positive example with a rule to generate: date [8 bits ] + running number [7 bits ] ", the entire entry becomes:
no001: "rule generation: date [8 bits ] + running number [7 bits ]) "
No002:NULL
No003:0
No004:Y
No005∶1000
S8, replacing the No001 value of the counterexample with' unsatisfied rule generation: date [8 bit ] + running number [7 bit ] ", the whole entry becomes
No001: "unsatisfied rule generation: date [8 bits ] + running number [7 bits ]) "
No002:NULL
No003:0
No004;Y
No005∶1000
Stored in a test data list.
S9, calling the general test steps in the read parameters of the method for generating the test steps, such as' 1, access URL: XXXX; 2. a post protocol; 3. see test data 4, send request ", saved in the test step list.
S10, calling a method for generating expected results to generate expected test results of each test case, specifically, reading positive example output in parameters, writing the positive example output into the expected results of the positive example, reading negative example output, writing the negative example output into the expected results of the negative example, wherein the positive example is 'output correct result', the negative example is 'system prompt error', judging whether output rules of the business rules ID4, ID5 and ID1 exist, if the output rules do not exist, no modification is carried out, and 2 expected results are stored in an expected structure list.
S11, judging whether other business rules exist or not, wherein judging is absent.
And S12, calling a character supplement description rule again, and judging the character type, wherein the character type is 1, namely the character type does not contain letters.
And S13, calling case generation rules of character types and lengths, and judging that 2 positive cases and 3 negative cases need to be generated.
Repeating the above steps S5 to S11, the case names to be noted are "field chinese 1 (field english 1) -character type-positive case-01", "field chinese 1 (field english 1) -character type-positive case-02", "field chinese 1 (field english 1) -character type-negative case 01", "field chinese 1 (field english 1) -character type-negative case 02", "field chinese 1 (field english 1) -character type-negative case 03"; no001 of the case data is "12% & $ 12312", "12# @23123123123", "12XC2# #123123", "12# @ 23123123123123123123 #", "12# @ 2312312312312312312312 # @2312312312312# @ 2312312312312312312 # @ 2312312312312312312312312312312312312312 # @ 2312312312312312312312312312312312312312312312312 # @ 23123123123123123123123123123", respectively.
And S14, all cases are not subjected to security verification because no letters are contained.
S15, judging as character type, all numerical type and Boolean type are negative.
And S16, checking the necessary input item, and judging that the check is positive.
S17, calling a method for generating the must-input item case to generate 1 counterexample, and repeating the steps 5 to 11.
And S19, repeating the steps S4 to S17, and generating the next field case, which is not described in detail herein.
And S20, after all the fields generate cases, carrying out case duplication elimination according to the test data, and deleting duplicate cases.
And S21, after no repeated case exists, writing the case name, the precondition, the test data, the test step and the expected result list into the excel to obtain a final test case set.
Based on the test case generation method, the disclosure also provides a test case generation device. The apparatus will be described in detail below with reference to fig. 7.
Fig. 7 schematically shows a block diagram of a device for generating a test case according to an embodiment of the present disclosure.
As shown in fig. 7, the test case generation apparatus 600 of this embodiment includes an acquisition module 610, a first generation module 620, a second generation module 630, and an output module 640.
The obtaining module 610 is configured to obtain an interface standardization document in response to a test case generation instruction. In an embodiment, the obtaining module 610 may be configured to perform the operation S210 described above, which is not described herein again.
The first generating module 620 is used for generating target test data according to the interface standardized document. In an embodiment, the first generating module 620 may be configured to perform the operation S220 described above, which is not described herein again.
The second generating module 630 is configured to generate a test case set according to the target test data and the interface standardization document. In an embodiment, the second generating module 630 may be configured to perform the operation S230 described above, which is not described herein again.
The output module 640 is configured to output the test case suite, where the interface standardization document includes an interface table, a rule ID, and a business rule. In an embodiment, the output module 640 may be configured to perform the operation S240 described above, which is not described herein again.
According to an embodiment of the present disclosure, the first generating module 620 includes: a first generation submodule and a second generation submodule.
And the first generation submodule is used for generating standardized test data according to the field attribute. In an embodiment, the first generation submodule may be configured to perform the operation S221 described above, and is not described herein again.
And the second generation submodule is used for modifying the standardized test data according to the field type, the field length, the enumeration value and the service rule so as to generate target test data. In an embodiment, the second generation submodule may be configured to perform operation S222 described above, and is not described herein again.
According to an embodiment of the present disclosure, the second generation module 630 includes a third generation submodule and a deduplication submodule.
And the third generation submodule is used for generating a test case set from the first field of the interface according to the business rule, the enumerated value, the character type, the character length and the field attribute. In an embodiment, the third generating submodule may be configured to perform the operation S231 described above, and details are not repeated herein.
And the duplication removing submodule is used for carrying out duplication removal on the test case set according to the target test data so as to delete the duplicate cases. In an embodiment, the deduplication sub-module may be configured to perform the operation S232 described above, which is not described herein again.
According to an embodiment of the present disclosure, the third generation submodule includes: the case designing device comprises a case designing unit, a first generating unit, a second generating unit, a third generating unit and a fourth generating unit.
And the first generating unit is used for generating the test case name and the precondition corresponding to each field according to the interface standardized document. In an embodiment, the first generating unit may be configured to perform the operation S2311 described above, which is not described herein again.
And the second generation unit is used for determining the test step corresponding to each use case according to the system parameters. In an embodiment, the second generating unit may be configured to perform the operation S2312 described above, which is not described herein again.
And the third generating unit is used for generating an expected result of each use case according to the system parameters and the business rules. In an embodiment, the third generating unit may be configured to perform the operation S2313 described above, which is not described herein again.
And the fourth generating unit is used for generating a test case set according to the case design, the test case name, the precondition, the testing step and the expected result. In an embodiment, the fourth generating unit may be configured to perform the operation S2313 described above, which is not described herein again.
According to the embodiment of the present disclosure, any plurality of the obtaining module 610, the first generating module 620, the second generating module 630, and the outputting module 640 may be combined and implemented in one module, or any one of them may be split into a plurality of modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the obtaining module 610, the first generating module 620, the second generating module 630, and the outputting module 640 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented by hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or implemented by any one of three implementations of software, hardware, and firmware, or implemented by a suitable combination of any of them. Alternatively, at least one of the obtaining module 610, the first generating module 620, the second generating module 630 and the output module 640 may be at least partially implemented as a computer program module, which when executed may perform a corresponding function.
FIG. 8 schematically shows a block diagram of an electronic device adapted to implement a method for generating test cases according to an embodiment of the present disclosure.
As shown in fig. 8, an electronic apparatus 900 according to an embodiment of the present disclosure includes a processor 901 which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 902 or a program loaded from a storage portion 908 into a Random Access Memory (RAM) 903. Processor 901 may comprise, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 901 may also include on-board memory for caching purposes. The processor 901 may comprise a single processing unit or a plurality of processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In the RAM903, various programs and data necessary for the operation of the electronic apparatus 900 are stored. The processor 901, the ROM902, and the RAM903 are connected to each other through a bus 904. The processor 901 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM902 and/or the RAM 903. Note that the programs may also be stored in one or more memories other than the ROM902 and the RAM 903. The processor 901 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
Electronic device 900 may also include input/output (I/O) interface 905, input/output (I/O) interface 905 also connected to bus 904, according to an embodiment of the present disclosure. The electronic device 900 may also include one or more of the following components connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs, and when the one or more programs are executed, the method for generating the test case according to the embodiment of the present disclosure is implemented.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM902 and/or RAM903 described above and/or one or more memories other than the ROM902 and RAM 903.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method illustrated in the flow chart. When the computer program product runs in a computer system, the program code is used for causing the computer system to realize the test case generation method provided by the embodiment of the disclosure.
The computer program performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure when executed by the processor 901. The above described systems, devices, modules, units, etc. may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, and the like. In another embodiment, the computer program may also be transmitted, distributed in the form of a signal on a network medium, and downloaded and installed through the communication section 909 and/or installed from the removable medium 911. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The computer program, when executed by the processor 901, performs the above-described functions defined in the system of the embodiment of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the disclosure, and these alternatives and modifications are intended to fall within the scope of the disclosure.

Claims (10)

1. A method for generating a test case is characterized by comprising the following steps:
responding to a generation instruction of a test case, and acquiring an interface standardization document;
generating target test data according to the interface standardization file;
generating a test case set according to the target test data and the interface standardization document; and
outputting the test case set, wherein the test case set is output,
wherein the interface standardization document comprises an interface table, a rule ID and a business rule.
2. The method of claim 1, wherein the interface table includes a field type, a field length, a field attribute, and an enumerated value, and wherein generating target test data from the interface normalized document includes:
generating standardized test data according to the field attribute; and
and modifying the standardized test data according to the field type, the field length, the enumeration value and the service rule to generate target test data.
3. The method of claim 2, wherein generating a set of test cases from the target test data and the interface standardized document comprises:
generating a test case set from a first field of an interface according to the business rule, the enumerated value, the character type, the character length and the field attribute;
and carrying out duplicate removal on the test case set according to the target test data so as to delete repeated cases.
4. The method according to claim 3, wherein the generating a test case set from a first field of an interface according to the business rule, the enumerated value, the character type, the character length, and the field attribute comprises;
carrying out case design from a first field of an interface according to the business rule, the enumerated value, the character type, the character length and the field attribute;
generating a test case name and a precondition corresponding to each field according to the interface standardization document;
determining a testing step corresponding to each use case according to the system parameters;
generating an expected result of each use case according to the system parameters and the business rules;
and generating a test case set according to the case design, the test case name, the precondition, the test step and the expected result.
5. The method of any of claims 1 to 4, wherein the business rules include linkage rules, independent rules, interpretive rules, positive output rules, and negative output rules.
6. An apparatus for generating a test case, the apparatus comprising:
the acquisition module is used for responding to a generation instruction of a test case and acquiring an interface standardized document;
the first generation module is used for generating target test data according to the interface standardization file;
the second generation module is used for generating a test case set according to the target test data and the interface standardized document; and
an output module for outputting the test case set,
wherein the interface standardization document comprises an interface table, a rule ID and a business rule.
7. The generation apparatus of claim 6, wherein the interface table comprises a field type, a field length, a field attribute, and an enumerated value, and wherein the first generation module comprises:
the first generation submodule is used for generating standardized test data according to the field attribute; and
and the second generation submodule is used for modifying the standardized test data according to the field type, the field length, the enumeration value and the service rule so as to generate target test data.
8. An electronic device, comprising:
one or more processors;
a storage device to store one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-5.
9. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to carry out the method according to any one of claims 1 to 5.
10. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 5.
CN202211388067.8A 2022-11-07 2022-11-07 Test case generation method, device, equipment, storage medium and program product Pending CN115587045A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211388067.8A CN115587045A (en) 2022-11-07 2022-11-07 Test case generation method, device, equipment, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211388067.8A CN115587045A (en) 2022-11-07 2022-11-07 Test case generation method, device, equipment, storage medium and program product

Publications (1)

Publication Number Publication Date
CN115587045A true CN115587045A (en) 2023-01-10

Family

ID=84782576

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211388067.8A Pending CN115587045A (en) 2022-11-07 2022-11-07 Test case generation method, device, equipment, storage medium and program product

Country Status (1)

Country Link
CN (1) CN115587045A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118041842A (en) * 2024-01-26 2024-05-14 中国人民解放军军事科学院系统工程研究院 Method and system for testing extensible loosely-coupled software radio communication equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118041842A (en) * 2024-01-26 2024-05-14 中国人民解放军军事科学院系统工程研究院 Method and system for testing extensible loosely-coupled software radio communication equipment

Similar Documents

Publication Publication Date Title
US7917770B2 (en) Configurable data masking for software testing
CN115587045A (en) Test case generation method, device, equipment, storage medium and program product
CN113535577A (en) Application testing method and device based on knowledge graph, electronic equipment and medium
CN114281803A (en) Data migration method, device, equipment, medium and program product
CN116483888A (en) Program evaluation method and device, electronic equipment and computer readable storage medium
CN115827122A (en) Operation guiding method and device, electronic equipment and storage medium
CN112445461B (en) Business rule generation method and device, electronic equipment and readable storage medium
CN113918525A (en) Data exchange scheduling method, system, electronic device, medium, and program product
CN113032256A (en) Automatic test method, device, computer system and readable storage medium
CN113504904A (en) User-defined function implementation method and device, computer equipment and storage medium
CN112860344A (en) Component processing method and device, electronic equipment and storage medium
CN113535565B (en) Interface use case generation method, device, equipment and medium
CN117493206A (en) Test data generation method, device, equipment and storage medium
CN114003492A (en) Demand test integrated generation method and device
CN114218254A (en) Report generation method, device, equipment and storage medium
CN118227439A (en) Method, device, equipment, medium and program product for processing log data
CN114266547A (en) Method, device, equipment, medium and program product for identifying business processing strategy
CN118296023A (en) Data comparison method, device, equipment, medium and program product
CN115421738A (en) Version deployment method and device, electronic equipment and storage medium
CN114169485A (en) Certificate manufacturing method and device, electronic equipment and readable storage medium
CN117472410A (en) Method, device and equipment for updating development tool in componentized development project
CN114942887A (en) Program safety testing method, device, equipment and medium
CN114817036A (en) Decision tree testing method and device, electronic equipment and storage medium
CN116108089A (en) Big data testing method, computer equipment and storage medium
CN114490580A (en) Configurable data migration method and apparatus executed by automation script

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