CN110334021B - Interface test case generation method, device, equipment and storage medium - Google Patents

Interface test case generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN110334021B
CN110334021B CN201910564382.3A CN201910564382A CN110334021B CN 110334021 B CN110334021 B CN 110334021B CN 201910564382 A CN201910564382 A CN 201910564382A CN 110334021 B CN110334021 B CN 110334021B
Authority
CN
China
Prior art keywords
field
test
value
request
parameter
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.)
Active
Application number
CN201910564382.3A
Other languages
Chinese (zh)
Other versions
CN110334021A (en
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.)
WeBank Co Ltd
Original Assignee
WeBank 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 WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN201910564382.3A priority Critical patent/CN110334021B/en
Publication of CN110334021A publication Critical patent/CN110334021A/en
Application granted granted Critical
Publication of CN110334021B publication Critical patent/CN110334021B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Landscapes

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

Abstract

The invention discloses a method, a device, equipment and a storage medium for generating an interface test case, wherein the method comprises the steps of determining a target interface document corresponding to a test request when the test request is received, and acquiring each request parameter field in the target interface document; determining a preset field value range corresponding to each request parameter field according to the field type of each request parameter field, and determining a target value rule of each request parameter field according to the test type corresponding to the test request; and taking out corresponding target values in field value ranges corresponding to the request parameter fields according to the target value taking rules, and assigning the request parameter fields according to the target values to generate corresponding interface test cases. The invention realizes the rapid generation and batch generation of the cases, and improves the diversity, completeness and accuracy of the test cases.

Description

Interface test case generation method, device, equipment and storage medium
Technical Field
The invention relates to the technical field of financial technology (Fintech), in particular to a method, a device and equipment for generating an interface test case and a computer readable storage medium.
Background
With the development of computer technology, more and more technologies (big data, distributed, blockchain, artificial intelligence, etc.) are applied to the financial field, and the traditional financial industry is gradually changing to financial technology (Fintech), but higher requirements are also put forward on the technologies due to the requirements of security and real-time performance of the financial industry. For the banking system, an interface test is generally required, wherein the interface test mainly tests the exchange of data. The interface test is mainly carried out through an interface test case. The existing interface test cases are generally manually written in a single mode, and depend on the working experience and technical capability of testers, so that the diversity, complexity and completeness of the interface test cases are limited. Therefore, the existing interface test case is not only low in compiling efficiency, but also low in case test accuracy.
Disclosure of Invention
The invention mainly aims to provide a method, a device and equipment for generating an interface test case and a computer readable storage medium, and aims to solve the technical problems of low compiling efficiency and low case test accuracy of the existing interface test case.
In order to achieve the above object, the present invention provides a method for generating an interface test case, where the method for generating an interface test case includes the following steps:
when a test request is received, determining a target interface document corresponding to the test request, and acquiring each request parameter field in the target interface document;
determining a preset field value range corresponding to each request parameter field according to the field type of each request parameter field, and determining a target value rule of each request parameter field according to the test type corresponding to the test request;
and taking out corresponding target values in field value ranges corresponding to the request parameter fields according to the target value taking rules, and assigning the request parameter fields according to the target values to generate corresponding interface test cases.
Optionally, the step of determining a preset field value range corresponding to each request parameter field according to the field type of each request parameter field, and determining a value rule of each request parameter field according to the test type corresponding to the test request specifically includes:
determining a preset field value range corresponding to each request parameter field in a preset database according to the field type of each request parameter field;
determining the target test type in the full field test type, the optional field test type and each field test type according to the test type corresponding to the test request;
and determining the target value-taking rule in the full field value-taking rule, the optional field value-taking rule and each field value-taking rule according to the target test type.
Optionally, the step of taking out a corresponding target value from a field value range corresponding to each request parameter field according to the target value taking rule, and assigning values to each request parameter field according to the target value to generate a corresponding interface test case specifically includes:
if the target value-taking rule is a full-field value-taking rule, taking out a corresponding safety value in a field value-taking range corresponding to each request parameter field as the target value;
and assigning values to the request parameter fields according to the target values corresponding to the request parameter fields to generate a full-field test case as the interface test case.
Optionally, the step of taking out a corresponding target value from a field value range corresponding to each request parameter field according to the target value taking rule, and assigning values to each request parameter field according to the target value to generate a corresponding interface test case specifically includes:
if the target value-taking rule is a mandatory field value-taking rule, determining mandatory parameter fields in each request parameter field according to the mandatory field identification, and sequentially adding the mandatory parameter fields to a mandatory parameter field queue;
taking out corresponding safety values in other optional parameter fields and field value ranges corresponding to the optional parameter fields as the target values, and assigning the other optional parameter fields and the optional parameter fields according to the target values to generate a first test case;
according to the field sequence in the optional parameter field queue, sequentially taking each optional parameter field in the optional parameter field queue as an optional parameter field to be tested;
assigning the optional parameter fields to be tested as null values, assigning other optional parameter fields except the optional parameter fields to be tested and other optional parameter fields as corresponding safety values, and generating optional field test cases to be tested corresponding to the optional parameter fields to be tested, wherein the number of the optional field test cases to be tested is equal to that of the optional parameter fields;
and generating a mandatory field test case as the interface test case according to each mandatory field test case to be tested and the first test case.
Optionally, the step of taking out a corresponding target value from a field value range corresponding to each request parameter field according to the target value taking rule, and assigning values to each request parameter field according to the target value to generate a corresponding interface test case specifically includes:
if the target value-taking rule is a value-taking rule of each field, sequentially acquiring each request parameter field as a target parameter field;
taking out a corresponding target value in a field value range corresponding to the target parameter field, wherein the target value comprises at least one of an overlong parameter value, an upper boundary value, a lower boundary value, a null value and other types of parameter values;
assigning values to the target parameter fields according to the target values, assigning values to other request parameter fields except the target parameter fields as safety values, and generating test cases of each field to be tested corresponding to each request parameter field;
and generating each field test case according to each field test case to be tested as the interface test case, wherein the number of the field test cases to be tested is equal to the number of the request parameter fields.
Optionally, the method for generating an interface test case further includes:
generating an interface test case set according to the interface test case, the service ID, the service scene number and the case execution logic, and storing the interface test case set;
and generating and displaying a corresponding test report according to the test type, a preset report template and the test result of the interface test case set.
Optionally, after the step of generating and displaying the corresponding test report according to the test type, the preset report template, and the execution result of the interface test case set, the method further includes:
and when an adjusting instruction triggered by the user based on the test report is received, correspondingly adjusting and repairing the interface test case set so as to optimize the interface test case set.
Optionally, when the test request is received, the step of determining the target interface document corresponding to the test request specifically includes:
and when a test request is received, acquiring a page request in the test request, and determining a corresponding target interface document in a file server according to the page request, wherein the page request comprises http or post.
In addition, to achieve the above object, the present invention further provides an interface test case generation apparatus, where the interface test case generation apparatus includes:
the parameter field acquisition module is used for determining a target interface document corresponding to a test request when the test request is received and acquiring each request parameter field in the target interface document;
a value rule determining module, configured to determine, according to the field type of each request parameter field, a preset field value range corresponding to each request parameter field, and determine, according to the test type corresponding to the test request, a target value rule of each request parameter field;
and the test case generation module is used for taking out corresponding target values in field value ranges corresponding to the request parameter fields according to the target value taking rules, and carrying out assignment on the request parameter fields according to the target values to generate corresponding interface test cases.
Optionally, the value rule determining module specifically includes:
a value range determining unit, configured to determine, according to the field type of each request parameter field, a preset field value range corresponding to each request parameter field in a preset database;
a test type determining unit, configured to determine the target test type from the full field test type, the mandatory field test type, and each field test type according to a test type corresponding to the test request;
and the value-taking rule determining unit is used for determining the target value-taking rule in the full-field value-taking rule, the mandatory field value-taking rule and each field value-taking rule according to the target test type.
Optionally, the test case generating module specifically includes:
a value determining unit, configured to, if the target value-taking rule is a full-field value-taking rule, take out a corresponding security value within a field value-taking range corresponding to each request parameter field, and take the security value as the target value;
and the field assignment unit is used for assigning values to the request parameter fields according to the target values corresponding to the request parameter fields to generate a full-field test case as the interface test case.
Optionally, the test case generation module is further specifically configured to:
if the target value-taking rule is a mandatory field value-taking rule, determining mandatory parameter fields in each request parameter field according to the mandatory field identification, and sequentially adding the mandatory parameter fields to a mandatory parameter field queue;
taking out corresponding safety values in other optional parameter fields and field value ranges corresponding to the optional parameter fields as the target values, and assigning the other optional parameter fields and the optional parameter fields according to the target values to generate a first test case;
according to the field sequence in the optional parameter field queue, sequentially taking each optional parameter field in the optional parameter field queue as an optional parameter field to be tested;
assigning the optional parameter fields to be tested as null values, assigning other optional parameter fields except the optional parameter fields to be tested and other optional parameter fields as corresponding safety values, and generating optional field test cases to be tested corresponding to the optional parameter fields to be tested, wherein the number of the optional field test cases to be tested is equal to that of the optional parameter fields;
and generating a mandatory field test case as the interface test case according to each mandatory field test case to be tested and the first test case.
Optionally, the test case generation module is further specifically configured to:
if the target value-taking rule is a value-taking rule of each field, sequentially acquiring each request parameter field as a target parameter field;
taking out a corresponding target value in a field value range corresponding to the target parameter field, wherein the target value comprises at least one of an overlong parameter value, an upper boundary value, a lower boundary value, a null value and other types of parameter values;
assigning values to the target parameter fields according to the target values, assigning values to other request parameter fields except the target parameter fields as safety values, and generating test cases of each field to be tested corresponding to each request parameter field;
and generating each field test case according to each field test case to be tested as the interface test case, wherein the number of the field test cases to be tested is equal to the number of the request parameter fields.
Optionally, the parameter field obtaining module is further configured to:
and when a test request is received, acquiring a page request in the test request, and determining a corresponding target interface document in a file server according to the page request, wherein the page request comprises http or post.
In addition, to achieve the above object, the present invention further provides an interface test case generation device, where the interface test case generation device includes: the interface test case generation method comprises a memory, a processor and an interface test case generation program which is stored on the memory and can run on the processor, wherein the interface test case generation program realizes the steps of the interface test case generation method when being executed by the processor.
In addition, to achieve the above object, the present invention further provides a computer readable storage medium, on which a generation program of an interface test case is stored, and when the generation program of the interface test case is executed by a processor, the steps of the generation method of the interface test case as described above are implemented.
When a test request is received, determining a target interface document corresponding to the test request, and acquiring each request parameter field in the target interface document; determining a preset field value range corresponding to each request parameter field according to the field type of each request parameter field, and determining a target value rule of each request parameter field according to the test type corresponding to the test request; and taking out corresponding target values in field value ranges corresponding to the request parameter fields according to the target value taking rules, and assigning the request parameter fields according to the target values to generate corresponding interface test cases. Through the mode, the method and the device realize the rapid generation and batch generation of the cases based on the request parameter field in the target interface document and by combining the field type, the preset field value range and the field value rule of the parameter field, improve the diversity, completeness and accuracy of the test cases, and solve the technical problems of low compiling efficiency and low case test accuracy of the existing interface test cases.
Drawings
Fig. 1 is a schematic device structure diagram of a hardware operating environment according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a method for generating an interface test case according to a first embodiment of the present invention.
The implementation, functional features and advantages of the present invention will be further described with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, fig. 1 is a schematic device structure diagram of a hardware operating environment according to an embodiment of the present invention.
The generation equipment of the interface test case of the embodiment of the invention can be a PC or server equipment, and a Java virtual machine runs on the generation equipment.
As shown in fig. 1, the interface test case generation device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, a communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration of the apparatus shown in fig. 1 is not intended to be limiting of the apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a generation program of an interface test case.
In the device shown in fig. 1, the network interface 1004 is mainly used for connecting to a backend server and performing data communication with the backend server; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and the processor 1001 may be configured to call the generation program of the interface test case stored in the memory 1005 and perform operations in the generation method of the interface test case described below.
Based on the hardware structure, the embodiment of the generation method of the interface test case is provided.
Referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of a method for generating an interface test case according to the present invention, where the method for generating an interface test case includes:
step S10, when a test request is received, determining a target interface document corresponding to the test request, and acquiring each request parameter field in the target interface document;
the existing interface test cases are generally manually written in a single mode, and the diversity, complexity and completeness of the interface test cases are limited depending on the working experience and technical capability of testers. Therefore, the existing interface test case is not only low in compiling efficiency, but also low in case test accuracy. In order to solve the above problems, in the embodiment, based on the request parameter field in the target interface document, in combination with the field type, the preset field value range, and the field value rule of the parameter field, the quick generation and batch generation of the cases are realized, and the diversity, completeness, and accuracy of the test cases are improved. The present implementation is described by taking as an example the generation of a RMB interface test case, where RMB is a self-developed middleware message protocol. Specifically, when a test request triggered by interface document uploading operation of a developer is received, a target interface document corresponding to the test request is determined. When a test request is received, the step of determining a target interface document corresponding to the test request specifically includes: and when a test request is received, acquiring a page request in the test request, and determining a corresponding target interface document in a file server according to the page request, wherein the page request comprises http or post. In order to improve data security, a developer can upload each API interface document, that is, a target interface document, to a file server of an intranet for storage, and link HTTP/POST to generate a corresponding test request according to a page request for obtaining the target interface document. Wherein the target interface document is an online document. And acquiring the service ID, the service scene number and a request parameter table comprising various request parameter fields in the target interface document.
Step S20, determining a preset field value range corresponding to each request parameter field according to the field type of each request parameter field, and determining a target value rule of each request parameter field according to the test type corresponding to the test request;
in this embodiment, the request parameter table includes a parameter field name, whether the field is a mandatory field, a field type, and the like of each request parameter field. The method comprises the steps that preset field value ranges corresponding to all parameter fields are stored in a database of a server in advance, wherein the field value ranges are value ranges corresponding to all field types which are self-defined in advance, such as safety values, upper boundary values, lower boundary values, null values and parameter values of non-local field types. And determining the field type of each request parameter, such as int, string, long, date, char, default and the like, according to a preset database, and then determining the field value range corresponding to each request parameter according to the field type. And determining the current test type according to the test request.
Determining a preset field value range corresponding to each request parameter field in a preset database according to the field type of each request parameter field;
determining the target test type in the full field test type, the optional field test type and each field test type according to the test type corresponding to the test request;
and determining the target value-taking rule in the full field value-taking rule, the optional field value-taking rule and each field value-taking rule according to the target test type.
In this embodiment, the test types include a full field test type, a mandatory field test type, and each field test type, and the target test type may be any one of the test types, or a combination of any two test types, or a combination of three test types. The all-field test type, the optional field test type and each field test type respectively correspond to an all-field value-taking rule, an optional field value-taking rule and each field value-taking rule. And determining at least one rule as a target value-taking rule according to the value-taking rule of the target test type in the whole field, the value-taking rule of the optional field and the value-taking rule of each field. All the field value rules, the optional field value rules and the field value rules are pre-defined value rules, and a value sequence and the like can be further defined.
And S30, taking out corresponding target values from field value ranges corresponding to the request parameter fields according to the target value taking rules, and assigning the request parameter fields according to the target values to generate corresponding interface test cases.
In this embodiment, according to the target value-taking rule, a field value is taken out from the field value range corresponding to each request parameter field, and the field value is used as the target value corresponding to each request parameter field. And assigning values to the request parameter fields according to the target values corresponding to the request parameter fields, and taking the assigned request parameter fields as interface test cases to test each interface in the RMB.
Further, after the step S30, the method further includes:
generating an interface test case set according to the interface test case, the service ID, the service scene number and the case execution logic, and storing the interface test case set;
and generating and displaying a corresponding test report according to the test type, a preset report template and the test result of the interface test case set.
In this embodiment, after the interface test case is executed, a directory named by the service ID and the service scenario number is created, and the directory includes all the generated interface test cases, so as to generate an interface test case set. Through the above manner, the creation, storage, and execution of the RMB interface test case are completed in this embodiment, and further, the present embodiment further includes a report output of the test case, that is, a corresponding type report template is determined in a preset report template through the test type of the interface test case. And filling the test results generated by the interface test case set, namely the test parameter fields and the corresponding assignments, and the result of assertion verification into the corresponding area of the report template of the corresponding type to generate a corresponding test report. In the specific embodiment, the case generated by the scheme supports smoking test, regression test, integration test, function test and performance test. The testing of each stage is completed by carrying out different parameter configurations. After each test is completed, test reports with different results are generated. The test case method in the embodiment can support various forms such as simple JSON bodies, complex JSON bodies, BODY of HTTP, URL parameters and the like. Therefore, the automatic case generation is completed based on JSON/HTTP BODY/URL and other format request messages, and the whole automatic closed-loop process protection of the case generation method in various testing stages such as smoking, regression, integration, function and performance is realized, namely, no external intervention is needed.
Further, after the step of generating and displaying the corresponding test report according to the test type, the preset report template and the execution result of the interface test case set, the method further includes:
and when an adjusting instruction triggered by the user based on the test report is received, correspondingly adjusting and repairing the interface test case set to optimize the interface test case set.
In this embodiment, the interface test case set may further support the user to add, delete, change, check, import, and export test cases. The method specifically includes manually reviewing the test cases in the test case set and the corresponding test results, correspondingly adding, deleting and modifying the test cases according to the test results, and inquiring the corresponding test cases to be rolled according to the case numbers of the test cases to perform accurate modification, or importing the test cases in other test case sets, or exporting the test cases in the test case set to other test case sets, and the like. Therefore, the generation resources of the test cases are saved, the case generation efficiency of each test case set is improved, and the integrity of each test case set is improved. In further embodiments, test cases corresponding to smoking tests or performance tests can be generated by inputting the number of threads and the number of cycles. Wherein, the number of smoking test lines is =1, and the number of cycles is =1; the number of the performance test lines = M, and the number of the cycles = N. And M and N respectively take different values, and when the performance test is regressed, the M and N are the number of threads and the number of cycles under the optimal performance tested by the performance result. For the first test, M =10, then M =20, 40, 60, 80 were used, i.e. sequentially increasing according to the 20 standard.
When receiving a test request, the embodiment determines a target interface document corresponding to the test request, and acquires each request parameter field in the target interface document; determining a preset field value range corresponding to each request parameter field according to the field type of each request parameter field, and determining a target value rule of each request parameter field according to the test type corresponding to the test request; and taking out corresponding target values in field value ranges corresponding to the request parameter fields according to the target value taking rules, and assigning the request parameter fields according to the target values to generate corresponding interface test cases. Through the mode, the method and the device are based on the request parameter field in the target interface document, and the field type, the preset field value range and the field value rule of the parameter field are combined, so that the rapid generation and batch generation of the cases are realized, the diversity, completeness and accuracy of the test cases are improved, and the technical problems of low compiling efficiency and lower case test accuracy of the conventional interface test cases are solved.
Further, based on the first embodiment of the generation method of the interface test case of the present invention, a second embodiment of the generation method of the interface test case of the present invention is provided.
In this embodiment, the step S30 specifically includes:
if the target value-taking rule is a full-field value-taking rule, taking out a corresponding safety value in a field value-taking range corresponding to each request parameter field as the target value;
and assigning values to the request parameter fields according to the target values corresponding to the request parameter fields to generate full-field test cases as the interface test cases.
In this embodiment, if the test type is a single full-field test type, the target value-taking rule is a full-field value-taking rule, where the full-field value-taking rule is a security value corresponding to each requested parameter field, and performs corresponding value assignment on each requested parameter field to generate a group of full-field test cases, that is, a group of standard cases. The safety value is a legal value of each parameter field in the RMB message, and different parameter field types correspond to different legal values. The security value belongs to one of the values in the predefined field value range corresponding to the request parameter field. The set of standard cases includes all parameter fields of the interface to be tested, namely all request parameter fields in the target interface document, and the value of each request parameter field is the safety value in the type of the respective request parameter field. And carrying out standardized test on each request parameter field through the full-field test case, namely judging whether each request parameter field can be normally executed when being assigned with a safety value.
Further, based on the first embodiment of the method for generating an interface test case of the present invention, a third embodiment of the method for generating an interface test case of the present invention is provided.
In this embodiment, the step S30 specifically includes:
if the target value-taking rule is a mandatory field value-taking rule, determining mandatory parameter fields in each request parameter field according to the mandatory field identification, and sequentially adding the mandatory parameter fields to a mandatory parameter field queue;
taking out corresponding safety values in other optional parameter fields and field value ranges corresponding to the optional parameter fields as the target values, and assigning the other optional parameter fields and the optional parameter fields according to the target values to generate a first test case;
according to the field sequence in the optional parameter field queue, sequentially taking each optional parameter field in the optional parameter field queue as an optional parameter field to be tested;
assigning the parameter fields to be tested to be null values, assigning other parameter fields except the parameter fields to be tested and other optional parameter fields to be corresponding safety values, and generating test cases of the parameter fields to be tested corresponding to the optional parameter fields to be tested, wherein the number of the test cases of the optional parameter fields to be tested is equal to the number of the optional parameter fields;
and generating a mandatory field test case as the interface test case according to each mandatory field test case to be tested and the first test case.
In this embodiment, if the test type is a mandatory field test type, the target value rule is a mandatory field value rule, where the mandatory field value rule is to assign safety values to each mandatory parameter field and optional parameter fields to test whether each mandatory parameter field can be normally executed, then assign null values to each mandatory parameter field in sequence, and assign safety values to other optional parameter fields, that is, assign null values to each mandatory parameter field in sequence, so as to test whether each mandatory parameter field can obtain a corresponding abnormal test result when a certain field is a null value. Specifically, the method comprises the following steps:
3.1. firstly, selecting a field with a field mark of 'yes', namely a mandatory parameter field, and generating a mandatory parameter field queue according to the mandatory parameter field. And assigning all the optional parameter fields in the optional parameter field queue to corresponding safety values, and assigning other optional parameter fields to corresponding safety values or assigning other optional parameter fields to null values, namely preventing the assignment of other optional parameter fields from influencing the assignment result of the optional parameter fields. Thus, a first test case of the mandatory parameter fields is generated.
3.2. And then taking the first optional parameter field in the optional parameter field queue as an optional parameter field to be tested, assigning the first optional parameter field as a null value, or not assigning the first optional parameter field, assigning the rest optional parameter fields in the optional parameter field queue, namely other optional parameter fields, as well as other optional parameter fields as safety values, thereby generating a first optional field test case to be tested.
3.n: and by analogy, if n optional parameter fields exist in the optional parameter field queue, taking the nth optional parameter field in the optional parameter field queue as an optional parameter field to be tested, assigning the nth optional parameter field as a null value, or not assigning the nth optional parameter field, assigning the rest optional parameter fields in the optional parameter field queue, namely other optional parameter fields, as safety values, and thus generating the nth optional field test case to be tested.
In summary, the optional field test cases are generated by combining the test cases of the optional fields to be tested and the first test case. And testing the optional parameter fields in each request parameter field through the optional field test case.
Further, based on the first embodiment of the method for generating interface test cases of the present invention, a fourth embodiment of the method for generating interface test cases of the present invention is provided.
In this embodiment, the step S30 specifically includes:
if the target value-taking rule is a value-taking rule of each field, sequentially acquiring each request parameter field as a target parameter field;
taking out a corresponding target value in a field value range corresponding to the target parameter field, wherein the target value comprises at least one of an overlong parameter value, an upper boundary value, a lower boundary value, a null value and other types of parameter values;
assigning values to the target parameter fields according to the target values, assigning values to other request parameter fields except the target parameter fields as safety values, and generating test cases of fields to be tested corresponding to the request parameter fields;
and generating each field test case according to each field test case to be tested as the interface test case, wherein the number of the field test cases to be tested is equal to the number of the request parameter fields.
In this embodiment, if the test type is the test type of each field, the target value-taking rule is the value-taking rule of each field. And the field value-taking rule is used for carrying out value assignment on each request parameter field so as to carry out single comprehensive test on each request parameter field. The field value range can include a safety value, an ultra-long parameter value, an upper boundary value, a lower boundary value, a null value, other types of parameter values and the like, wherein the target value to be taken by each field test case is at least one of the ultra-long parameter value, the upper boundary value, the lower boundary value, the null value and other types of parameter values. And then, assigning the other request parameter fields as safe values to prevent the assignment of the other request parameter fields from influencing the test result of the target parameter field. Specifically, the method comprises the following steps:
4.1, acquiring a first request parameter field as a target parameter field, and judging the target parameter field, namely the field type and the specified length of the first request parameter field. Preferentially testing the length boundary, generating a value A1 which exceeds the designated length of the field, namely an overlong parameter value, then taking out other various values except a safety value from the value range of the field, namely an upper boundary value, a lower boundary value, a null value, other types of parameter values and the like, and recording the values as A2, A3 and AK, wherein K is the number of values which can be currently taken, namely the number of target values. And the other request parameter fields respectively take the security values corresponding to the parameter fields and are marked as Z [ M ]. Wherein, M is then used A1 … … AK and Z [ M ] to generate K groups of test cases, namely A1Z [ M ], A2Z [ M ], A3Z [ M ]. AKZ [ M ];
and 4.2, sequentially taking the second request parameter field as a target parameter field, and judging the target parameter field, namely the field type and the specified length of the second request parameter field. Preferentially testing the length boundary, generating a value B1 which exceeds the designated length of the field, namely an ultra-long parameter value, then taking out other various values except the safety value from the field value range, namely an upper boundary value, a lower boundary value, a null value, other types of parameter values and the like, and recording the values as B2, B3 and BJ, wherein J is the number of values which can be currently taken, namely the number of target values. And the other request parameter fields respectively take the safety values corresponding to the parameter fields and are marked as Y [ M ]. Wherein, M is then B1 … … BJ and Z [ M ] are used to generate J groups of test cases, namely B1Z [ M ], B2Z [ M ], B3Z [ M ]. BJZ [ M ];
4.n, sequentially fetching the nth field, wherein n is the number of the request parameter fields, and repeating the above operations until all the request parameter fields are traversed and fetched.
In summary, the field test cases are generated according to the sets of test cases in the fourth embodiment. And comprehensively testing the fields of the request parameter fields through the field test cases. In further embodiments, one, two or all of the full field test type, the mandatory field test type and each field test type may be performed on each request parameter at the same time.
The invention also provides a device for generating the interface test case, which comprises:
the parameter field acquisition module is used for determining a target interface document corresponding to a test request when the test request is received and acquiring each request parameter field in the target interface document;
a value rule determining module, configured to determine, according to the field type of each request parameter field, a preset field value range corresponding to each request parameter field, and determine, according to the test type corresponding to the test request, a target value rule of each request parameter field;
and the test case generation module is used for taking out corresponding target values in field value ranges corresponding to the request parameter fields according to the target value taking rules, and carrying out assignment on the request parameter fields according to the target values to generate corresponding interface test cases.
Further, the value rule determining module specifically includes:
a value range determining unit, configured to determine, according to the field type of each request parameter field, a preset field value range corresponding to each request parameter field in a preset database;
a test type determining unit, configured to determine the target test type in the full field test type, the mandatory field test type, and each field test type according to a test type corresponding to the test request;
and the value-taking rule determining unit is used for determining the target value-taking rule in the full-field value-taking rule, the mandatory field value-taking rule and each field value-taking rule according to the target test type.
Further, the test case generating module specifically includes:
a value determining unit, configured to take out a corresponding security value within a field value range corresponding to each request parameter field as the target value if the target value rule is a full-field value rule;
and the field assignment unit is used for assigning values to the request parameter fields according to the target values corresponding to the request parameter fields to generate a full-field test case as the interface test case.
Further, the test case generation module is specifically further configured to:
if the target value-taking rule is a mandatory field value-taking rule, determining mandatory parameter fields in each request parameter field according to the mandatory field identification, and sequentially adding the mandatory parameter fields to a mandatory parameter field queue;
taking out corresponding security values from other optional parameter fields and field value ranges corresponding to the optional parameter fields as the target values, and assigning the other optional parameter fields and the optional parameter fields according to the target values to generate a first test case;
according to the field sequence in the optional parameter field queue, sequentially taking each optional parameter field in the optional parameter field queue as an optional parameter field to be tested;
assigning the optional parameter fields to be tested as null values, assigning other optional parameter fields except the optional parameter fields to be tested and other optional parameter fields as corresponding safety values, and generating optional field test cases to be tested corresponding to the optional parameter fields to be tested, wherein the number of the optional field test cases to be tested is equal to that of the optional parameter fields;
and generating a mandatory field test case as the interface test case according to each mandatory field test case to be tested and the first test case.
Further, the test case generation module is specifically further configured to:
if the target value-taking rule is a value-taking rule of each field, sequentially acquiring each request parameter field as a target parameter field;
taking out a corresponding target value in a field value range corresponding to the target parameter field, wherein the target value comprises at least one of an overlong parameter value, an upper boundary value, a lower boundary value, a null value and other types of parameter values;
assigning values to the target parameter fields according to the target values, assigning values to other request parameter fields except the target parameter fields as safety values, and generating test cases of each field to be tested corresponding to each request parameter field;
and generating each field test case according to each field test case to be tested as the interface test case, wherein the number of the field test cases to be tested is equal to the number of the request parameter fields.
Further, the parameter field obtaining module is further configured to:
and when a test request is received, acquiring a page request in the test request, and determining a corresponding target interface document in a file server according to the page request, wherein the page request comprises http or post.
Further, the device for generating the interface test case further includes:
the case set generating module is used for generating an interface test case set according to the interface test case, the service ID, the service scene number and the case execution logic and storing the interface test case set;
and the test report generating module is used for generating and displaying a corresponding test report according to the test type, the preset report template and the test result of the interface test case set.
Further, the apparatus for generating an interface test case further includes:
and the case set optimization module is used for correspondingly adjusting and repairing the interface test case set when receiving an adjusting instruction triggered by the user based on the test report so as to optimize the interface test case set.
The method executed by each program module can refer to each embodiment of the interface test case generation method of the present invention, and details are not repeated here.
The invention also provides a computer readable storage medium.
The computer-readable storage medium of the present invention stores thereon a generation program of interface test cases, which when executed by a processor implements the steps of the generation method of interface test cases as described above.
The method implemented when the generating program of the interface test case running on the processor is executed may refer to each embodiment of the generating method of the interface test case of the present invention, and details are not described here.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention or the portions contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) as described above and includes several instructions for enabling a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (16)

1. A generation method of an interface test case is characterized by comprising the following steps:
when a test request is received, determining a target interface document corresponding to the test request, and acquiring each request parameter field in the target interface document;
determining a preset field value range corresponding to each request parameter field according to the field type of each request parameter field, and determining a target value rule of each request parameter field according to the test type corresponding to the test request;
and taking out corresponding target values in field value ranges corresponding to the request parameter fields according to the target value taking rules, and assigning the request parameter fields according to the target values to generate corresponding interface test cases.
2. The method for generating an interface test case according to claim 1, wherein the step of determining the preset field value range corresponding to each request parameter field according to the field type of each request parameter field, and the step of determining the value rule of each request parameter field according to the test type corresponding to the test request specifically include:
determining a preset field value range corresponding to each request parameter field in a preset database according to the field type of each request parameter field;
determining a target test type in the full field test type, the mandatory field test type and each field test type according to the test type corresponding to the test request;
and determining the target value-taking rule in a full-field value-taking rule, a mandatory field value-taking rule and each field value-taking rule according to the target test type.
3. The method for generating interface test cases according to claim 2, wherein the step of taking out a corresponding target value from the field value range corresponding to each requested parameter field according to the target value-taking rule, and assigning values to each requested parameter field according to the target value to generate a corresponding interface test case specifically comprises:
if the target value-taking rule is a full-field value-taking rule, taking out a corresponding safety value in a field value-taking range corresponding to each request parameter field as the target value;
and assigning values to the request parameter fields according to the target values corresponding to the request parameter fields to generate full-field test cases as the interface test cases.
4. The method for generating an interface test case according to claim 2, wherein the step of taking out a corresponding target value from a field value range corresponding to each requested parameter field according to the target value-taking rule, and assigning values to each requested parameter field according to the target value to generate a corresponding interface test case specifically comprises:
if the target value-taking rule is a mandatory field value-taking rule, determining mandatory parameter fields in each request parameter field according to the mandatory field identification, and sequentially adding the mandatory parameter fields to a mandatory parameter field queue;
taking out corresponding safety values in other optional parameter fields and field value ranges corresponding to the optional parameter fields as the target values, and assigning the other optional parameter fields and the optional parameter fields according to the target values to generate a first test case;
according to the field sequence in the optional parameter field queue, sequentially taking each optional parameter field in the optional parameter field queue as an optional parameter field to be tested;
assigning the optional parameter fields to be tested as null values, assigning other optional parameter fields except the optional parameter fields to be tested and other optional parameter fields as corresponding safety values, and generating optional field test cases to be tested corresponding to the optional parameter fields to be tested, wherein the number of the optional field test cases to be tested is equal to that of the optional parameter fields;
and generating a mandatory field test case as the interface test case according to each mandatory field test case to be tested and the first test case.
5. The method for generating an interface test case according to claim 2, wherein the step of taking out a corresponding target value from a field value range corresponding to each requested parameter field according to the target value-taking rule, and assigning values to each requested parameter field according to the target value to generate a corresponding interface test case specifically comprises:
if the target value-taking rule is a value-taking rule of each field, sequentially acquiring each request parameter field as a target parameter field;
taking out a corresponding target value in a field value range corresponding to the target parameter field, wherein the target value comprises at least one of an overlong parameter value, an upper boundary value, a lower boundary value, a null value and other types of parameter values;
assigning values to the target parameter fields according to the target values, assigning values to other request parameter fields except the target parameter fields as safety values, and generating test cases of each field to be tested corresponding to each request parameter field;
and generating each field test case according to each field test case to be tested as the interface test case, wherein the number of the field test cases to be tested is equal to the number of the request parameter fields.
6. The method for generating interface test cases according to claim 1, wherein the method for generating interface test cases further comprises:
generating an interface test case set according to the interface test case, the service ID, the service scene number and the case execution logic, and storing the interface test case set;
and generating and displaying a corresponding test report according to the test type, a preset report template and the test result of the interface test case set.
7. The method for generating interface test cases according to claim 6, wherein after the step of generating and displaying the corresponding test report according to the test type, the preset report template, and the execution result of the interface test case set, the method further comprises:
and when an adjusting instruction triggered by the user based on the test report is received, correspondingly adjusting and repairing the interface test case set so as to optimize the interface test case set.
8. The method for generating an interface test case according to any one of claims 1 to 7, wherein the step of determining the target interface document corresponding to the test request when the test request is received specifically includes:
and when a test request is received, acquiring a page request in the test request, and determining a corresponding target interface document in a file server according to the page request, wherein the page request comprises http or post.
9. An interface test case generation device, characterized in that the interface test case generation device comprises:
the parameter field acquisition module is used for determining a target interface document corresponding to a test request when the test request is received and acquiring each request parameter field in the target interface document;
a value rule determining module, configured to determine, according to the field type of each request parameter field, a preset field value range corresponding to each request parameter field, and determine, according to the test type corresponding to the test request, a target value rule of each request parameter field;
and the test case generation module is used for taking out a corresponding target value from a field value range corresponding to each request parameter field according to the target value taking rule, assigning values to each request parameter field according to the target value and generating a corresponding interface test case.
10. The apparatus for generating an interface test case according to claim 9, wherein the value rule determining module specifically includes:
a value range determining unit, configured to determine, according to the field type of each request parameter field, a preset field value range corresponding to each request parameter field in a preset database;
the test type determining unit is used for determining a target test type in the full field test type, the optional field test type and each field test type according to the test type corresponding to the test request;
and the value rule determining unit is used for determining the target value rule in the full field value rule, the mandatory field value rule and each field value rule according to the target test type.
11. The apparatus for generating interface test cases according to claim 10, wherein the test case generation module specifically includes:
a value determining unit, configured to, if the target value-taking rule is a full-field value-taking rule, take out a corresponding security value within a field value-taking range corresponding to each request parameter field, and take the security value as the target value;
and the field assignment unit is used for assigning values to the request parameter fields according to the target values corresponding to the request parameter fields to generate full-field test cases as the interface test cases.
12. The apparatus for generating interface test cases according to claim 10, wherein the test case generation module is further configured to:
if the target value-taking rule is a mandatory field value-taking rule, determining mandatory parameter fields in each request parameter field according to the mandatory field identification, and sequentially adding the mandatory parameter fields to a mandatory parameter field queue;
taking out corresponding safety values in other optional parameter fields and field value ranges corresponding to the optional parameter fields as the target values, and assigning the other optional parameter fields and the optional parameter fields according to the target values to generate a first test case;
according to the field sequence in the optional parameter field queue, sequentially taking each optional parameter field in the optional parameter field queue as an optional parameter field to be tested;
assigning the optional parameter fields to be tested as null values, assigning other optional parameter fields except the optional parameter fields to be tested and other optional parameter fields as corresponding safety values, and generating optional field test cases to be tested corresponding to the optional parameter fields to be tested, wherein the number of the optional field test cases to be tested is equal to that of the optional parameter fields;
and generating a mandatory field test case as the interface test case according to each mandatory field test case to be tested and the first test case.
13. The apparatus for generating interface test cases according to claim 10, wherein the test case generation module is further configured to:
if the target value-taking rule is a value-taking rule of each field, sequentially acquiring each request parameter field as a target parameter field;
taking out a corresponding target value in a field value range corresponding to the target parameter field, wherein the target value comprises at least one of an overlong parameter value, an upper boundary value, a lower boundary value, a null value and other types of parameter values;
assigning values to the target parameter fields according to the target values, assigning values to other request parameter fields except the target parameter fields as safety values, and generating test cases of each field to be tested corresponding to each request parameter field;
and generating each field test case according to each field test case to be tested as the interface test case, wherein the number of the field test cases to be tested is equal to the number of the request parameter fields.
14. The apparatus for generating interface test cases according to any of claims 9-13, wherein the parameter field obtaining module is further configured to:
and when a test request is received, acquiring a page request in the test request, and determining a corresponding target interface document in a file server according to the page request, wherein the page request comprises http or post.
15. An interface test case generation device, comprising:
a memory, a processor and a program for generating interface test cases which is stored in the memory and can be run on the processor, the program for generating interface test cases, when executed by the processor, implementing the steps of the method for generating interface test cases as claimed in any one of claims 1 to 8.
16. A computer-readable storage medium, in which a generation program of interface test cases is stored, which when executed by a processor implements the steps of the generation method of interface test cases according to any one of claims 1 to 8.
CN201910564382.3A 2019-06-25 2019-06-25 Interface test case generation method, device, equipment and storage medium Active CN110334021B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910564382.3A CN110334021B (en) 2019-06-25 2019-06-25 Interface test case generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910564382.3A CN110334021B (en) 2019-06-25 2019-06-25 Interface test case generation method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110334021A CN110334021A (en) 2019-10-15
CN110334021B true CN110334021B (en) 2023-04-18

Family

ID=68144064

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910564382.3A Active CN110334021B (en) 2019-06-25 2019-06-25 Interface test case generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110334021B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111478969A (en) * 2020-04-09 2020-07-31 吉林亿联银行股份有限公司 Interface checking method and device
CN111897712A (en) * 2020-06-20 2020-11-06 中国建设银行股份有限公司 Test case generation method and device, electronic equipment and readable storage medium
CN111813680B (en) * 2020-07-13 2023-05-26 建信金融科技有限责任公司 Method and device for generating test script, computer equipment and storage medium
CN112380142A (en) * 2020-12-11 2021-02-19 上海中通吉网络技术有限公司 Interface document management method and device and test equipment
CN112905459B (en) * 2021-02-08 2024-05-03 中国工商银行股份有限公司 Service interface testing method and device, electronic equipment and storage medium
CN112948195B (en) * 2021-03-31 2023-04-25 建信金融科技有限责任公司 Interface testing method, 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
CN113742242A (en) * 2021-09-16 2021-12-03 中国银行股份有限公司 Interface testing method and device
CN113821800A (en) * 2021-09-29 2021-12-21 重庆紫光华山智安科技有限公司 Data uploading interface test method and system, electronic equipment and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102968370A (en) * 2012-11-26 2013-03-13 中国电信股份有限公司云计算分公司 Test data generating method and device
CN106155891A (en) * 2015-04-02 2016-11-23 阿里巴巴集团控股有限公司 Interface test method, interface description data library generating method and device
WO2017096990A1 (en) * 2015-12-07 2017-06-15 中兴通讯股份有限公司 Method and device for automatically generating test script
CN106897205A (en) * 2015-12-18 2017-06-27 阿里巴巴集团控股有限公司 A kind of test data generating method and device
CN109189666A (en) * 2018-08-02 2019-01-11 腾讯科技(北京)有限公司 Interface test method, device and computer equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102968370A (en) * 2012-11-26 2013-03-13 中国电信股份有限公司云计算分公司 Test data generating method and device
CN106155891A (en) * 2015-04-02 2016-11-23 阿里巴巴集团控股有限公司 Interface test method, interface description data library generating method and device
WO2017096990A1 (en) * 2015-12-07 2017-06-15 中兴通讯股份有限公司 Method and device for automatically generating test script
CN106897205A (en) * 2015-12-18 2017-06-27 阿里巴巴集团控股有限公司 A kind of test data generating method and device
CN109189666A (en) * 2018-08-02 2019-01-11 腾讯科技(北京)有限公司 Interface test method, device and computer equipment

Also Published As

Publication number Publication date
CN110334021A (en) 2019-10-15

Similar Documents

Publication Publication Date Title
CN110334021B (en) Interface test case generation method, device, equipment and storage medium
CN107908541B (en) Interface testing method and device, computer equipment and storage medium
CN105094783B (en) method and device for testing stability of android application
CN108628748B (en) Automatic test management method and automatic test management system
CN104834602B (en) A kind of program dissemination method, device and program delivery system
WO2019075994A1 (en) Method, device and system for mock data at ios end, and storage medium
CN110532182B (en) Automatic testing method and device for virtualization platform
CN110569159A (en) Baffle generation method, device, equipment and computer storage medium
CN111026670B (en) Test case generation method, test case generation device and storage medium
CN110688305B (en) Test environment synchronization method, device, medium and electronic equipment
CN111475390A (en) Log collection system deployment method, device, equipment and storage medium
CN112579455B (en) Automatic interface testing method and device, electronic equipment and storage medium
CN110674083A (en) Workflow migration method, device, equipment and computer readable storage medium
WO2021008576A1 (en) Context information management method, device, and system, and computer-readable storage medium
CN112035344A (en) Multi-scenario test method, device, equipment and computer readable storage medium
CN112181477A (en) Complex event processing method and device and terminal equipment
CN111045941B (en) Positioning method and device for user interface control and storage medium
CN110908708B (en) Code release method, device and system
CN107357721B (en) Method and device for testing system
CN115617780A (en) Data import method, device, equipment and storage medium
CN111796578A (en) Vehicle controller testing method, device and system and storage medium
CA3138761A1 (en) Method, device, computer equipment and storage medium for verifying inter-system data admission
CN112561690B (en) Method, system, equipment and storage medium for testing credit card staged service interface
CN113238935A (en) Application testing method, system, device, medium, and computer program product
CN111767218A (en) Automatic testing method, equipment and storage medium for continuous integration

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
GR01 Patent grant
GR01 Patent grant