CN115309660A - Interface testing method and device, storage medium and computer equipment - Google Patents

Interface testing method and device, storage medium and computer equipment Download PDF

Info

Publication number
CN115309660A
CN115309660A CN202211114448.7A CN202211114448A CN115309660A CN 115309660 A CN115309660 A CN 115309660A CN 202211114448 A CN202211114448 A CN 202211114448A CN 115309660 A CN115309660 A CN 115309660A
Authority
CN
China
Prior art keywords
interface
test case
test
tested
fields
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
CN202211114448.7A
Other languages
Chinese (zh)
Inventor
何辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Pingan Payment Technology Service Co Ltd
Original Assignee
Pingan Payment Technology Service 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 Pingan Payment Technology Service Co Ltd filed Critical Pingan Payment Technology Service Co Ltd
Priority to CN202211114448.7A priority Critical patent/CN115309660A/en
Publication of CN115309660A publication Critical patent/CN115309660A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/368Test management for test version control, e.g. updating test cases to a new software version
    • 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

Abstract

The invention discloses an interface testing method, an interface testing device, a storage medium and computer equipment, relates to the technical field of information and digital medical treatment, and improves the testing efficiency and the testing precision of an interface field. The method comprises the following steps: receiving a test case generation instruction; determining a test case template corresponding to the interface type of the interface to be tested based on the identification information corresponding to the interface to be tested; acquiring a plurality of interface fields corresponding to the interface to be tested based on a test case template, and determining each target configuration parameter corresponding to the plurality of interface fields and target assertion corresponding to each target configuration parameter based on the preset interface field test type and the preset interface field test rule; and generating a test case set corresponding to the interface to be tested based on each target configuration parameter and the corresponding target assertion, and testing the interface to be tested by using the test case set. The invention is suitable for testing the interface.

Description

Interface testing method and device, storage medium and computer equipment
Technical Field
The present invention relates to the field of information technologies, and in particular, to an interface testing method and apparatus, a storage medium, and a computer device.
Background
With the increasingly large software scale, it is necessary to divide a complex system into small components, so that a programming interface is introduced, a good interface can reduce interdependence of various parts of the system, improve cohesion of the components, and reduce coupling degree between the components, and therefore, in order to exert the above advantages of the interface, the developed interface needs to be tested, and the interface test is mainly to test fields in the interface to ensure normal implementation of the interface function.
Currently, testing of interfaces is typically done by manually writing test cases. However, the manual test case compiling mode results in low interface testing efficiency, and meanwhile, due to the fact that technical levels of testers are different, the test case compiling is wrong, and therefore the interface testing precision is low.
Disclosure of Invention
The invention provides an interface testing method, an interface testing device, a storage medium and computer equipment, which mainly aim at improving the testing efficiency and the testing precision of an interface field.
According to a first aspect of the present invention, there is provided an interface testing method, comprising:
receiving a test case generation instruction corresponding to an interface to be tested, wherein the test case generation instruction carries identification information corresponding to the interface to be tested;
determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the same type of interface;
based on the test case template, acquiring a plurality of interface fields corresponding to the interface to be tested, and displaying the test types of the preset interface fields and the test rules of the preset interface fields corresponding to the plurality of interface fields respectively;
determining each target configuration parameter corresponding to each of the plurality of interface fields and a target assertion corresponding to each target configuration parameter based on the preset interface field test type and the preset interface field test rule;
and generating a test case set corresponding to the interface to be tested based on each target configuration parameter and the corresponding target assertion, and testing the interface to be tested by using the test case set.
According to a second aspect of the present invention, there is provided an interface test apparatus comprising:
the device comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for receiving a test case generation instruction corresponding to an interface to be tested, and the test case generation instruction carries identification information corresponding to the interface to be tested;
the first determining unit is used for determining the interface type of the interface to be tested based on the identification information and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the same type of interface;
the acquisition unit is used for acquiring a plurality of interface fields corresponding to the interface to be tested based on the test case template and displaying the test types and the test rules of the preset interface fields corresponding to the interface fields;
a second determining unit, configured to determine, based on the preset interface field test type and the preset interface field test rule, each target configuration parameter corresponding to each of the plurality of interface fields and a target assertion corresponding to each target configuration parameter;
and the test unit is used for generating a test case set corresponding to the interface to be tested based on each target configuration parameter and the corresponding target assertion, and testing the interface to be tested by using the test case set.
According to a third aspect of the present invention, there is provided a computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, performs the steps of:
receiving a test case generation instruction corresponding to an interface to be tested, wherein the test case generation instruction carries identification information corresponding to the interface to be tested;
determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the same type of interface;
based on the test case template, acquiring a plurality of interface fields corresponding to the interface to be tested, and displaying the test types of the preset interface fields and the test rules of the preset interface fields corresponding to the plurality of interface fields respectively;
determining each target configuration parameter corresponding to each of the plurality of interface fields and target assertion corresponding to each target configuration parameter based on the preset interface field test type and the preset interface field test rule;
and generating a test case set corresponding to the interface to be tested based on each target configuration parameter and the corresponding target assertion, and testing the interface to be tested by using the test case set.
According to a fourth aspect of the present invention, there is provided a computer apparatus comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the program:
receiving a test case generation instruction corresponding to an interface to be tested, wherein the test case generation instruction carries identification information corresponding to the interface to be tested;
determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the interface of the same type;
based on the test case template, acquiring a plurality of interface fields corresponding to the interface to be tested, and displaying the test types of the preset interface fields and the test rules of the preset interface fields corresponding to the plurality of interface fields respectively;
determining each target configuration parameter corresponding to each of the plurality of interface fields and target assertion corresponding to each target configuration parameter based on the preset interface field test type and the preset interface field test rule;
and generating a test case set corresponding to the interface to be tested based on each target configuration parameter and the corresponding target assertion, and testing the interface to be tested by using the test case set.
According to the interface testing method, the interface testing device, the storage medium and the computer equipment, compared with the current mode of manually constructing the test case to test the interface, the interface testing method receives the test case generation instruction corresponding to the interface to be tested, wherein the test case generation instruction carries the identification information corresponding to the interface to be tested; determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the same type of interface; meanwhile, based on the test case template, acquiring a plurality of interface fields corresponding to the interface to be tested, and displaying the test types and test rules of the preset interface fields corresponding to the interface fields respectively; then, based on the preset interface field test type and the preset interface field test rule, determining each target configuration parameter corresponding to each of the plurality of interface fields and target assertion corresponding to each target configuration parameter; finally, based on each target configuration parameter and the corresponding target assertion, a test case set corresponding to the interface to be tested is generated, the interface to be tested is tested by the test case set, a plurality of interface fields are automatically obtained by the test case template, each target configuration parameter is automatically given to the plurality of interface fields based on the test type of the preset interface fields and the test rule of the preset interface fields displayed in the test case template, finally, based on each target configuration parameter and the corresponding target assertion, the test case set is generated, and the interface to be tested is tested by the test case set, so that the efficiency of interface test is improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 shows a flowchart of an interface testing method provided in an embodiment of the present invention;
FIG. 2 is a flow chart of another interface testing method provided by the embodiment of the invention;
fig. 3 is a schematic structural diagram illustrating an interface testing apparatus according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of another interface testing apparatus provided in the embodiment of the present invention;
fig. 5 shows a physical structure diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The invention will be described in detail hereinafter with reference to the drawings and embodiments. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
At present, the efficiency of interface testing is low due to the mode of manually writing test cases to test interfaces, and meanwhile, due to the fact that technical levels of testers are different, the writing of the test cases is wrong, and therefore the testing accuracy of the interfaces is low.
In order to solve the above problem, an embodiment of the present invention provides an interface testing method, as shown in fig. 1, where the method includes:
101. receiving a test case generation instruction corresponding to an interface to be tested, wherein the test case generation instruction carries identification information corresponding to the interface to be tested.
The interface to be tested may be an application program interface, such as an interface in a management medical insurance information system. The identification information may be icon information or character information of the interface to be tested, and as long as the interface to be tested can be uniquely determined by the identification information, the embodiment of the present invention does not specifically limit the form of the identification information.
For the embodiment of the invention, in order to solve the problems of low testing efficiency and low testing precision of the interface in the prior art, the embodiment of the invention automatically acquires a plurality of interface fields by using the test case template, automatically endows each target configuration parameter for the plurality of interface fields based on the test type of the preset interface field and the test rule of the preset interface field displayed in the test case template, finally generates the test case set based on each target configuration parameter and the corresponding target assertion thereof, and tests the interface to be tested by using the test case set, thereby improving the efficiency of interface testing, and simultaneously avoiding the condition of wrong programming caused by manually programming the test case, thereby causing the condition of wrong interface testing, and further improving the testing precision of the interface. The embodiment of the invention is mainly applied to a scene of testing the interface, and the execution main body of the embodiment of the invention is a device or equipment capable of testing the interface, and can be specifically arranged on one side of a client or a server.
Specifically, the interface test in the embodiment of the present invention may specifically be a boundary value test of each interface field in an interface, a boundary-value-detect.jar interface test plug-in is developed in the embodiment of the present invention, the plug-in is inserted into an engineering code corresponding to an interface to be tested, a test case generation system is downloaded and installed in a company official website, the test case generation system is opened by double clicking, a main interface of the test case generation system is displayed, an interface type option in the main interface of the test case generation system is clicked, a pull-down menu corresponding to different interface types appears, an interface type to which the interface to be tested belongs is selected in the pull-down menu, at this time, a test case generation instruction corresponding to the interface to be tested is triggered, when the test case generation instruction is triggered, a boundary-value-detect.jar plug-in the engineering code corresponding to the interface to be tested starts working, the test case generation instruction carries identification information corresponding to the interface to be tested, the test case generation template corresponding to the interface to be tested is displayed based on the identification information, and the test case generation efficiency is improved, thereby improving the test efficiency of the interface to be tested.
102. And determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the interface of the same type.
Wherein the interface types include: the device comprises a password verification type interface, a payment type interface, an information sharing type interface, an information receiving type interface and the like, wherein different interface types correspond to different test case templates.
For the embodiment of the invention, after a test case generation instruction corresponding to the interface to be tested is received, the interface type of the interface to be tested is determined based on identification information corresponding to the interface to be tested, which is carried in the test case generation quality, because different interface types correspond to different test case templates, the test case template corresponding to the interface type can be determined based on the interface type, wherein a universal test case code corresponding to the interface type is automatically linked in the test case template, a filling item exists in the universal test case code, then an interface field to be tested is selected in the test case template, based on the displayed test rule of the preset interface field and the preset interface field, each target configuration parameter is given to the selected interface field, the target configuration parameter is automatically filled into the filling item in the universal test case code on the test case template, simultaneously the target assertion corresponding to each target configuration parameter is determined, and based on each target configuration parameter and the target assertion corresponding to the test case code, finally the test case interface to be tested is tested by using the test case set, the test efficiency of the interface to be tested is improved, and the test case writing accuracy is improved.
103. And acquiring a plurality of interface fields corresponding to the interface to be tested based on the test case template, and displaying the test types of the preset interface fields and the test rules of the preset interface fields corresponding to the plurality of interface fields respectively.
The interface field may be any field in the interface to be tested, for example, the storage rule interface includes: a rule ID field, a management and control mode field, a service type field, a rule name field, a rule type field and whether the rule field is enabled or not. The interface field test type is preset, such as a field length test and an enumeration value test, the preset interface field test rule is a rule related to the preset interface field test type, different preset interface field test types correspond to different preset interface field test rules, for example, when the interface field is a serial number, and if the preset interface field test type corresponding to the rule ID field is a field length test, the corresponding preset interface field test rule is that the field length does not exceed 32 bits. If the preset interface field test type corresponding to the management and control mode field is an enumeration value test, the corresponding preset interface field test rule is that the enumeration value must be one of COST or REIM.
For the embodiment of the invention, different test case templates are linked with different interface field libraries, a pull-down option menu corresponding to interface fields exists in the test case template, a pull-down menu identifier corresponding to field title items in the test case template is clicked, so that the pull-down menu corresponding to each interface field corresponding to the interface type can be displayed, a plurality of interface fields corresponding to the interface to be tested are selected in the pull-down menu, wherein the plurality of interface fields can be displayed to a user in the form of field identifiers, each interface field is selected, a preset interface field test type corresponding to the interface field can be displayed at the corresponding position of the test case template, and a preset interface field test rule is displayed.
104. And determining each target configuration parameter corresponding to each interface field and target assertion corresponding to each target configuration parameter based on the preset interface field test type and the preset interface field test rule.
The target configuration parameter is to assign a different test value to any one of the plurality of interface fields. The target assertion refers to a test result (expected test result) that should occur when the interface field test value is assigned, for example, if the preset interface field test type is a length test, the length of the corresponding preset interface field test rule is not more than 32 bits, when the interface field configuration parameter (the assigned test value), i.e., the length of the field, is 2, the corresponding target assertion (i.e., the expected interface test result) is a test pass, and when the length of the interface field is 64, the corresponding target assertion (i.e., the expected interface test result) is a test fail.
For the embodiment of the present invention, after the preset interface field test type and the preset interface field test rule corresponding to the plurality of interface fields are displayed, based on the preset interface field test type and the preset interface field test rule, the boundary-value-detect plug-in automatically determines each target configuration parameter corresponding to each of the plurality of interface fields and the target assertion corresponding to each target configuration parameter.
For example, if the interface to be tested is a rule-saving interface, which includes 6 interface fields, respectively: rule ID, control mode, category, ruleName, ruleType, ruleEnable, and test type of a preset interface field corresponding to ruleId is: and (3) field length testing, wherein the preset interface field testing rule is as follows: the field can have a value or not, and the field is 32 bits in length under the condition of the value; the test type of the preset interface field corresponding to the control mode is as follows: testing an enumeration value, wherein a testing rule of a preset interface field is as follows: must be COST or REIM; the testing type of the preset interface field corresponding to category is as follows: testing an enumeration value, wherein a testing rule of a preset interface field is as follows: must be one of AIR, HOTEL, CAR and TRAIN; the test type of the preset interface field corresponding to the ruleName is as follows: and (3) field length testing, wherein the preset interface field testing rule is as follows: must have a value, the length is 128 bits at the longest; the test type of the preset interface field corresponding to the ruleType is as follows: testing an enumeration value, wherein a testing rule of a preset interface field is as follows: the interface test type of the interface test system is one of DEFAULT and CUSTOM, and the test type of the preset interface field corresponding to ruleEnable is as follows: testing an enumeration value, wherein a testing rule of a preset interface field is as follows: a trunk-value-detect plug-in is used to assign target configuration parameters to the 6 interface fields, and determine a target assertion corresponding to the target configuration parameters, for example, the target configuration parameters assigned to the ruleld interface field may be: if there is no value or there is a value, the value is 0 bit, or 16 bits, or 33 bits, that is, 4 target configuration parameters may be configured for the interface field, where the target assertions corresponding to the 4 configuration parameters are: the target assertion corresponding to the configuration parameter is test pass when the configuration parameter is no value, the target assertion corresponding to the configuration parameter is test pass when the configuration parameter is 0 bit, the target assertion corresponding to the configuration parameter is test pass when the configuration parameter is 16 bit, and the target assertion corresponding to the configuration parameter is test fail when the configuration parameter is 33 bit, for example, the target configuration parameter assigned to the control mode interface field may be: the test method comprises the steps of COST, REIM or AIR, when configuration parameters are COST, corresponding target assertions are passed, when configuration parameters are REIM, corresponding target assertions are passed, when configuration parameters are AIR, corresponding target assertions are failed, target configuration parameters and corresponding target assertions can be configured for each interface field respectively, finally, based on the target configuration parameters and the corresponding target assertions, a plurality of test cases can be generated, the test cases form a test case set, finally, the test case set is used for testing the interface to be tested, for example, if 2 target configuration parameters are configured for the interface field A and 3 target configuration parameters are configured for the interface field B, 6 test cases can be generated, and the interface to be tested is tested by the 6 test cases respectively. Therefore, the test case can be automatically generated through the test case template and the boundary-value-detect plug-in, the generation efficiency of the test case is improved, and the test efficiency of the interface is improved.
105. And generating a test case set corresponding to the interface to be tested based on each target configuration parameter and the corresponding target assertion, and testing the interface to be tested by using the test case set.
For the embodiment of the invention, after obtaining each target configuration parameter corresponding to a plurality of interface fields, each target configuration parameter is automatically filled to the corresponding filling-in position of the test case universal code in the test case template in a round-robin manner, the test case generation system generates each test case complete code based on the target configuration parameter filled in a round-robin manner, constructs a test case set based on each test case complete code and the corresponding target assertion thereof, and finally, each test case in the test case set is utilized to sequentially test the interface to be tested.
Compared with the current mode of manually constructing a test case to test an interface, the interface testing method provided by the invention receives a test case generation instruction corresponding to the interface to be tested, wherein the test case generation instruction carries identification information corresponding to the interface to be tested; determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the same type of interface; meanwhile, based on the test case template, acquiring a plurality of interface fields corresponding to the interface to be tested, and displaying the test types and test rules of the preset interface fields corresponding to the interface fields respectively; then, based on the preset interface field test type and the preset interface field test rule, determining each target configuration parameter corresponding to each of the plurality of interface fields and target assertion corresponding to each target configuration parameter; finally, based on each target configuration parameter and the corresponding target assertion, a test case set corresponding to the interface to be tested is generated, the interface to be tested is tested by the test case set, a plurality of interface fields are automatically obtained by the test case template, each target configuration parameter is automatically given to the plurality of interface fields based on the test type of the preset interface fields and the test rule of the preset interface fields displayed in the test case template, finally, based on each target configuration parameter and the corresponding target assertion, the test case set is generated, and the interface to be tested is tested by the test case set, so that the efficiency of interface test is improved.
Further, in order to better explain the process of testing the interface, as a refinement and an extension of the foregoing embodiment, an embodiment of the present invention provides another interface testing method, as shown in fig. 2, where the method includes:
201. receiving a test case generation instruction corresponding to an interface to be tested, wherein the test case generation instruction carries identification information corresponding to the interface to be tested.
Specifically, firstly inserting the boundary-value-detect plug-in into the code project corresponding to the interface to be tested, namely, the plug-in is quoted in the code project corresponding to the interface to be tested, then, double-clicking to open the test case generation system, clicking a pull-down menu in a template generation button in the displayed main interface, selecting the identifier of the interface to be tested in the displayed pull-down menu, namely, triggering a test case generation instruction, and then, the boundary-value-detect plug-in is ready to start working.
202. And determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the interface of the same type.
For the embodiment of the present invention, in order to determine the test case template corresponding to the interface type, the test case template needs to be constructed first, and based on this, the method includes: determining each group of interface fields corresponding to different types of interfaces; storing the groups of interface fields into interface field libraries corresponding to the different types of interfaces; and constructing test case templates corresponding to the different types of interfaces, and establishing mapping relations between the different test case templates and different interface field libraries.
Specifically, because the interface fields included in the interfaces of the same type are substantially the same, it is necessary to determine each set of interface fields corresponding to the interfaces of different types, and construct an interface field library corresponding to the interfaces of different types in advance, and then store each set of interface fields into the interface field library corresponding to the interface field library, and at the same time, construct test case templates corresponding to different interface types, and because the test case code frames corresponding to the interfaces of the same type are substantially the same, there is a test case general frame code in each test case template, and it is only necessary to fill in characteristic parameter codes corresponding to different interfaces in the general test case codes, and in order to select a target test case template, automatically link out the target interface field library corresponding to the target test case template, it is necessary to establish a mapping relationship between the different test case templates and the different interface field libraries.
Further, after a test case template is constructed and a mapping relation between the test case template and an interface field library is established, which type of interface the interface to be tested belongs to is checked based on identification information corresponding to the test interface, and because different types of interfaces correspond to different test case templates, the test case template corresponding to the type of interface is determined based on the type of interface to be tested belongs to, that is, the test case template corresponding to the interface to be tested is determined.
203. And acquiring a plurality of interface fields corresponding to the interface to be tested based on the test case template, and displaying the test types of the preset interface fields and the test rules of the preset interface fields corresponding to the plurality of interface fields respectively.
For the embodiment of the present invention, after determining the test case template corresponding to the interface type, multiple interface fields corresponding to the interfaces to be tested need to be obtained based on the test case template, and based on this, step 203 specifically includes: determining a target interface field library corresponding to the test case template based on the mapping relation between different test case templates and different interface field libraries; and acquiring a plurality of interface fields selected by a user from the target interface field library for the interface to be tested.
Specifically, a target interface field library corresponding to the test case template is determined based on a mapping relation between different test case templates and different interface field libraries, wherein the target interface field library stores interface fields included in the type interface, a user clicks a pull-down menu identifier on a field title item corresponding to the test case template, the interface fields corresponding to the type interface are displayed in the pull-down menu, and the user selects a plurality of interface fields included in an interface to be tested in the interface fields.
Further, after obtaining the plurality of interface fields included in the interface to be tested, displaying the preset interface field test types and the preset interface field test rules respectively corresponding to the plurality of interface fields at corresponding positions of the test case template, based on which step 203 further includes: acquiring the position information of the plurality of interface fields in the test case template; and displaying the preset interface field test types and the preset interface field test rules respectively corresponding to the interface fields in the test case template based on the position information.
Specifically, after selecting an interface field at a position corresponding to an interface field title item in the test case template, determining position information of the interface field in the test case template, and based on the position information, displaying a preset interface field test type and a preset interface field test rule corresponding to the interface field at a position above or below the interface field, where the preset interface field test type and the preset interface field test rule corresponding to different interface fields may be the same or different, and the positions of the preset interface field test type and the preset interface field test rule may enable a worker to clearly know that the preset interface field test type and the preset interface field test rule are the test type and the test rule corresponding to the interface field.
204. And determining each target configuration parameter corresponding to each interface field and target assertion corresponding to each target configuration parameter based on the preset interface field test type and the preset interface field test rule.
Specifically, based on an interface field selected by a user, and a preset interface field test type and a preset interface field test rule corresponding to the displayed interface field, a boundary-value-detect plug-in is executed in an engineering code of an interface to be tested, the plug-in decompresses a jar packet corresponding to the interface to be tested, finds the interface field selected by the user in the decompressed compressed packet, and generates each target configuration parameter and a target assertion corresponding to the target configuration parameter for the interface field based on the preset interface field test rule and the preset interface field test type corresponding to the interface field selected by the user.
205. And generating a test case set corresponding to the interface to be tested by using a case generating function based on each target configuration parameter and the corresponding target assertion.
The case generating function may specifically be a two-factor algorithm function, specifically, any one of the interface fields may correspond to a plurality of target configuration parameters, each target configuration parameter has a corresponding target assertion, after the corresponding target configuration parameters and the target assertions are generated for the plurality of interface fields by using a trunk-value-detect.jar plug-in, each target configuration parameter corresponding to any one of the interface fields needs to be inserted into a corresponding position of a universal test case code frame in the test case template in a round-robin manner under the condition that values of other interface fields are not changed, based on this, each target configuration parameter corresponding to the plurality of interface fields may be arranged and combined by using the two-factor algorithm function, and the configuration parameters corresponding to any one of the arrangement and combination are sequentially input into corresponding positions in the universal test code in the test case template, and then the target assertions corresponding to each combination may be combined, so that the test case set may be obtained.
206. And testing the interface to be tested by utilizing the test case set.
For the embodiment of the present invention, after the test case set corresponding to the interface to be tested is constructed, in order to improve the testing efficiency, the test cases in the test case set may be sequenced, and based on this, the method includes: determining a weight coefficient corresponding to each test case in the test case set; based on the weight coefficient, sequencing each test case in the test case set to obtain each sequenced test case; and testing the interface to be tested based on the arrangement sequence of each test case.
Specifically, the method may determine a weight coefficient of each test case based on the importance degree of each interface field and the importance degree of each configuration parameter, and rank each test case according to a descending order of the weight coefficient to obtain each ranked test set, and further, after each test case set is obtained, a test notification needs to be generated, and the test notification is sent to a tester for interface testing, based on which the method includes: generating a test notification corresponding to the interface to be tested based on the test case set; and calling a preset communication tool interface, and sending the test notification to a tester terminal so that a tester of the tester terminal can test the interface to be tested based on the test notification.
The preset communication tools comprise WeChat, mail, mobile phone short messages and the like. For the embodiment of the invention, after the test case set is constructed, the test case set can be stored to a corresponding position, meanwhile, a test notification corresponding to the interface to be tested is generated based on the test case set, the test notification comprises the storage position corresponding to the test case set, and the test notification is sent to the tester terminal in the form of WeChat, mail, short message and the like, so that the tester of the tester terminal can obtain the test case set from the position based on the position carried in the test notification, and the test case set is utilized to test the interface to be tested.
Further, a tester can select N test cases before ranking to test the interface to be tested, if time is sufficient, the interface to be tested can also be tested by using each test case to obtain a test result, for example, if the target assertions corresponding to the test case a are passed, but the test case a is used to test the interface to be tested, and the obtained test result is that the test is failed, it is determined that the interface to be tested is abnormal, if the target assertions corresponding to the test cases B, C, and D are all passed, the test cases B, C, and D are used to test the interface to be tested, and the obtained test results are all passed, wherein the test cases B, C, and D cover each configuration parameter corresponding to a certain target interface field, and it is determined that the interface to be tested is not abnormal under the target interface field.
According to another interface testing method provided by the invention, compared with the current mode of manually constructing a test case to test an interface, the method provided by the invention receives a test case generation instruction corresponding to the interface to be tested, wherein the test case generation instruction carries identification information corresponding to the interface to be tested; determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the interface of the same type; meanwhile, based on the test case template, acquiring a plurality of interface fields corresponding to the interface to be tested, and displaying the test types and test rules of the preset interface fields corresponding to the plurality of interface fields respectively; then, based on the preset interface field test type and the preset interface field test rule, determining each target configuration parameter corresponding to each of the plurality of interface fields and target assertion corresponding to each target configuration parameter; finally, based on each target configuration parameter and the corresponding target assertion, a test case set corresponding to the interface to be tested is generated, the interface to be tested is tested by the test case set, a plurality of interface fields are automatically obtained by the test case template, each target configuration parameter is automatically given to the plurality of interface fields based on the preset interface field test type and the preset interface field test rule displayed in the test case template, finally, based on each target configuration parameter and the corresponding target assertion, the test case set is generated, the interface to be tested is tested by the test case set, the efficiency of interface test is improved, meanwhile, the condition that writing errors are caused by manual writing of the test case is avoided, the condition that the interface is tested by errors is caused, and the test precision of the interface is improved.
Further, as a specific implementation of fig. 1, an embodiment of the present invention provides an interface testing apparatus, as shown in fig. 3, the apparatus includes: a receiving unit 31, a first determining unit 32, an obtaining unit 33, a second determining unit 34 and a testing unit 35.
The receiving unit 31 may be configured to receive a test case generation instruction corresponding to an interface to be tested, where the test case generation instruction carries identification information corresponding to the interface to be tested.
The first determining unit 32 may be configured to determine, based on the identification information, an interface type to which the interface to be tested belongs, and determine a test case template corresponding to the interface type, where the test case template includes a universal test case code corresponding to an interface of the same type.
The obtaining unit 33 may be configured to obtain, based on the test case template, a plurality of interface fields corresponding to the interface to be tested, and display a preset interface field test type and a preset interface field test rule corresponding to each of the plurality of interface fields.
The second determining unit 34 may be configured to determine, based on the preset interface field test type and the preset interface field test rule, each target configuration parameter corresponding to each of the plurality of interface fields and a target assertion corresponding to each target configuration parameter.
The testing unit 35 may be configured to generate a test case set corresponding to the interface to be tested based on each target configuration parameter and the target assertion corresponding to the target configuration parameter, and test the interface to be tested by using the test case set.
In a specific application scenario, in order to construct a test case template corresponding to the interface type, as shown in fig. 4, the apparatus further includes: a storage unit 36 and a construction unit 37.
The first determining unit 32 may be further configured to determine sets of interface fields corresponding to different types of interfaces.
The storage unit 36 may be configured to store the sets of interface fields into an interface field library corresponding to the interfaces of different types.
The constructing unit 37 may be configured to construct test case templates corresponding to the different types of interfaces, and establish mapping relationships between the different test case templates and the different interface field libraries.
In a specific application scenario, in order to obtain a plurality of interface fields corresponding to the interfaces to be tested, the obtaining unit 33 includes a first determining module 331 and an obtaining module 332.
The first determining module 331 may be configured to determine a target interface field library corresponding to the test case template based on a mapping relationship between different test case templates and different interface field libraries.
The obtaining module 332 may be configured to obtain a plurality of interface fields selected by a user from the target interface field library for the interface to be tested.
In a specific application scenario, in order to show the preset interface field test type and the preset interface field test rule respectively corresponding to the plurality of interface fields, the obtaining unit 33 further includes a showing module 333.
The obtaining module 332 may also be configured to not obtain the location information of the plurality of interface fields in the test case template.
The display module 333 may be configured to display, in the test case template, a preset interface field test type and a preset interface field test rule corresponding to the plurality of interface fields, respectively, based on the plurality of pieces of location information.
In a specific application scenario, in order to generate the test case set corresponding to the interface to be tested, the test unit 35 may be specifically configured to generate the test case set corresponding to the interface to be tested by using a case generation function based on each target configuration parameter and the target assertion corresponding thereto.
In a specific application scenario, in order to test the interface to be tested by using the test case suite, the test unit 35 includes a second determining module 351, a sorting module 352, and a testing module 353.
The second determining module 351 may be configured to determine a weight coefficient corresponding to each test case in the test case set.
The sorting module 352 may sort the test cases in the test case set without based on the weight coefficient, so as to obtain the sorted test cases.
The testing module 353 may be configured to test the interfaces to be tested based on the arrangement order of the test cases.
In a specific application scenario, in order to send the test notification to a tester, the apparatus further includes: a generating unit 38 and a transmitting unit 39.
The generating unit 38 may be configured to generate a test notification corresponding to the interface to be tested based on the test case suite.
The sending unit 39 may be configured to call a preset communication tool interface, and send the test notification to the tester terminal, so that a tester at the tester terminal tests the interface to be tested based on the test notification.
It should be noted that other corresponding descriptions of the functional modules related to the interface testing apparatus provided in the embodiment of the present invention may refer to the corresponding description of the method shown in fig. 1, and are not described herein again.
Based on the method shown in fig. 1, correspondingly, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the following steps: receiving a test case generation instruction corresponding to an interface to be tested, wherein the test case generation instruction carries identification information corresponding to the interface to be tested; determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the interface of the same type; acquiring a plurality of interface fields corresponding to the interface to be tested based on the test case template, and displaying the test types of the preset interface fields and the test rules of the preset interface fields corresponding to the plurality of interface fields respectively; determining each target configuration parameter corresponding to each of the plurality of interface fields and a target assertion corresponding to each target configuration parameter based on the preset interface field test type and the preset interface field test rule; and generating a test case set corresponding to the interface to be tested based on each target configuration parameter and the corresponding target assertion, and testing the interface to be tested by using the test case set.
Based on the above embodiments of the method shown in fig. 1 and the apparatus shown in fig. 3, an embodiment of the present invention further provides an entity structure diagram of a computer device, as shown in fig. 5, where the computer device includes: a processor 41, a memory 42, and a computer program stored on the memory 42 and executable on the processor, wherein the memory 42 and the processor 41 are both arranged on a bus 43 such that when the processor 41 executes the program, the following steps are performed: receiving a test case generation instruction corresponding to an interface to be tested, wherein the test case generation instruction carries identification information corresponding to the interface to be tested; determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the interface of the same type; based on the test case template, acquiring a plurality of interface fields corresponding to the interface to be tested, and displaying the test types of the preset interface fields and the test rules of the preset interface fields corresponding to the plurality of interface fields respectively; determining each target configuration parameter corresponding to each of the plurality of interface fields and a target assertion corresponding to each target configuration parameter based on the preset interface field test type and the preset interface field test rule; and generating a test case set corresponding to the interface to be tested based on each target configuration parameter and the corresponding target assertion, and testing the interface to be tested by using the test case set.
According to the technical scheme, a test case generation instruction corresponding to an interface to be tested is received, wherein the test case generation instruction carries identification information corresponding to the interface to be tested; determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the interface of the same type; meanwhile, based on the test case template, acquiring a plurality of interface fields corresponding to the interface to be tested, and displaying the test types and test rules of the preset interface fields corresponding to the plurality of interface fields respectively; then, based on the preset interface field test type and the preset interface field test rule, determining each target configuration parameter corresponding to each of the plurality of interface fields and target assertion corresponding to each target configuration parameter; finally, based on each target configuration parameter and the corresponding target assertion, a test case set corresponding to the interface to be tested is generated, the interface to be tested is tested by the test case set, a plurality of interface fields are automatically obtained by the test case template, each target configuration parameter is automatically given to the plurality of interface fields based on the preset interface field test type and the preset interface field test rule displayed in the test case template, finally, based on each target configuration parameter and the corresponding target assertion, the test case set is generated, the interface to be tested is tested by the test case set, the efficiency of interface test is improved, meanwhile, the condition that writing errors are caused by manual writing of the test case is avoided, the condition that the interface is tested by errors is caused, and the test precision of the interface is improved.
It will be apparent to those skilled in the art that the modules or steps of the present invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. An interface testing method, comprising:
receiving a test case generation instruction corresponding to an interface to be tested, wherein the test case generation instruction carries identification information corresponding to the interface to be tested;
determining the interface type of the interface to be tested based on the identification information, and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the interface of the same type;
based on the test case template, acquiring a plurality of interface fields corresponding to the interface to be tested, and displaying the test types of the preset interface fields and the test rules of the preset interface fields corresponding to the plurality of interface fields respectively;
determining each target configuration parameter corresponding to each of the plurality of interface fields and target assertion corresponding to each target configuration parameter based on the preset interface field test type and the preset interface field test rule;
and generating a test case set corresponding to the interface to be tested based on each target configuration parameter and the corresponding target assertion, and testing the interface to be tested by using the test case set.
2. The method of claim 1, wherein prior to said determining the test case template corresponding to the interface type, the method further comprises:
determining each group of interface fields corresponding to different types of interfaces;
storing the groups of interface fields into interface field libraries corresponding to the different types of interfaces;
and constructing test case templates corresponding to the different types of interfaces, and establishing mapping relations between the different test case templates and different interface field libraries.
3. The method of claim 1, wherein the obtaining a plurality of interface fields corresponding to the interface to be tested based on the test case template comprises:
determining a target interface field library corresponding to the test case template based on the mapping relation between different test case templates and different interface field libraries;
and acquiring a plurality of interface fields selected by a user from the target interface field library for the interface to be tested.
4. The method according to claim 1, wherein the displaying of the test type and the test rule of the preset interface field corresponding to each of the plurality of interface fields comprises:
acquiring the position information of the plurality of interface fields in the test case template;
and displaying the preset interface field test types and the preset interface field test rules respectively corresponding to the interface fields in the test case template based on the position information.
5. The method of claim 1, wherein generating a test case set corresponding to the interface to be tested based on the target configuration parameters and the target assertions corresponding thereto comprises:
and generating a test case set corresponding to the interface to be tested by using a case generating function based on each target configuration parameter and the corresponding target assertion.
6. The method of claim 1, wherein the testing the interface to be tested using the test case suite comprises:
determining a weight coefficient corresponding to each test case in the test case set;
based on the weight coefficient, sequencing each test case in the test case set to obtain each sequenced test case;
and testing the interface to be tested based on the arrangement sequence of each test case.
7. The method as claimed in claim 1, wherein after generating the test case suite corresponding to the interface to be tested based on the target configuration parameters and the target assertions corresponding thereto, the method further comprises:
generating a test notification corresponding to the interface to be tested based on the test case set;
and calling a preset communication tool interface, and sending the test notification to a tester terminal so that a tester at the tester terminal can test the interface to be tested based on the test notification.
8. An interface testing apparatus, comprising:
the device comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for receiving a test case generation instruction corresponding to an interface to be tested, and the test case generation instruction carries identification information corresponding to the interface to be tested;
the first determining unit is used for determining the interface type of the interface to be tested based on the identification information and determining a test case template corresponding to the interface type, wherein the test case template comprises a universal test case code corresponding to the same type of interface;
the acquisition unit is used for acquiring a plurality of interface fields corresponding to the interface to be tested based on the test case template and displaying the test types and the test rules of the preset interface fields corresponding to the plurality of interface fields respectively;
a second determining unit, configured to determine, based on the preset interface field test type and the preset interface field test rule, each target configuration parameter corresponding to each of the plurality of interface fields and a target assertion corresponding to each target configuration parameter;
and the testing unit is used for generating a testing case set corresponding to the interface to be tested based on each target configuration parameter and the corresponding target assertion thereof, and testing the interface to be tested by using the testing case set.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
10. A computer arrangement comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the computer program realizes the steps of the method of any one of claims 1 to 7 when executed by the processor.
CN202211114448.7A 2022-09-14 2022-09-14 Interface testing method and device, storage medium and computer equipment Pending CN115309660A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211114448.7A CN115309660A (en) 2022-09-14 2022-09-14 Interface testing method and device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211114448.7A CN115309660A (en) 2022-09-14 2022-09-14 Interface testing method and device, storage medium and computer equipment

Publications (1)

Publication Number Publication Date
CN115309660A true CN115309660A (en) 2022-11-08

Family

ID=83865966

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211114448.7A Pending CN115309660A (en) 2022-09-14 2022-09-14 Interface testing method and device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN115309660A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116561014A (en) * 2023-07-07 2023-08-08 国电南瑞科技股份有限公司 Device and method for generating test case of electric power secondary equipment
CN116627851A (en) * 2023-07-24 2023-08-22 恒生电子股份有限公司 Interface testing method and device

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116561014A (en) * 2023-07-07 2023-08-08 国电南瑞科技股份有限公司 Device and method for generating test case of electric power secondary equipment
CN116561014B (en) * 2023-07-07 2023-09-29 国电南瑞科技股份有限公司 Device and method for generating test case of electric power secondary equipment
CN116627851A (en) * 2023-07-24 2023-08-22 恒生电子股份有限公司 Interface testing method and device
CN116627851B (en) * 2023-07-24 2023-10-20 恒生电子股份有限公司 Interface testing method and device

Similar Documents

Publication Publication Date Title
CN115309660A (en) Interface testing method and device, storage medium and computer equipment
CN107908541B (en) Interface testing method and device, computer equipment and storage medium
CN108255730A (en) Software interface test approach, test equipment, storage medium and device
CN104767714B (en) A kind of ID and the correlating method of user resources information, terminal and system
CN106802859A (en) A kind of method and device of client software test
CN109726108B (en) Front-end code testing method, device, system and medium based on analog data
CN108076056A (en) Cloud server login method and device
CN106897207A (en) Ui testing method and apparatus
CN110569194A (en) interface testing method and device, electronic equipment and storage medium
CN111475402A (en) Program function testing method and related device
CN113225760B (en) Network testing method and equipment
CN112822073B (en) Test method, device, system, electronic equipment and readable storage medium
CN109032956A (en) A kind of interface test method and device
CN107632909A (en) Method and system for ATE function
CN109299002A (en) Generation method, computer readable storage medium and the terminal device of test report
CN110908708B (en) Code release method, device and system
CN112019404A (en) Method and device for automatically testing FC-AE-1553 communication protocol chip
CN109828910A (en) Method and device, the computer equipment, storage medium of monkey test
CN110297754A (en) A kind of test information feedback method and system
CN110968507B (en) Coverage rate statistics method and coverage rate statistics device
CN110225097B (en) Information processing method, device and storage medium
CN114466395A (en) Method and device for testing performance of base station, storage medium and electronic device
CN110502429B (en) Management method, device, equipment and storage medium of test system
CN115904356A (en) Application program generation method and device, storage medium and computer equipment
CN114487758B (en) Test method and test system for semiconductor equipment

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