CN110990276A - Automatic testing method and device for interface field and storage medium - Google Patents
Automatic testing method and device for interface field and storage medium Download PDFInfo
- Publication number
- CN110990276A CN110990276A CN201911202846.2A CN201911202846A CN110990276A CN 110990276 A CN110990276 A CN 110990276A CN 201911202846 A CN201911202846 A CN 201911202846A CN 110990276 A CN110990276 A CN 110990276A
- Authority
- CN
- China
- Prior art keywords
- test
- interface
- tested
- attribute information
- testing
- 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
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 611
- 238000000034 method Methods 0.000 claims abstract description 25
- 230000006870 function Effects 0.000 claims description 26
- 238000012545 processing Methods 0.000 claims description 13
- 238000004590 computer program Methods 0.000 claims description 6
- 238000010586 diagram Methods 0.000 description 5
- 238000012937 correction Methods 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000010998 test method Methods 0.000 description 2
- 230000006399 behavior Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000011022 operating instruction Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3692—Test management for test results analysis
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 an automatic interface field testing method, device and storage medium. The method comprises the following steps: reading an interface document of an interface to be tested, wherein the interface document comprises at least one piece of attribute information to be tested corresponding to each interface field in the N interface fields and an example value of each interface field; acquiring test rule information matched with the attribute information to be tested aiming at each attribute information to be tested corresponding to each interface field; obtaining a test case according to the test rule information and example values of other interface fields except the interface field in the N interface fields; and testing the interface to be tested according to the test case. The test data corresponding to the attribute to be tested can be automatically acquired according to the test rule information, so that the test case is acquired by combining the example values of other interface fields, the efficiency and the accuracy of acquiring the test data are improved, and the efficiency and the accuracy of testing are improved.
Description
Technical Field
The embodiment of the invention relates to the technical field of interface testing, in particular to an automatic interface field testing method, device and storage medium.
Background
The interface test is generally applicable to an underlying framework system and a central service system which provide services for other systems, and mainly tests interfaces provided by the systems to the outside so as to verify the correctness and stability of the interfaces. Interface testing can be divided into interface field rule testing and interface internal logic testing from the test level. The interface field is used to define the characteristics or behaviors contained in the object, for example, when testing the field of the login interface, the login password is defined as a necessary item, and the password is a combination of 1-10 digits and an English word, when testing, it is required to test whether the password is filled in, whether the password is a combination of digits and an English word, and whether the password is 1-10 digits.
In the prior art, test data for interface field rule testing mainly depends on interface documents defined by development, and a test data designer writes test cases according to the interface documents and executes the interface field rule testing by a tester.
However, when a test data designer manually compiles test cases, when one piece of data in the test cases is wrong, the whole test is wrong, and the accuracy of the test data cannot be guaranteed.
Disclosure of Invention
The embodiment of the invention provides an interface field automatic test method, an interface field automatic test device and a storage medium, which can automatically obtain test data according to the rule of an interface field, thereby obtaining a test case, and improving the efficiency of obtaining the test data and the accuracy of the test data.
In a first aspect, an embodiment of the present invention provides an automated interface field testing method, including:
reading an interface document of an interface to be tested, wherein the interface document comprises at least one piece of attribute information to be tested corresponding to each interface field in N interface fields and an example value of each interface field, and N is an integer greater than or equal to 1;
acquiring test rule information matched with the attribute information to be tested aiming at each attribute information to be tested corresponding to each interface field;
obtaining a test case according to the test rule information and example values of other interface fields except the interface field in the N interface fields;
and testing the interface to be tested according to the test case.
In some possible embodiments, the test rule information includes a template for generating a test case; wherein, the obtaining a test case according to the test rule information and the example values of the interface fields except the interface field in the N interface fields includes:
acquiring a template for generating a test case and test data for testing the attribute information to be tested according to the test rule information;
and obtaining the test case according to the test data, the template for generating the test case and the example values of the other interface fields.
In some possible embodiments, the test rule information further includes: test data for testing the attribute information to be tested; the test data for testing the attribute information to be tested is obtained according to a test data generating function and the at least one piece of test attribute information of the interface field.
In some possible embodiments, the test rule information further includes: generating a test data generating function corresponding to the attribute information to be tested;
the obtaining of the test data for testing the attribute information to be tested according to the test rule information includes:
and acquiring test data for testing the attribute information to be tested according to the test data generating function and the at least one piece of test attribute information of the interface field.
In some possible embodiments, the testing the interface to be tested according to the test case includes:
acquiring an interface address of the interface to be tested;
and testing the interface to be tested according to the interface address and the test case.
In some possible embodiments, after the testing the interface to be tested according to the test case, the method further includes:
acquiring a first test result corresponding to the test case;
judging whether the first test result indication conforms to a preset result corresponding to the test case;
if not, the test case is obtained again, and the interface to be tested is tested according to the obtained test case.
In some possible embodiments, after the testing the interface to be tested according to the retrieved test case, the method further includes:
acquiring a second test result corresponding to the obtained test case;
judging whether the first test result is consistent with the second test result;
if not, outputting prompt information, wherein the prompt information is used for prompting a user to modify the test rule information matched with the attribute information to be tested.
In a second aspect, an embodiment of the present invention provides an interface field automation test apparatus, including:
the interface document comprises at least one piece of attribute information to be tested corresponding to each interface field in N interface fields and an example value of each interface field, wherein N is an integer greater than or equal to 1;
the acquisition module is used for acquiring test rule information matched with the attribute information to be tested aiming at each attribute information to be tested corresponding to each interface field;
the processing module is used for obtaining a test case according to the test rule information and example values of other interface fields except the interface field in the N interface fields;
and the test module is used for testing the interface to be tested according to the test case.
In some possible embodiments, the test rule information includes a template for generating a test case; the processing module obtains a test case according to the test rule information and example values of other interface fields except the interface field in the N interface fields, and is specifically configured to:
acquiring a template for generating a test case and test data for testing the attribute information to be tested according to the test rule information;
and obtaining the test case according to the test data, the template for generating the test case and the example values of the other interface fields.
In some possible embodiments, the test rule information further includes: test data for testing the attribute information to be tested; the test data for testing the attribute information to be tested is obtained according to a test data generating function and the at least one piece of test attribute information of the interface field.
In some possible embodiments, the test rule information further includes: generating a test data generating function corresponding to the attribute information to be tested;
the processing module obtains test data for testing the attribute information to be tested according to the test rule information, and is specifically configured to:
and acquiring test data for testing the attribute information to be tested according to the test data generating function and the at least one piece of test attribute information of the interface field.
In some possible embodiments, the test module tests the interface to be tested according to the test case, and is specifically configured to: acquiring an interface address of the interface to be tested; and testing the interface to be tested according to the interface address and the test case.
In some possible embodiments, the obtaining module is further configured to obtain a first test result corresponding to the test case after the testing module tests the interface to be tested according to the test case; the processing module is further configured to determine whether the first test result indication meets a preset result corresponding to the test case; if not, the test case is obtained again; and the test module is also used for testing the interface to be tested according to the obtained test case.
In some possible embodiments, the obtaining module is further configured to obtain a second test result corresponding to the retrieved test case after the testing module tests the interface to be tested according to the retrieved test case; the processing module is further configured to determine whether the first test result is consistent with the second test result; if not, outputting prompt information, wherein the prompt information is used for prompting a user to modify the test rule information matched with the attribute information to be tested.
In a third aspect, an embodiment of the present invention provides an electronic device, including: at least one processor and memory;
the memory stores computer-executable instructions; the at least one processor executes computer-executable instructions stored by the memory to perform the method of any one of the first aspect of the embodiments of the invention.
In a fourth aspect, the present invention provides a computer-readable storage medium, in which program instructions are stored, and when the program instructions are executed by a processor, the method according to any one of the first aspect of the present invention is implemented.
In a fifth aspect, this application embodiment provides a program product, which includes a computer program, where the computer program is stored in a readable storage medium, and the computer program can be read by at least one processor of an electronic device from the readable storage medium, and the computer program is executed by the at least one processor to enable the electronic device to implement the method according to any one of the first aspect of the application embodiment.
The embodiment of the invention provides an automatic testing method, a device and a storage medium for interface fields, wherein an interface document of an interface to be tested is read, and the interface document comprises at least one piece of attribute information to be tested corresponding to each interface field in N interface fields and an example value of each interface field; acquiring test rule information matched with the attribute information to be tested aiming at each attribute information to be tested corresponding to each interface field; according to the test rule information and the example values of the interface fields except the interface field in the N interface fields, the test case is obtained, the test data corresponding to the attribute to be tested can be automatically obtained according to the test rule information, so that the test case is obtained by combining the example values of the other interface fields, the efficiency and the accuracy of obtaining the test data are improved, and the efficiency and the accuracy of testing are improved. Moreover, when the interface to be tested is tested according to the test case, the interface test can be automatically executed according to the test case, so that the test efficiency is further improved, and the problems of low efficiency and easy error when the test case is manually compiled in the prior art are solved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic diagram of a technical solution provided in an embodiment of the present invention;
FIG. 2 is a flowchart of an automated interface field testing method according to an embodiment of the present invention;
FIG. 3 is a flowchart of a method for automated testing of interface fields according to another embodiment of the present invention;
FIG. 4 is a flowchart of a method for automated testing of interface fields according to another embodiment of the present invention;
FIG. 5 is a schematic structural diagram of an interface field automatic test apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. 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.
When the interface field rule test is carried out and one of the interface fields is tested, the interface field needs to be subjected to rule analysis, so that test data corresponding to the interface field is manually written to obtain a test case. However, for a plurality of interface fields with similar interface field rules, test data may be automatically generated according to the field rules. For example, for a registration interface, a registration name, a login password and a mobile phone number need to be filled in, wherein the registration name is defined as a Chinese character, the number of digits does not exceed 4, and the required items are required to be filled in; defining a login password as a mandatory item comprising special characters and numbers, wherein the digit is 8; and defining the mobile phone number as a number, 11 bits and selecting a filling item. Therefore, the attribute information of the three fields (the registration name, the login password and the mobile phone number) corresponds to the number of necessary inputs, the field data type and the field digit, the field rules are the same, the test data generating function can be designed according to the field rules, and the test data can be automatically generated, so that the test case is obtained.
The embodiment of the invention provides an automatic testing method and device for interface fields and a storage medium, wherein as shown in fig. 1, the currently tested interface field is called a main testing field, and other interface fields are auxiliary testing fields. Obtaining test data of the attribute information to be tested in the main test field, and obtaining test rule information of each attribute information to be tested corresponding to each interface field according to the rule of the interface field so as to automatically generate test data; and the data corresponding to the auxiliary test field in the test case is the example value of the interface document, so that the test case is obtained, the efficiency and the accuracy of obtaining the test data are improved, and the efficiency and the accuracy of the test are improved. In addition, after the test case is obtained, the test of each attribute information to be tested in each interface field can be automatically executed according to the test case, and the test efficiency is improved.
The interface field automatic testing method provided by the embodiment of the invention can be applied to a testing terminal to realize the testing of the interface field, for example, the testing of a server interface and the like. The test terminal may be a smart phone, a tablet computer, a laptop portable computer, a desktop computer, etc. in which various software is installed. The interface field automatic test method can be executed by a test terminal, and can also be understood as being executed by an interface field automatic test device deployed in the test terminal. In the following method embodiments, for convenience of description, the execution subject of each step is described as an interface field automation test apparatus, but the present invention is not limited thereto.
Fig. 2 is a flowchart of an interface field automated testing method according to an embodiment of the present invention, and as shown in fig. 2, the method according to the embodiment may include:
s201, reading an interface document of the interface to be tested.
The interface document comprises at least one piece of attribute information to be tested corresponding to each interface field in N interface fields and an example value of each interface field, wherein N is an integer greater than or equal to 1.
In this embodiment, the interface document is shown in table 1, and the interface document is used to define the interface fields, and as shown in table 1, the interface document includes the fields: the interface field comprises ID (number), NAME (NAME), SEX (gender), AGE (AGE) and LuckyNum (lucky number), and at least one piece of attribute information to be tested corresponding to each interface field, wherein the attribute information to be tested comprises attributes to be tested and attribute information corresponding to the attributes to be tested. For example, for the interface field ID (number), the attribute information to be tested includes: the attribute information to be tested of the attribute to be tested, namely 'yes', the attribute information to be tested of the attribute to be tested, namely 'type', is 'NUMBER', the attribute information to be tested of the attribute to be tested, namely 'length', is '10', the interface document gives an example value of each interface field, wherein the example value is the value of the interface field in the test case when the corresponding interface field is not the interface field to be tested.
TABLE 1 interface document schematic
Reading all attribute information to be tested of each interface field of the interface document of the interface to be tested and an example value of each interface document.
S202, aiming at each to-be-tested attribute information corresponding to each interface field, obtaining test rule information matched with the to-be-tested attribute information.
In this embodiment, a user may, for example, preset a rule base, where the rule base includes test rule information corresponding to attribute information to be tested in any interface document. When the interface document shown in table 1 needs to be tested, according to each to-be-tested attribute information corresponding to each interface field in the interface document, obtaining test rule information matched with the to-be-tested attribute information from a rule base.
For example, for the interface document shown in table 1, when the interface fields in the interface document are tested, for each interface field, the attributes to be tested are: "must input", "type", and "length", wherein the attribute information to be tested corresponding to each interface field is different. For each interface field, the three attributes have the same test rule, and test rule information can be set in advance for each to-be-tested attribute information corresponding to each interface field. For example, for the interface field ID (number), test rule information matching "whether or not to fail" of the attribute information to be tested, test rule information matching "type" of the attribute information to be tested, and test rule information matching "length" of the attribute information to be tested are set in advance, respectively. When the length of the attribute information to be tested is tested, the test rule information matched with the length is obtained.
The test rules of "must be input", "type", and "length" for the attribute information to be tested of each interface field in table 1 are shown in tables 2 to 4, respectively, for example.
TABLE 2 test rules of "must fail
TABLE 3 test rules for "type
TABLE 4 test rules for "Length
Tables 5 to 7 show the test rule information corresponding to each attribute information to be tested corresponding to the interface field "ID" in table 1, according to the test rule of "must fail", "type", and "length" of the attribute information to be tested.
TABLE 5 test rule information "if necessary input
TABLE 6 "TYPE" TEST RULE INFORMATION
Example numbering | Input value | Use case Properties | Inputting content | Return value |
Test case 3 | NUMBER | Correction example | Inputting numbers | 10010 |
Test case 4 | NUMBER | Counter example | Inputting Chinese characters | 10011 |
Test case 5 | NUMBER | Counter example | Inputting special characters | 10011 |
Test case 6 | NUMBER | Counter example | Inputting English letters | 10011 |
TABLE 7, "Length" test rule information
Example numbering | Input value | Use case Properties | Inputting content | Return value |
Test case 7 | 10 | Correction example | Inputting 9-bit long digits | 10010 |
Test case 8 | 10 | Correction example | Inputting 10-bit long numbers | 10010 |
Test case 9 | 10 | Counter example | Inputting 11-bit long digits | 10011 |
S203, obtaining a test case according to the test rule information and the example values of the interface fields except the interface field in the N interface fields.
In this embodiment, for example, the interface field corresponding to the attribute information to be tested that needs to be tested currently may be referred to as a main test field, and the other interface fields that do not perform the attribute test currently may be referred to as auxiliary test fields. For one piece of attribute information to be tested of the current test in the primary test field, for example, for the interface field with a length of table 1, when the attribute of "must fail" of the interface field "ID" is tested currently, the interface field "ID" is the primary test field, and the interface field "NAME", the interface field "SEX", the interface field "AGE", and the interface field "LuckyNum" are the secondary test fields. For the attribute of "must fail" in the main test field "ID", the test data is obtained according to the test rule information shown in table 5, and the data in the auxiliary test field is the sample value in the interface document, so that the test case is obtained according to the test data obtained by the test rule information shown in table 5 and the sample value in the interface document.
And S204, testing the interface to be tested according to the test case.
In this embodiment, after the test case is obtained, the test interface to be tested is tested.
In some embodiments, one possible implementation of S104 is: acquiring an interface address of an interface to be tested; and testing the interface to be tested according to the interface address and the test case. For example, the interface address is obtained according to the interface name in the interface document shown in table 1, a test script is written, a message sending tool is called, and a test case is executed.
In the embodiment, an interface document of an interface to be tested is read, wherein the interface document comprises at least one piece of attribute information to be tested corresponding to each interface field in N interface fields and an example value of each interface field; acquiring test rule information matched with the attribute information to be tested aiming at each attribute information to be tested corresponding to each interface field; according to the test rule information and the example values of the interface fields except the interface field in the N interface fields, the test case is obtained, the test data corresponding to the attribute information to be tested can be automatically obtained according to the test rule information, so that the test case is obtained by combining the example values of the other interface fields, the efficiency and the accuracy of obtaining the test data are improved, and the efficiency and the accuracy of testing are improved. Moreover, when the interface to be tested is tested according to the test case, the interface test can be automatically executed according to the test case, so that the test efficiency is further improved, and the problems of low efficiency and easy error when the test case is manually compiled in the prior art are solved.
Fig. 3 is a flowchart of an automated interface field testing method according to another embodiment of the present invention, and as shown in fig. 3, the method according to this embodiment may include:
s301, reading an interface document of the interface to be tested.
In this embodiment, S201 may be referred to for a specific implementation manner of S301, and details are not described here.
S302, aiming at each to-be-tested attribute information corresponding to each interface field, obtaining test rule information matched with the to-be-tested attribute information.
In this embodiment, S202 may be referred to for a specific implementation manner of S302, and is not described herein again.
S303, obtaining a template for generating a test case and test data for testing attribute information to be tested according to the test rule information.
In this embodiment, according to the test rule information, a template for generating a test case and test data of attribute information to be tested corresponding to the test rule information are obtained. The template for generating the test case is obtained according to the test requirement of the interface test, that is, the template for generating the test case represents the test intention of the test case, that is, the test requirement to be tested by the test case.
In some embodiments, the test rule information includes a template for generating a test case, and after the test data of the attribute information to be tested currently tested in the attribute information to be tested in the main test field and the example value of the auxiliary test field are acquired, the test case is acquired according to the template for generating the test case.
In some embodiments, the test rule information further comprises: and the test data is used for testing the attribute information to be tested. Therefore, after the test rule information is obtained, the test data of the attribute information to be tested corresponding to the test rule information can be automatically obtained from the test rule information, and the efficiency and the accuracy of obtaining the test data are improved.
In some embodiments, the test data for testing the attribute information to be tested is obtained according to the test data generating function corresponding to the attribute information to be tested and at least one piece of test attribute information of the interface field. Because the interface fields of the interfaces to be tested have the same test rule, a test data generation function can be preset according to the test rule, and the test data generation function is, for example: CREATDATA ("current field type", "current field length", "smaller than, larger than or equal to"), when reading the interface document of the interface to be tested, every time one of the attribute information to be tested of one interface field is read, test data for testing the attribute information to be tested is obtained according to all the attribute information to be tested of the interface field and the test data generating function. For example, for the interface field "name", when testing its "must input" attribute, according to table 2, its positive example is to input a number whose field length meets the requirement of the attribute "length" (i.e. meets the requirements of the attributes "type" and "length"), therefore, according to all the attribute information to be tested of the interface field "name" and the test data generating function, the positive example for testing the "must input" attribute is obtained, for example: 1000, its opposite example is no input. After test data of each to-be-tested attribute information of each interface field is obtained, the test data is stored into the test rule information corresponding to the to-be-tested attribute information, so that the test data can be automatically obtained from the matched test rule information when the to-be-tested attribute information is tested. The efficiency of obtaining the test data and the accuracy of the test data are improved, and therefore the efficiency, the accuracy and the credibility of the test are improved.
In some embodiments, the test rule information further comprises: generating a function by using test data corresponding to the attribute information to be tested; accordingly, one possible implementation manner of S303 is: and acquiring test data for testing the attribute information to be tested according to the test data generating function and at least one piece of test attribute information of the interface field.
In this embodiment, a test data generating function corresponding to the attribute information to be tested is set in the test rule information matched with each test attribute information of each interface field in advance, so that when the attribute information to be tested is to be tested, the test data for testing the attribute information to be tested is obtained according to the test data generating function and all the attribute information to be tested of the interface field. For example, for the attribute information "type" to be tested in the interface field "ID", the test data is a function of: CREATDATA ("current field type", "10", "less"), wherein "current field type" includes: for different current field types, generating different test data to test the type of attribute information to be tested; for the length of the attribute information to be tested in the interface field ID, the test data is as a function: CREATDATA ("NUMBER", "10", "less than, greater than, or equal to"), wherein "less than, greater than, or equal to" includes: and respectively corresponding to different test data to test the length of the attribute information to be tested.
S304, obtaining the test case according to the test data, the template for generating the test case and the example values of other interface fields.
In this embodiment, the test case is obtained according to the test data, the example values of the other interface fields, and the template for generating the test case. For example, for the length of the attribute information to be tested in the interface field "ID", according to the example values in table 1 and the test rule information newly corresponding to the attribute to be tested, the test case for testing the attribute information to be tested is obtained as follows:
first test case:
{
"ID'":123456789,
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
Second test case:
{
"ID'":1234567891,
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
Third test case:
{
"ID'":12345678911,
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
S305, testing the interface to be tested according to the test case.
In this embodiment, S204 may be referred to for a specific implementation manner of S305, which is not described herein again.
In this embodiment, because each interface field in the interface to be tested has a similar rule, a uniform test data generating function can be set according to the rule of each field, and when the attribute information to be tested of one of the interface fields is tested, the test data for testing the attribute information to be tested is automatically obtained according to the attribute information to be tested and the parameter information in the test data generating function of other attribute information to be tested of the interface field (the current field type or the current field length or less than, greater than or equal to), so that the efficiency and the accuracy of obtaining the test data are improved.
Fig. 4 is a flowchart of an automated interface field testing method according to another embodiment of the present invention, based on any one of the above embodiments, the present embodiment provides a specific embodiment according to the interface document shown in table 1, and as shown in fig. 4, the method of the present embodiment may include:
s401, reading an interface document of the interface to be tested.
In this embodiment, S201 may be referred to for a specific implementation manner of S401, and details are not described here.
S402, selecting any interface field in the interface document.
In this embodiment, an example of selecting the interface field "ID" is described.
S40311, selecting whether the attribute information to be tested in the interface field needs to be input or not.
S40312, according to the fact whether the attribute information to be tested is necessary, test rule information matched with the attribute information to be tested is obtained.
In this embodiment, test data for testing whether the attribute information to be tested must be input and a template of a test case are obtained according to the test rule information.
S40313, according to the interface document, acquiring example values of other interface fields.
S40314, according to the test rule information and the example value, a test case for testing whether the attribute information to be tested is necessary is obtained.
In this embodiment, the test case may be, for example:
test case 1:
{
"ID'":10000,
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
Test case 2:
{
"ID'":“”,
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
S40321, selecting the attribute information to be tested 'type' in the interface field.
S40322, according to the type of the attribute information to be tested, test rule information matched with the attribute information to be tested is obtained;
in this embodiment, test data for testing the type of the attribute information to be tested and a template of a test case are obtained according to the test rule information.
S40323, according to the interface document, acquiring example values of other interface fields.
S40324, according to the test rule information and the example value, a test case for testing the type of the attribute information to be tested is obtained.
In this embodiment, the test case may be, for example:
test case 3:
{
"ID'":10000,
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
Test case 4:
{
"ID'" hello ",
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
Test case 5:
{
"ID'":“%%%%%%####”,
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
Test case 6:
{
"ID'":“ABC”,
"NAME": Zhang three "// example value
"SEX":1// example value
"AGE": 20///example value
LUCKYNUM {1, 2, 3, 4}// example value
}
S40331, selecting the length of the attribute information to be tested in the interface field.
S40332, according to the length of the attribute information to be tested, test rule information matched with the attribute information to be tested is obtained.
In this embodiment, test data for testing the length of the attribute information to be tested and a template of the test case are obtained according to the test rule information.
S40333, according to the interface document, acquiring example values of other interface fields.
S40334, according to the test rule information and the example value, a test case for testing the length of the attribute information to be tested is obtained.
Test case 7:
{
"ID'":123456789,
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
Test case 8:
{
"ID'":1234567891,
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
Test case 9:
{
"ID'":12345678911,
"NAME": Zhang three "// example value
"SEX":1// example value
20/example value of "AGE
LUCKYNUM {1, 2, 3, 4}// example value
}
S404, obtaining a test case for testing the selected interface field according to the test cases obtained in S40314, S40324 and S40334.
S405, testing the interface fields in the selected interface to be tested according to the test cases for testing the selected interface fields.
S406, returning to S402, another interface field is selected.
It should be noted that fig. 3 illustrates that after all test cases of one interface field are obtained, the message sending tool is called to execute the test cases. For example, for any attribute information to be tested in one interface field, after a test case of the attribute information to be tested is obtained, a message sending tool is called to execute the test case.
In some possible embodiments, on the basis of any of the foregoing embodiments, after S204, the method further includes:
acquiring a first test result corresponding to the test case; judging whether the first test result indication accords with a preset result corresponding to the test case; if not, the test case is obtained again, and the interface to be tested is tested according to the obtained test case.
In this embodiment, for any attribute to be tested, at least one test case of the attribute to be tested is obtained according to S202 and S203 for the first time, and when the interface test is executed according to each test case, a test result corresponding to each test case can be obtained. And the test result corresponding to the test case obtained for the first time is the first test result.
And after the first test result of each test case is obtained, judging whether the first test result is consistent with a preset result corresponding to the first test case. If the test case is consistent with the test case, the logic of the attribute to be tested, which is to be tested, in the interface field corresponding to the attribute to be tested is correct; if the first test result is inconsistent with the preset result corresponding to the first test case, in order to obtain the reason for the inconsistency between the first test result and the preset result corresponding to the first test case, the test case used for testing the logic of the attribute to be tested in the interface field can be obtained again according to the steps S202 and S203, and the attribute to be tested of the interface field is tested again according to the obtained test case.
For example, the test case for testing the attribute to be tested includes a positive case and a negative case, and the preset result is correct whether the test case is the positive case or the negative case. Therefore, when the test case obtained according to S202 and S203 is a positive example, if the first test result is correct, it indicates that the logic of the attribute to be tested of the test case is error-free; if the first test result is wrong, it indicates that the logic of the attribute to be tested of the test case is wrong, and the test case needs to be obtained again for testing. When the test case obtained according to S202 and S203 is a counterexample, if the first test result is correct, it indicates that the logic of the attribute to be tested of the test case is correct; if the first test result is wrong, it indicates that the logic of the attribute to be tested of the test case is wrong, and the test case needs to be obtained again for testing.
In this embodiment, by obtaining the test result of the test case, when the test result is inconsistent with the preset result corresponding to the test case, the test case is obtained again for testing, so as to determine whether the test case has a fault or the logic of the attribute to be tested, which is to be tested, of the test case is determined to be fault-free, thereby improving the accuracy of obtaining the test case and testing the interface.
In some possible embodiments, on the basis of the foregoing embodiments, after "testing the interface to be tested according to the retrieved test case", the method further includes:
acquiring a second test result corresponding to the obtained test case; judging whether the first test result is consistent with the second test result; if not, outputting prompt information, wherein the prompt information is used for prompting a user to modify the test rule information matched with the attribute information to be tested.
In this embodiment, after the test is executed according to the retrieved test case to obtain the test result, the test result corresponding to the retrieved test case is recorded as the second test result, and the second test result is compared with the first test result. If the first test result is consistent with the second test result, that is, the second test result is inconsistent with the preset result, it may be determined that the logic of the attribute to be tested, which is to be tested, of the test case is incorrect, and the logic of the attribute to be tested, which is to be tested, of the test case needs to be modified. If the first test result is inconsistent with the second test result, namely the second test result is consistent with the preset result, the test rule information matched with the attribute information to be tested is determined to be wrong, and prompt information is output so as to prompt a user to modify the test rule information matched with the attribute information to be tested.
In the embodiment, the two test results are compared, and when the two test results are inconsistent, the test rule information for obtaining the test data in the test case is modified, so that the accuracy of the obtained test case is improved, and the situation that the test result is wrong due to incorrect test case and the test result is regarded as the logic error of the to-be-tested attribute to be tested by the test case is avoided.
Fig. 5 is a schematic structural diagram of an interface field automatic testing apparatus according to an embodiment of the present invention, and as shown in fig. 5, the apparatus according to this embodiment may include: a reading module 51, an acquisition module 52, a processing module 53 and a testing module 54. Wherein,
the reading module 51 is configured to read an interface document of an interface to be tested, where the interface document includes at least one to-be-tested attribute information corresponding to each interface field of N interface fields and an example value of each interface field, and N is an integer greater than or equal to 1;
the obtaining module 52 is configured to obtain, for each to-be-tested attribute information corresponding to each interface field, test rule information matched with the to-be-tested attribute information;
the processing module 53 is configured to obtain a test case according to the test rule information and the example values of the interface fields except the interface field in the N interface fields;
and the test module 54 is configured to test the interface to be tested according to the test case.
In some possible embodiments, the test rule information includes a template for generating test cases.
In some possible embodiments, the processing module 53 obtains the test case according to the test rule information and the example values of the interface fields except the interface field in the N interface fields, and is specifically configured to:
acquiring a template for generating a test case and test data for testing attribute information to be tested according to the test rule information; and obtaining the test case according to the test data, the template for generating the test case and the example values of other interface fields.
In some possible embodiments, the test rule information further includes: and the test data is used for testing the attribute information to be tested.
In some possible embodiments, the test data for testing the attribute information to be tested is obtained from the test data generating function and the at least one test attribute information of the interface field.
In some possible embodiments, the test rule information further includes: generating a function by using test data corresponding to the attribute information to be tested; the processing module 53 obtains test data for testing the attribute information to be tested according to the test rule information, and is specifically configured to: and acquiring test data for testing the attribute information to be tested according to the test data generating function and at least one piece of test attribute information of the interface field.
In some possible embodiments, the test module 54 tests the interface to be tested according to the test case, and is specifically configured to: acquiring an interface address of an interface to be tested; and testing the interface to be tested according to the interface address and the test case.
In some possible embodiments, the obtaining module 52 is further configured to obtain a first test result corresponding to the test case after the test module tests the interface to be tested according to the test case; the processing module 53 is further configured to determine whether the first test result indication meets a preset result corresponding to the test case; if not, the test case is obtained again; the test module 54 is further configured to test the interface to be tested according to the retrieved test case.
In some possible embodiments, the obtaining module 52 is further configured to obtain a second test result corresponding to the obtained test case after the test module tests the interface to be tested according to the obtained test case; the processing module 53 is further configured to determine whether the first test result is consistent with the second test result; if not, outputting prompt information, wherein the prompt information is used for prompting a user to modify the test rule information matched with the attribute information to be tested.
The apparatus of this embodiment may be configured to implement the technical solution of any one of the above-mentioned method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 6, the electronic device according to the embodiment may include: at least one processor 61 and a memory 62. Fig. 6 shows an electronic device as an example of a processor, wherein,
and a memory 62 for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory 62 may comprise a Random Access Memory (RAM) and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
And the processor 61 is configured to execute the computer-executable instructions stored in the memory 62 to implement the interface field automatic testing method in the foregoing embodiment.
The processor 61 may be a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits configured to implement the embodiments of the present Application.
Alternatively, in a specific implementation, if the memory 62 and the processor 61 are implemented independently, the memory 62 and the processor 61 may be connected to each other through a bus and perform communication with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The buses may be divided into address buses, data buses, control buses, etc., but do not represent only one bus or one type of bus.
Alternatively, in a specific implementation, if the memory 62 and the processor 61 are integrated on a chip, the memory 62 and the processor 61 may complete the same communication through an internal interface.
The electronic device described above in this embodiment may be configured to execute the technical solutions shown in the above method embodiments, and the implementation principles and technical effects are similar, which are not described herein again.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
Claims (10)
1. An automated interface field testing method, comprising:
reading an interface document of an interface to be tested, wherein the interface document comprises at least one piece of attribute information to be tested corresponding to each interface field in N interface fields and an example value of each interface field, and N is an integer greater than or equal to 1;
acquiring test rule information matched with the attribute information to be tested aiming at each attribute information to be tested corresponding to each interface field;
obtaining a test case according to the test rule information and example values of other interface fields except the interface field in the N interface fields;
and testing the interface to be tested according to the test case.
2. The method of claim 1, wherein the test rule information includes a template for generating test cases; wherein, the obtaining a test case according to the test rule information and the example values of the interface fields except the interface field in the N interface fields includes:
acquiring a template for generating a test case and test data for testing the attribute information to be tested according to the test rule information;
and obtaining the test case according to the test data, the template for generating the test case and the example values of the other interface fields.
3. The method of claim 2, wherein the test rule information further comprises: test data for testing the attribute information to be tested; the test data for testing the attribute information to be tested is obtained according to a test data generating function and the at least one piece of test attribute information of the interface field.
4. The method of claim 2, wherein the test rule information further comprises: generating a test data generating function corresponding to the attribute information to be tested;
the obtaining of the test data for testing the attribute information to be tested according to the test rule information includes:
and acquiring test data for testing the attribute information to be tested according to the test data generating function and the at least one piece of test attribute information of the interface field.
5. The method of claim 1, wherein the testing the interface to be tested according to the test case comprises:
acquiring an interface address of the interface to be tested;
and testing the interface to be tested according to the interface address and the test case.
6. The method of claim 1, wherein after the testing the interface to be tested according to the test case, the method further comprises:
acquiring a first test result corresponding to the test case;
judging whether the first test result meets a preset result corresponding to the test case;
if not, the test case is obtained again, and the interface to be tested is tested according to the obtained test case.
7. The method of claim 6, wherein after the testing the interface to be tested according to the retrieved test case, further comprising:
acquiring a second test result corresponding to the obtained test case;
judging whether the first test result is consistent with the second test result;
if not, outputting prompt information, wherein the prompt information is used for prompting a user to modify the test rule information matched with the attribute information to be tested.
8. An automated interface field testing apparatus, comprising:
the interface document comprises at least one piece of attribute information to be tested corresponding to each interface field in N interface fields and an example value of each interface field, wherein N is an integer greater than or equal to 1;
the acquisition module is used for acquiring test rule information matched with the attribute information to be tested aiming at each attribute information to be tested corresponding to each interface field;
the processing module is used for obtaining a test case according to the test rule information and example values of other interface fields except the interface field in the N interface fields;
and the test module is used for testing the interface to be tested according to the test case.
9. An electronic device, comprising: a memory for storing program instructions and at least one processor for calling the program instructions in the memory to perform the interface field automated testing method of any of claims 1-7.
10. A readable storage medium, characterized in that the readable storage medium has stored thereon a computer program; the computer program, when executed, implements an interface field automated testing method as claimed in any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911202846.2A CN110990276A (en) | 2019-11-29 | 2019-11-29 | Automatic testing method and device for interface field and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911202846.2A CN110990276A (en) | 2019-11-29 | 2019-11-29 | Automatic testing method and device for interface field and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110990276A true CN110990276A (en) | 2020-04-10 |
Family
ID=70088526
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911202846.2A Pending CN110990276A (en) | 2019-11-29 | 2019-11-29 | Automatic testing method and device for interface field and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110990276A (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111897712A (en) * | 2020-06-20 | 2020-11-06 | 中国建设银行股份有限公司 | Test case generation method and device, electronic equipment and readable storage medium |
CN112035357A (en) * | 2020-08-31 | 2020-12-04 | 平安医疗健康管理股份有限公司 | Intelligent test method, device, equipment and storage medium |
CN112380081A (en) * | 2020-12-04 | 2021-02-19 | 哈尔滨工业大学 | Commercial vehicle-mounted CAN bus fuzzy test method based on field weight |
CN112597033A (en) * | 2020-12-26 | 2021-04-02 | 中国农业银行股份有限公司 | Automatic interface testing method and device |
CN113609018A (en) * | 2021-08-05 | 2021-11-05 | 工银科技有限公司 | Test method, training method, device, apparatus, medium, and program product |
CN113672520A (en) * | 2021-09-08 | 2021-11-19 | 京东科技控股股份有限公司 | Test case generation method and device, electronic equipment and storage medium |
CN114647587A (en) * | 2022-03-30 | 2022-06-21 | 中国银行股份有限公司 | Method, apparatus, device, storage medium and product for determining correctness of interface |
CN114760236A (en) * | 2022-04-08 | 2022-07-15 | 中国银行股份有限公司 | Interface checking method, device, storage medium and equipment |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106155891A (en) * | 2015-04-02 | 2016-11-23 | 阿里巴巴集团控股有限公司 | Interface test method, interface description data library generating method and device |
CN108446225A (en) * | 2018-03-06 | 2018-08-24 | 平安科技(深圳)有限公司 | Creating device, method and the computer readable storage medium of analog interface |
CN109189666A (en) * | 2018-08-02 | 2019-01-11 | 腾讯科技(北京)有限公司 | Interface test method, device and computer equipment |
CN109388561A (en) * | 2018-09-18 | 2019-02-26 | 深圳壹账通智能科技有限公司 | Interface testing case generation method, device, computer equipment and storage medium |
CN110134584A (en) * | 2019-04-12 | 2019-08-16 | 深圳壹账通智能科技有限公司 | A kind of generation method, device, storage medium and the server of interface testing use-case |
CN110232024A (en) * | 2019-05-26 | 2019-09-13 | 必成汇(成都)科技有限公司 | Software automated testing frame and test method |
-
2019
- 2019-11-29 CN CN201911202846.2A patent/CN110990276A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106155891A (en) * | 2015-04-02 | 2016-11-23 | 阿里巴巴集团控股有限公司 | Interface test method, interface description data library generating method and device |
CN108446225A (en) * | 2018-03-06 | 2018-08-24 | 平安科技(深圳)有限公司 | Creating device, method and the computer readable storage medium of analog interface |
CN109189666A (en) * | 2018-08-02 | 2019-01-11 | 腾讯科技(北京)有限公司 | Interface test method, device and computer equipment |
CN109388561A (en) * | 2018-09-18 | 2019-02-26 | 深圳壹账通智能科技有限公司 | Interface testing case generation method, device, computer equipment and storage medium |
CN110134584A (en) * | 2019-04-12 | 2019-08-16 | 深圳壹账通智能科技有限公司 | A kind of generation method, device, storage medium and the server of interface testing use-case |
CN110232024A (en) * | 2019-05-26 | 2019-09-13 | 必成汇(成都)科技有限公司 | Software automated testing frame and test method |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111897712A (en) * | 2020-06-20 | 2020-11-06 | 中国建设银行股份有限公司 | Test case generation method and device, electronic equipment and readable storage medium |
CN112035357A (en) * | 2020-08-31 | 2020-12-04 | 平安医疗健康管理股份有限公司 | Intelligent test method, device, equipment and storage medium |
CN112380081A (en) * | 2020-12-04 | 2021-02-19 | 哈尔滨工业大学 | Commercial vehicle-mounted CAN bus fuzzy test method based on field weight |
CN112597033A (en) * | 2020-12-26 | 2021-04-02 | 中国农业银行股份有限公司 | Automatic interface testing method and device |
CN112597033B (en) * | 2020-12-26 | 2024-08-06 | 中国农业银行股份有限公司 | Automatic interface testing method and device |
CN113609018A (en) * | 2021-08-05 | 2021-11-05 | 工银科技有限公司 | Test method, training method, device, apparatus, medium, and program product |
CN113672520A (en) * | 2021-09-08 | 2021-11-19 | 京东科技控股股份有限公司 | Test case generation method and device, electronic equipment and storage medium |
CN113672520B (en) * | 2021-09-08 | 2024-06-18 | 京东科技控股股份有限公司 | Test case generation method and device, electronic equipment and storage medium |
CN114647587A (en) * | 2022-03-30 | 2022-06-21 | 中国银行股份有限公司 | Method, apparatus, device, storage medium and product for determining correctness of interface |
CN114760236A (en) * | 2022-04-08 | 2022-07-15 | 中国银行股份有限公司 | Interface checking method, device, storage medium and equipment |
CN114760236B (en) * | 2022-04-08 | 2023-11-14 | 中国银行股份有限公司 | Interface checking method, device, storage medium and equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110990276A (en) | Automatic testing method and device for interface field and storage medium | |
CN109033772B (en) | Verification information input method and device | |
CN108734304B (en) | Training method and device of data model and computer equipment | |
CN108595338A (en) | Test case write method, device, computer equipment and storage medium | |
CN109271611B (en) | Data verification method and device and electronic equipment | |
CN110046086B (en) | Expected data generation method and device for test and electronic equipment | |
CN110263853B (en) | Method and device for checking state of manual client by using error sample | |
CN110389941B (en) | Database checking method, device, equipment and storage medium | |
CN111797026A (en) | Test case generation method and device, computer equipment and storage medium | |
CN107316156B (en) | Data processing method, device, server and storage medium | |
CN111352782A (en) | Interface testing method and device, computer equipment and storage medium | |
CN111209736A (en) | Text file analysis method and device, computer equipment and storage medium | |
CN111159040A (en) | Test data generation method, device, equipment and storage medium | |
CN113342669A (en) | Verification method and device for shortening convergence time of chip code coverage rate | |
CN116415258A (en) | Vulnerability detection method, device, equipment, medium and program product | |
CN108959508B (en) | SQL data generation method and device | |
CN112882707B (en) | Rendering method and device, storage medium and electronic equipment | |
CN117171030A (en) | Method, device, equipment and storage medium for detecting software running environment | |
US20120310849A1 (en) | System and method for validating design of an electronic product | |
WO2021072872A1 (en) | Name storage method and apparatus based on character conversion, and computer device | |
CN116562227A (en) | Chip signal connectivity verification method and device | |
CN110865932A (en) | Program internal interface testing method, system, terminal and storage medium | |
CN116340941A (en) | Static code scanning method, device, equipment and medium | |
CN112631852B (en) | Macro checking method, macro checking device, electronic equipment and computer readable storage medium | |
CN114564336A (en) | Data consistency checking method, device, equipment and storage medium |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200410 |