CN117312168A - 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
CN117312168A
CN117312168A CN202311384852.0A CN202311384852A CN117312168A CN 117312168 A CN117312168 A CN 117312168A CN 202311384852 A CN202311384852 A CN 202311384852A CN 117312168 A CN117312168 A CN 117312168A
Authority
CN
China
Prior art keywords
preset
abnormal
interface
test data
test
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311384852.0A
Other languages
Chinese (zh)
Inventor
郑艳辉
刘荣伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan Aishu Information Technology Group Co ltd
Original Assignee
Hunan Aishu Information Technology Group 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 Hunan Aishu Information Technology Group Co ltd filed Critical Hunan Aishu Information Technology Group Co ltd
Priority to CN202311384852.0A priority Critical patent/CN117312168A/en
Publication of CN117312168A publication Critical patent/CN117312168A/en
Pending legal-status Critical Current

Links

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. Analyzing the interface document to determine key parameters corresponding to the interface document; inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document; determining a normal test data set corresponding to the interface document by using a preset random generation algorithm according to the key parameters; and generating an interface test case according to the abnormal test data set and the normal test data set. The method solves the problems of low generation efficiency, incomplete coverage and the like of the interface test cases caused by the fact that a worker is required to manually write the interface test cases depending on own experience in the existing interface test case generation method, and achieves the beneficial effects of effectively improving the generation efficiency and coverage rate of the interface test cases.

Description

Interface test case generation method, device, equipment and storage medium
Technical Field
The present invention relates to the field of interface testing technologies, and in particular, to a method, an apparatus, a device, and a storage medium for generating an interface test case.
Background
Interface testing is a test of interfaces between test systems or components, and is mainly to verify the exchange, transfer and control management processes of data, and the mutual logic relationship. The interface test depends on the interface test case, which is an important link in quality assurance and needs continuous writing and maintenance.
In the existing interface test case generation method, the problems of low efficiency, incomplete coverage and the like of the interface test case generation exist.
Disclosure of Invention
The invention provides a method, a device, equipment and a storage medium for generating an interface test case, which are used for solving the problems of low efficiency, incomplete coverage and the like of the generation of the interface test case in the existing method for generating the interface test case.
According to an aspect of the present invention, there is provided an interface test case generation method, including:
analyzing the interface document, and determining key parameters corresponding to the interface document;
inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document;
determining a normal test data set corresponding to the interface document by using a preset random generation algorithm according to the key parameters;
and generating an interface test case according to the abnormal test data set and the normal test data set.
According to another aspect of the present invention, there is provided an interface test case generating apparatus including:
the parameter acquisition module is used for analyzing the interface document and determining key parameters corresponding to the interface document;
the first determining module is used for inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document;
The second determining module is used for determining a normal test data set corresponding to the interface document by using a preset random generation algorithm according to the key parameters;
and the case generation module is used for generating an interface test case according to the abnormal test data set and the normal test data set.
According to another aspect of the present invention, there is provided an interface test case generating apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the interface test case generation method of any one of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement the interface test case generation method of any of the embodiments of the present invention when executed.
According to the technical scheme provided by the embodiment of the invention, the interface document is analyzed, and the key parameters corresponding to the interface document are determined; inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document; determining a normal test data set corresponding to the interface document by using a preset random generation algorithm according to the key parameters; and generating an interface test case according to the abnormal test data set and the normal test data set. According to the technical scheme, the key parameters are input into the preset test model, the abnormal test data set corresponding to the interface document can be obtained by using the preset test model, meanwhile, the normal test data set corresponding to the interface document can be determined by using the preset random generation algorithm according to the key parameters, a worker does not need to write the abnormal test data manually, and further, the interface test case is generated according to the abnormal test data set and the normal test data set. The method solves the problems of low generation efficiency, incomplete coverage and the like of the interface test cases caused by the fact that a worker is required to manually write the interface test cases depending on own experience in the existing interface test case generation method, and achieves the beneficial effects of effectively improving the generation efficiency and coverage rate of the interface test cases.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for generating an interface test case according to a first embodiment of the present invention;
FIG. 2 is a flowchart of a method for generating an interface test case according to a second embodiment of the present invention;
FIG. 3 is a schematic structural diagram of an interface test case generating device according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an interface test case generating device according to a fourth embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of an interface test case generating method provided in the first embodiment of the present invention, where the embodiment is applicable to generate an interface test case, and the method may be performed by an interface test case generating device, where the interface test case generating device may be implemented in a form of hardware and/or software, and the interface test case generating device may be configured in an interface test case generating device. As shown in fig. 1, the method includes:
S110, analyzing the interface document, and determining key parameters corresponding to the interface document.
In this embodiment, the interface document is a description document for describing an interface provided by a system component. In the project development process, because front and rear ends are separated and developed, front and rear end engineers are required to define interfaces together, write interface documents, and then develop according to the interface documents, wherein the interface documents are required to be maintained before the project is finished. The key parameters are related information contained in the interface document, such as information of a request address, a request method, a request header, a request parameter, a parameter type, a response parameter and the like in the interface document.
Specifically, when the interface test case is generated, the interface document provided by the developer can be obtained, and further, the key parameters corresponding to the interface document can be obtained by analyzing the interface document.
S120, inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document.
In this embodiment, the preset test model is a model that is built in advance and used for generating the abnormal test data set. The abnormal test data is test data required when the interface abnormal test is performed. The anomaly test data set includes a plurality of anomaly test data.
Specifically, the abnormal test data is one of important bases for generating the interface test cases, in the prior art, generally, a worker is required to write the test data manually according to test experience, so that the efficiency of the interface test cases is very low in generation, particularly in large-scale development, a large amount of time is occupied by the worker, therefore, a preset test model is built in advance, the obtained key parameters are input into the preset test model, the abnormal test data corresponding to the interface document can be obtained by using the preset test model, and an abnormal test data set is generated by the abnormal test data. The abnormal test data set is obtained through the preset test model, so that the workload of workers can be greatly reduced, and the working efficiency is effectively improved.
Optionally, the preset test model includes: the method comprises the steps of presetting an interface type and a preset abnormal test data set corresponding to the preset interface type; the preset abnormal test data set comprises a plurality of preset abnormal test data, wherein the preset abnormal test data comprises preset abnormal data corresponding to a preset interface type, an expected result corresponding to the preset abnormal data and an abnormal error report corresponding to the preset abnormal data.
The preset interface type comprises relevant parameter types corresponding to the interface document, such as int type, character type and the like. The preset abnormal data corresponding to the preset interface type comprises parameters which are set according to interface test experience, for example, the parameter type is int type, and the corresponding abnormal data type is 0, -1, 0.1, & gt, a, chinese characters, character strings, blank spaces and the like. The expected result corresponding to the preset abnormal data is 400, and is generally fixed, and the error reporting corresponding to the preset abnormal data can be written according to the interface test experience, for example, the error reporting corresponding to the preset abnormal data can be "parameter type error". By constructing the preset test model, the workload of workers can be greatly reduced, and the efficiency of generating the interface test cases is improved.
S130, determining a normal test data set corresponding to the interface document by using a preset random generation algorithm according to the key parameters.
In this embodiment, the preset random generation algorithm is an algorithm set in advance, and is used for calculating normal test data.
Specifically, considering that normal test data generated correspondingly by different service requirements are different, a random generation algorithm is constructed in advance to automatically generate a normal test data set in order to ensure the comprehensiveness of the test. According to key parameters, a normal test data set corresponding to interface documents of different services is automatically determined by using a built random generation algorithm, and the problems that the efficiency is low, the workload is high and test points are easy to miss due to the fact that normal test data are written manually by current staff are solved.
S140, generating an interface test case according to the abnormal test data set and the normal test data set.
Specifically, the abnormal test data set and the normal test data set are respectively traversed through a traversing algorithm, the traversed results are written into an excel table, the abnormal test data case set and the normal test data case set are generated, and then the abnormal test data case set and the normal test data case set jointly form an interface test case, so that the automatic generation of the interface test case is realized.
According to the technical scheme provided by the embodiment of the invention, the key parameters corresponding to the interface document are determined by analyzing the interface document; inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document; determining a normal test data set corresponding to the interface document by using a preset random generation algorithm according to the key parameters; and generating an interface test case according to the abnormal test data set and the normal test data set. According to the technical scheme, the key parameters are input into the preset test model, the abnormal test data set corresponding to the interface document can be obtained by using the preset test model, meanwhile, the normal test data set corresponding to the interface document can be determined by using the preset random generation algorithm according to the key parameters, a worker does not need to write the abnormal test data manually, and further, the interface test case is generated according to the abnormal test data set and the normal test data set. The method solves the problems of low generation efficiency, incomplete coverage and the like of the interface test cases caused by the fact that a worker is required to manually write the interface test cases depending on own experience in the existing interface test case generation method, and achieves the beneficial effects of effectively improving the generation efficiency and coverage rate of the interface test cases.
In an alternative embodiment, inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document, including: inputting the key parameters into a preset test model, determining a target preset interface type corresponding to the parameter type according to the parameter type in the key parameters through the preset test model, determining a target preset abnormal test data set corresponding to the target preset interface type according to the target preset interface type, and determining an abnormal test data set corresponding to the interface document according to the target preset abnormal test data set. By the method, the abnormal test data set can be accurately and rapidly determined.
The abnormal test data set comprises abnormal test data, the abnormal test data comprises abnormal data, expected results corresponding to the abnormal data and abnormal errors corresponding to the abnormal data, the abnormal data corresponds to target preset abnormal data in the target preset abnormal test data set one by one, the expected results corresponding to the abnormal data corresponds to expected results corresponding to the target preset abnormal data one by one, and the abnormal errors corresponding to the abnormal data correspond to the abnormal errors corresponding to the target preset abnormal data one by one.
In this embodiment, the parameter type in the key parameter is the parameter type in the interface document, and may include the int type. The target preset interface type is a preset interface type in a preset test model determined according to the parameter type of the current key parameter. The target preset abnormal test data set is a preset abnormal test data set in a preset test model determined according to the parameter type of the current key parameter.
Specifically, after the key parameters are input into the preset test model, the preset test model matches preset interface types in the preset test model according to parameter types in the input preset key parameters, the matched preset interface types are determined to be target preset interface types, the preset test model further finds a preset abnormal test data set corresponding to the target preset interface types according to the matched preset interface types, namely the target preset interface types, the preset abnormal test data set is determined to be a target preset abnormal test data set, the target abnormal test data set comprises target abnormal test data, and the target abnormal test data comprises target abnormal data, expected results corresponding to the target abnormal data and abnormal errors corresponding to the target abnormal data.
Example two
Fig. 2 is a flowchart of a method for generating an interface test case according to a second embodiment of the present invention, where the method is optimized and expanded based on the foregoing alternative embodiments, and the process of generating a normal test data set is described in this embodiment. As shown in fig. 2, the method includes:
s210, analyzing the interface document, and determining key parameters corresponding to the interface document.
S220, inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document.
S230, determining a plurality of scattered point values according to a preset value range and a preset step length; the preset value range is determined according to a plurality of preset key points in the data range constraint corresponding to the parameter types in the key parameters.
In this embodiment, the preset key points are set according to actual requirements. The preset value range includes preset values, and in order to ensure the comprehensiveness of the generated normal test data, the endpoints at two ends of the preset value range are generally far away from the key points. The preset step length is set according to actual requirements. The scattered point value comprises data obtained by traversing a preset value range in a preset step length.
Specifically, analyzing an interface document, determining key parameters of the interface document, wherein the key parameters comprise parameter types and data range constraints corresponding to the parameter types, setting preset key points corresponding to the data range constraints according to requirements, and further determining a preset value range according to the preset key points; simultaneously setting a preset step length; and then traversing a preset value range with a preset step length to determine a plurality of scattered point values.
By analyzing the interface document, the parameter type of the interface document is determined to be int type, and the preset key point corresponding to the data range constraint is set as (3, 10 and 19) according to the requirement. And then determining a preset value range (-10, 50) according to the key points, and setting the preset step length to be 1. Further, a plurality of scatter values may be generated by traversing a predetermined range of values (-10, 50) with a predetermined step size 1, the scatter values comprising: -9, -8, -7, -6, -5, -4, -3, -2, -1, 0,1, 2, 3, 4, 5.
S240, calculating the minimum absolute distance between the current scattered point value and a plurality of preset key points according to each scattered point value in the plurality of scattered point values, and determining normal test data corresponding to the current scattered point value according to the minimum absolute distance.
In this embodiment, the minimum absolute distance includes a minimum value of absolute values of differences between the current scatter value and the plurality of preset keypoints.
Specifically, considering that the probability of error of normal test data generated near the key point is large, it is necessary to calculate the minimum absolute distance between the current scatter value and the preset key point. For each of the plurality of scatter values, calculating a minimum absolute distance between the current scatter value and a plurality of preset keypoints, the exemplary keypoints being (3, 10, 19), if the current scatter value is-9, the minimum absolute distance is min (| -9-3|, | -9-10|, | -9-19|) =12; if the current scatter value is 2, the minimum absolute distance is min (|2-3|, |2-10|, |2-19|) =1; by such a push, the minimum absolute distance corresponding to each scatter value can be calculated. And then, according to the minimum absolute distance corresponding to the current scattered point value, determining normal test data corresponding to the current scattered point value.
S250, determining a normal test data set corresponding to the interface document according to the normal test data corresponding to the plurality of scattered point values.
Specifically, the normal test data set corresponding to the interface document is determined by traversing the normal test data corresponding to each of the plurality of scatter values. The present embodiment is not limited to a specific traversal method.
Optionally, the expected result corresponding to the normal test data may also be included in the normal test data set.
S260, generating an interface test case according to the abnormal test data set and the normal test data set.
According to the technical scheme provided by the second embodiment of the invention, an abnormal test data set is determined through a preset test model; determining a plurality of scattered point values according to a preset value range and a preset step length; for each of the plurality of scatter values, calculating a minimum absolute distance between the current scatter value and a plurality of preset key points, and determining normal test data corresponding to the current scatter value according to the minimum absolute distance; and determining a normal test data set corresponding to the interface document according to the normal test data corresponding to the plurality of scattered point values. And generating an interface test case according to the abnormal test data set and the normal test data set. Through the technical scheme, the generation efficiency and the coverage rate of normal test data are effectively improved, the generation efficiency and the coverage rate of interface test cases are further improved, and the workload of staff is greatly reduced.
In some embodiments, determining normal test data corresponding to the current scatter value according to the minimum absolute distance includes: judging whether the minimum absolute distance is zero; if yes, generating normal test data corresponding to the current scattered point value by using a preset boundary value algorithm according to the data range constraint; if not, determining the quantity of normal test data corresponding to the current scattered point value according to the minimum absolute distance and the initialization coefficient; and generating normal test data corresponding to the current scattered point value by utilizing a random function according to the current scattered point value, the preset step length and the number. Through the technical scheme, the coverage rate and quality of normal test data can be effectively improved.
In this embodiment, the preset boundary value algorithm includes a boundary value algorithm set in advance. The initialization coefficients comprise coefficients set according to actual requirements, and different coefficients can be set for different minimum absolute distances.
Specifically, judging whether the minimum absolute distance is zero; if the minimum absolute distance is zero, determining that the scattered point value at the moment is a special value, and further generating normal test data corresponding to the current scattered point value by using a preset boundary value algorithm according to the data range constraint; if the minimum absolute distance is not zero, generating normal test data corresponding to the current scattered point value by using a random function, namely determining the quantity of the normal test data corresponding to the current scattered point value according to the minimum absolute distance and an initialization coefficient; and generating normal test data corresponding to the current scattered point value by utilizing a random function according to the current scattered point value, the preset step length and the number.
For example, taking the current scatter value as 2 and the key points as (3, 10 and 19) as examples, the minimum absolute distance corresponding to the current scatter value can be calculated to be 1, and at the moment, if the minimum absolute distance is not zero, the number of normal test data corresponding to the current scatter value is calculated, and the calculation formula is as follows:
n=w*(1/d) (1)
Wherein n is the number of normal test data corresponding to the current scatter value, w is an initialization coefficient for adjusting the number of normal test data generated near the scatter value, and d is the minimum absolute distance. And setting w to 2, the number of normal test data corresponding to the current scattered point value of 2 can be calculated to be 2.
And then, according to the current scattered point value, the preset step length and the number, generating normal test data corresponding to the current scattered point value by utilizing a random function, wherein the calculation formula is as follows:
random, random (n-preset step, n+preset step) for_in range (n) (2)
In some embodiments, the data range constraint comprises at least one data range constraint; according to the data range constraint, generating normal test data corresponding to the current scattered point value by using a preset boundary value algorithm, wherein the normal test data comprises the following steps: determining boundary test data corresponding to each data range constraint condition in the data range constraint by using a preset boundary algorithm; and generating normal test data corresponding to the current scattered point value according to the boundary test data corresponding to each data range constraint condition. Through the technical scheme, normal test data corresponding to the current scattered point value can be effectively determined through a preset boundary value algorithm.
In this embodiment, the data range constraint is obtained by parsing the interface document.
By way of example, the data range constraint may comprise at least one data range constraint, e.g., the data type is int-type, and the corresponding data range constraint may comprise (a, b), > a, < b, etc., where (a, b), > a, < b are all data range constraints. For different data range constraint conditions, respectively determining boundary test data corresponding to the different data range constraint conditions by using a preset boundary algorithm, and if the data range constraint conditions are (a, b), by using the preset boundary algorithm, for example, determining that the boundary test data corresponding to the data range constraint conditions is: a-1, a, a+1, b-1, b, b+1; if the data range constraint condition is > a, determining that the boundary test data corresponding to the data range constraint condition is: a, a+1; if the data range constraint condition is < b, determining that the boundary test data corresponding to the data range constraint condition is: b-1, b. And then, normal test data corresponding to the current scattered point value is generated by traversing the boundary test data corresponding to each data range constraint condition.
In some optional embodiments, the method for generating an interface test case further includes: according to preset specification information of a preset automation tool, converting the interface test case into an automation script code, and writing the automation script code into a preset file; and executing the automation script code by using the preset automation tool based on the keywords in the preset file.
In this embodiment, the preset automation tool may be a universal test frame, such as an httprenner frame. The preset specification information includes specifications set in advance based on a preset automation tool, for example, only writing into a corresponding field is allowed. The preset file includes a file for saving the interface test case, for example, an excel file. The key word may be the name of the interface test case corresponding to the different modules.
Specifically, in order to facilitate subsequent automated testing, the generated interface test cases need to be converted into automated script code. Based on preset standard information set in advance, converting the interface test case into an automatic script code through a preset automation tool, and writing the automatic script code into a preset file. Illustratively, the generated interface test cases are assembled into json format and written into an excel file. The interface test case is converted into an automatic script code, and the work of writing and maintaining the test case of a worker is reduced. And further executing an automatic script code by using a preset automation tool based on the keywords in the preset file to perform interface test. By the technical scheme provided by the embodiment, the generation efficiency and the generation quality of the interface test cases can be greatly improved, and the test workload of staff is reduced. For each requirement, the product iteration is carried out every two weeks, no additional writing of use cases and automatic scripts is needed by staff, the staff only needs to pay attention to UI tests and tests corresponding to other quality dimensions, daily workload of 3 staff can be saved for each requirement, and a large amount of cost is saved for enterprises with rapid iteration and insufficient resources.
Optionally, during the interface test, it may be verified whether the actual output is consistent with the output thereof, and the test result is continuously recorded. The reliable test structure is provided, so that the positioning and the solving of the test problem are facilitated.
Example III
Fig. 3 is a schematic structural diagram of an interface test case generating device according to a third embodiment of the present invention. As shown in fig. 3, the apparatus includes a parameter acquisition module 31, a first determination module 32, a second determination module 33, and a use case generation module 34.
The parameter obtaining module 31 is configured to parse the interface document and determine key parameters corresponding to the interface document; the first determining module 32 is configured to input the key parameters into a preset test model, and obtain an abnormal test data set corresponding to the interface document; the second determining module 33 is configured to determine, according to the key parameter, a normal test data set corresponding to the interface document by using a preset random generation algorithm; the case generation module 34 is configured to generate an interface test case according to the abnormal test data set and the normal test data set.
The technical scheme provided by the third embodiment of the invention solves the problems of low efficiency, incomplete coverage and the like of the interface test case generation caused by the fact that a worker is required to manually write the interface test case depending on own experience in the existing interface test case generation method, and achieves the beneficial effects of effectively improving the efficiency and coverage rate of the interface test case generation.
Optionally, the preset test model includes:
the method comprises the steps of presetting an interface type and a preset abnormal test data set corresponding to the preset interface type; the preset abnormal test data set comprises a plurality of preset abnormal test data, wherein the preset abnormal test data comprises preset abnormal data corresponding to a preset interface type, an expected result corresponding to the preset abnormal data and an abnormal error report corresponding to the preset abnormal data.
Optionally, the first determining module 32 is specifically configured to input the key parameter into a preset test model, determine, according to a parameter type in the key parameter, a target preset interface type corresponding to the parameter type through the preset test model, determine, according to the target preset interface type, a target preset abnormal test dataset corresponding to the target preset interface type, and determine, according to the target preset abnormal test dataset, an abnormal test dataset corresponding to the interface document;
the abnormal test data set comprises abnormal test data, the abnormal test data comprises abnormal data, expected results corresponding to the abnormal data and abnormal errors corresponding to the abnormal data, the abnormal data corresponds to target preset abnormal data in the target preset abnormal test data set one by one, the expected results corresponding to the abnormal data corresponds to expected results corresponding to the target preset abnormal data one by one, and the abnormal errors corresponding to the abnormal data correspond to the abnormal errors corresponding to the target preset abnormal data one by one.
Optionally, the second determining module 33 includes:
the scattered point value determining submodule is used for determining a plurality of scattered point values according to a preset value range and a preset step length; the preset value range is determined according to a plurality of preset key points in a data range constraint corresponding to the parameter type in the key parameters;
the normal data determining sub-module is used for calculating the minimum absolute distance between the current scattered point value and a plurality of preset key points according to each scattered point value in the plurality of scattered point values, and determining normal test data corresponding to the current scattered point value according to the minimum absolute distance;
and the normal data set determining submodule is used for determining a normal test data set corresponding to the interface document according to the normal test data corresponding to the plurality of scattered point values.
Optionally, determining normal test data corresponding to the current scatter value according to the minimum absolute distance includes:
judging whether the minimum absolute distance is zero;
if yes, generating normal test data corresponding to the current scattered point value by using a preset boundary value algorithm according to the data range constraint;
if not, determining the quantity of normal test data corresponding to the current scattered point value according to the minimum absolute distance and the initialization coefficient; and generating normal test data corresponding to the current scattered point value by utilizing a random function according to the current scattered point value, the preset step length and the number.
Optionally, the data range constraint comprises at least one data range constraint;
optionally, generating normal test data corresponding to the current scatter value by using a preset boundary value algorithm according to the data range constraint, including:
determining boundary test data corresponding to each data range constraint condition in the data range constraint by using a preset boundary algorithm; and generating normal test data corresponding to the current scattered point value according to the boundary test data corresponding to each data range constraint condition.
Optionally, the interface test case generating device further includes:
the automatic conversion module is used for converting the interface test case into an automatic script code according to preset specification information of a preset automation tool and writing the automatic script code into a preset file;
and the script execution module is used for executing the automatic script code by utilizing the preset automation tool based on the keywords in the preset file.
The interface test case generating device provided by the embodiment of the invention can execute the interface test case generating method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the executing method.
Example IV
Fig. 4 is a schematic structural diagram of an interface test case generating device according to a fourth embodiment of the present invention. The interface test case generating device may be an electronic device intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 4, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as the interface test case generation method.
In some embodiments, the interface test case generation method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the interface test case generation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the interface test case generation method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. The interface test case generation method is characterized by comprising the following steps of:
analyzing an interface document and determining key parameters corresponding to the interface document;
inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document;
determining a normal test data set corresponding to the interface document by using a preset random generation algorithm according to the key parameters;
And generating an interface test case according to the abnormal test data set and the normal test data set.
2. The method of claim 1, wherein the predetermined test model comprises:
the method comprises the steps of presetting an interface type and a preset abnormal test data set corresponding to the preset interface type; the preset abnormal test data set comprises a plurality of preset abnormal test data, wherein the preset abnormal test data comprises preset abnormal data corresponding to the preset interface type, an expected result corresponding to the preset abnormal data and an abnormal error report corresponding to the preset abnormal data.
3. The method according to claim 2, wherein inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document includes:
inputting the key parameters into the preset test model, determining a target preset interface type corresponding to the parameter type according to the parameter type in the key parameters through the preset test model, determining a target preset abnormal test data set corresponding to the target preset interface type according to the target preset interface type, and determining an abnormal test data set corresponding to the interface document according to the target preset abnormal test data set;
The abnormal test data set comprises abnormal test data, the abnormal test data comprises abnormal data, expected results corresponding to the abnormal data and abnormal errors corresponding to the abnormal data, the abnormal data corresponds to target preset abnormal data in the target preset abnormal test data set one by one, the expected results corresponding to the abnormal data corresponds to the expected results corresponding to the target preset abnormal data one by one, and the abnormal errors corresponding to the abnormal data correspond to the abnormal errors corresponding to the target preset abnormal data one by one.
4. The method of claim 1, wherein determining the normal test data set corresponding to the interface document using a preset random generation algorithm according to the key parameters comprises:
determining a plurality of scattered point values according to a preset value range and a preset step length; the preset value range is determined according to a plurality of preset key points in a data range constraint corresponding to the parameter type in the key parameters;
for each of the plurality of scattered point values, calculating a minimum absolute distance between the current scattered point value and the plurality of preset key points, and determining normal test data corresponding to the current scattered point value according to the minimum absolute distance;
And determining a normal test data set corresponding to the interface document according to the normal test data corresponding to the plurality of scattered point values respectively.
5. The method of claim 4, wherein determining normal test data corresponding to a current hash-point value based on the minimum absolute distance comprises:
judging whether the minimum absolute distance is zero or not;
if yes, generating normal test data corresponding to the current scattered point value by using a preset boundary value algorithm according to the data range constraint;
if not, determining the quantity of normal test data corresponding to the current scattered point value according to the minimum absolute distance and the initialization coefficient; and generating normal test data corresponding to the current scattered point value by utilizing a random function according to the current scattered point value, the preset step length and the number.
6. The method of claim 5, wherein the data range constraint comprises at least one data range constraint;
generating normal test data corresponding to the current scattered point value by using a preset boundary value algorithm according to the data range constraint, wherein the normal test data comprises the following steps:
determining boundary test data corresponding to each data range constraint condition in the data range constraint by utilizing the preset boundary algorithm; and generating normal test data corresponding to the current scattered point value according to the boundary test data corresponding to each data range constraint condition.
7. The method according to any one of claims 1-6, further comprising:
converting the interface test case into an automation script code according to preset specification information of a preset automation tool, and writing the automation script code into a preset file;
and executing the automation script code by utilizing the preset automation tool based on the keywords in the preset file.
8. An interface test case generating device, comprising:
the parameter acquisition module is used for analyzing the interface document and determining key parameters corresponding to the interface document;
the first determining module is used for inputting the key parameters into a preset test model to obtain an abnormal test data set corresponding to the interface document;
the second determining module is used for determining a normal test data set corresponding to the interface document by using a preset random generation algorithm according to the key parameters;
and the case generation module is used for generating an interface test case according to the abnormal test data set and the normal test data set.
9. An interface test case generating device, characterized in that the interface test case generating device comprises:
At least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the interface test case generation method of any one of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to implement the interface test case generation method of any one of claims 1-7 when executed.
CN202311384852.0A 2023-10-24 2023-10-24 Interface test case generation method, device, equipment and storage medium Pending CN117312168A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311384852.0A CN117312168A (en) 2023-10-24 2023-10-24 Interface test case generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311384852.0A CN117312168A (en) 2023-10-24 2023-10-24 Interface test case generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117312168A true CN117312168A (en) 2023-12-29

Family

ID=89242591

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311384852.0A Pending CN117312168A (en) 2023-10-24 2023-10-24 Interface test case generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117312168A (en)

Similar Documents

Publication Publication Date Title
CN116975081A (en) Log diagnosis set updating method, device, equipment and storage medium
CN116303013A (en) Source code analysis method, device, electronic equipment and storage medium
CN117312168A (en) Interface test case generation method, device, equipment and storage medium
CN114443493A (en) Test case generation method and device, electronic equipment and storage medium
CN116955504B (en) Data processing method and device, electronic equipment and storage medium
CN117271373B (en) Automatic construction method and device for test cases, electronic equipment and storage medium
CN117540718A (en) Intelligent inspection result statistical method based on document object model
CN115098405B (en) Software product evaluation method and device, electronic equipment and storage medium
CN116562242A (en) Data report construction method and device, electronic equipment and storage medium
CN117056222A (en) Interface test file generation method and device, electronic equipment and storage medium
CN115495380A (en) Test case generation method and device, electronic equipment and storage medium
CN117724980A (en) Method and device for testing software framework performance, electronic equipment and storage medium
CN117743396A (en) Data quality detection method, device, equipment and storage medium
CN117873990A (en) DDL analysis method, device, equipment and storage medium based on WAL log
CN117014291A (en) Abnormal node determining method, device, equipment and medium based on workflow grouping
CN115934550A (en) Test method, test device, electronic equipment and storage medium
CN117609064A (en) Unit test method and device, electronic equipment and storage medium
CN117406964A (en) Data architecture model design method, device, electronic equipment and storage medium
CN115567624A (en) Message processing method and device, electronic equipment and medium
CN116883198A (en) Data quality evaluation method and device, electronic equipment and medium
CN117806604A (en) TLV data analysis method and device based on spring boot frame
CN115238212A (en) Page designated element detection and replacement method, device, equipment and storage medium
CN117251196A (en) Data maintenance method, device, equipment and storage medium
CN115859300A (en) Vulnerability detection method and device, electronic equipment and storage medium
CN116204442A (en) System testing method and device, electronic 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