CN116991697A - Interface testing method, device, electronic equipment and storage medium - Google Patents

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

Info

Publication number
CN116991697A
CN116991697A CN202210442876.6A CN202210442876A CN116991697A CN 116991697 A CN116991697 A CN 116991697A CN 202210442876 A CN202210442876 A CN 202210442876A CN 116991697 A CN116991697 A CN 116991697A
Authority
CN
China
Prior art keywords
test
interface
configuration information
configuration file
expected result
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
CN202210442876.6A
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.)
NetsUnion Clearing Corp
Original Assignee
NetsUnion Clearing Corp
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 NetsUnion Clearing Corp filed Critical NetsUnion Clearing Corp
Priority to CN202210442876.6A priority Critical patent/CN116991697A/en
Publication of CN116991697A publication Critical patent/CN116991697A/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

Abstract

The application provides an interface testing method, an interface testing device, electronic equipment and a storage medium, wherein the interface testing method comprises the following steps: assembling a test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface, and sending the test case object to the tested interface for processing; under the condition of obtaining test response data, according to expected result configuration information in the test configuration file, assembling to obtain an expected result object with the same format as the test response data; and comparing the test response data with the expected result object, and determining a test result of the tested interface based on the comparison result. The technical scheme of the application can conveniently create the test case.

Description

Interface testing method, device, electronic equipment and storage medium
Technical Field
The present application relates to the field of software testing technologies, and in particular, to an interface testing method, an apparatus, an electronic device, and a storage medium.
Background
The interface test is a test for testing interfaces among components of a system, and is mainly used for detecting interaction points between a current system and an external system and between all subsystems in the current system, and mainly used for checking data exchange, transmission and control management processes, mutual logic dependency among the systems and the like.
The interface test method in the related art needs to pre-determine test scenes, then test the interface test method one by using different unit test codes or different unit test methods aiming at each test scene, the operation is more complicated, and a large number of test cases can be generated in the test process.
In the process of testing the interface, a tester is required to write test classes and test methods. Therefore, when the test cases are more, the test cases can be too many or the test methods are more, and the test scenes can not be quickly and clearly combed.
Content of the application
The application provides an interface testing method, an interface testing device, electronic equipment and a non-transitory computer readable storage medium, which are used for solving the defect of more testing cases in the prior art and realizing convenient creation of the testing cases.
In a first aspect, the present application provides an interface testing method, including: assembling a test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface, and sending the test case object to the tested interface for processing; under the condition of obtaining test response data, according to expected result configuration information in the test configuration file, assembling to obtain an expected result object with the same format as the test response data; and comparing the test response data with the expected result object, and determining a test result of the tested interface based on the comparison result.
The application provides an interface testing method, which further comprises the following steps: under the condition of obtaining an external dependency request from a tested interface, assembling a test simulation object according to test simulation data configuration information in the test configuration file, and sending the test simulation object to the tested interface for processing; the external dependency request corresponds to an external dependency interface of the tested interface, and the test simulation data is the test simulation data of the external dependency interface.
According to the application, the interface testing method is provided, and the assembly is realized based on a reflection mechanism.
According to the interface testing method provided by the application, the testing configuration file comprises at least one testing case configuration information corresponding to the testing scene and expected result configuration information.
The application provides an interface testing method, which further comprises the following steps: responding to the test configuration file editing instruction, and newly adding or modifying the test configuration file; the modification test profile includes one or more of the following: modifying test case configuration information and expected result configuration information corresponding to the changed test scene in the test configuration file; adding a new test scene in the test configuration file, and configuring corresponding test case configuration information and expected result configuration information for the new test scene; and deleting a test scene, test case configuration information corresponding to the test scene and expected result configuration information from the test configuration file.
According to the interface testing method provided by the application, the test cases are named by the identification of the test scene; the assembling the test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface comprises the following steps: reading test case configuration information matched with a current test scene of a tested interface from the test configuration file according to the identification of the current test scene; the step of assembling the expected result object with the same format as the test response data according to the expected result configuration information in the test configuration file comprises the following steps: and reading expected result configuration information matched with the current test scene from the test configuration file according to the identification of the current test scene of the tested interface.
According to the present application, there is provided an interface testing method, before assembling a test case object, the interface testing method further comprising: and reading the test configuration file to a memory so as to read the test case configuration information or the expected result configuration information in the test configuration file from the memory when the test case configuration information or the expected result configuration information is required.
In a second aspect, the present application further provides an interface testing apparatus, including: the test case object assembling unit is used for assembling the test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface, and sending the test case object to the tested interface for processing; the expected result object assembling unit is used for assembling the expected result object with the same format as the test response data according to the expected result configuration information in the test configuration file under the condition of obtaining the test response data; and the comparison unit is used for comparing the test response data with the expected result object and determining the test result of the tested interface based on the comparison result.
In a third aspect, the present application also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of any of the interface testing methods described above when the program is executed.
In a fourth aspect, the present application also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of any of the interface testing methods described above.
According to the interface testing method, the device, the electronic equipment and the non-transitory computer readable storage medium, the test case object and the expected result case are assembled respectively through the test case configuration information and the expected result configuration information stored in the test configuration file, so that the tested interface is tested, and the test case can be created more conveniently.
Drawings
In order to more clearly illustrate the application or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the application, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of an interface testing method according to the present application;
FIG. 2 is a second flow chart of the interface testing method according to the present application;
FIG. 3 is a third flow chart of the interface testing method according to the present application;
FIG. 4 is a flow chart of an interface testing method according to the present application;
FIG. 5 is a schematic diagram of an interface testing device according to the present application;
FIG. 6 is a second schematic diagram of the interface testing device according to the present application;
fig. 7 is a schematic structural diagram of an electronic device provided by the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be clearly and completely described below with reference to specific embodiments of the present application and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Technical terms in the embodiments of the present application are explained below.
Project interface test cases: based on different request contents configured by different scenes of the tested function, the case is generated after processing. The project interface test cases are hereinafter referred to as test cases.
Intra-project interface test: and initiating a test request to a tested interface in the project according to the generated test case, simulating a downstream application, acquiring a simulation response from the simulation response test configuration according to the test request, returning the simulation response to the tested interface, processing by the tested function according to the simulation response, generating a request result and comparing the request result with an expected result contained in the test case. The intra-project interface test is hereinafter referred to simply as interface test.
Project interface test MOCK case: based on different returned contents of the tested interface in different scene configurations, simulating response data returned by the downstream service, and processing to generate a case. The project interface test dock case is hereinafter referred to as dock case.
Project interface test expected case: based on the expected content obtained by the tested interface after receiving different requests and corresponding returned content, the case is generated after processing. The project interface test expected cases are hereinafter abbreviated as expected result cases.
The following describes in detail the technical solutions provided by the embodiments of the present application with reference to the accompanying drawings.
FIG. 1 is a flow chart of an interface testing method according to an embodiment of the present application. The method provided by the embodiment of the application can be executed by any electronic device with computer processing capability, such as a terminal device and/or a server. As shown in fig. 1, the interface testing method includes:
step 102, assembling the test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface, and sending the test case object to the tested interface for processing.
Specifically, a test case refers to a case for performing a test task on a test interface of a specific software product, and reflects a test scheme, a method, a technology and a strategy, wherein the content of the test case comprises a test target, a test environment, input data, a test step, an expected result, a test script and the like, and finally a document is formed.
Specifically, based on the content contained in the test case, a test case object in the embodiment of the present application may be generated. The test case objects may include test case configuration information in a test configuration file and interface information for the interface under test. The test case object compiles a set of test inputs, execution conditions, and expected results for a particular objective to verify that a particular software requirement is met. It should be appreciated that the test case objects are different when the test scenarios are different. And sending the test case object to a designated test interface for interface test, so that a test result can be obtained.
Specifically, the test result includes response result data, standard response data, and a matching result of the response result data and the standard response data in the test scene.
The test configuration file comprises test case configuration information and expected result configuration information corresponding to at least one test scene. Assembling the test case objects is the process of generating the test case objects based on the test case configuration information and the interface information, and the assembling may be implemented based on a reflection mechanism.
And 104, under the condition of obtaining the test response data, assembling according to the expected result configuration information in the test configuration file to obtain an expected result object with the same format as the test response data.
Specifically, the tested function of the tested interface is tested according to the test case object, so that test response data can be obtained. The test response data are response result data in the current test scene, and the expected result object is standard response data in the current test scene. Assembling the expected result object is the process of generating an assembled expected result object based on the expected result configuration information, which assembly may be implemented based on a reflection mechanism.
And 106, comparing the test response data with the expected result object, and determining the test result of the tested interface based on the comparison result.
Specifically, the expected result object is preset standard response data corresponding to the target test case object in the test configuration file, and the standard response data is used for comparing with the test response data to determine whether the test response data is a correct output result corresponding to the test case object.
Specifically, when the test response data is compared with the expected result object, if the comparison result is that the test response data is consistent with the expected result object, the test result of the tested interface is passed, and if the comparison result is that the test response data is inconsistent with the expected result object, the test result of the tested interface is failed. The expected result configuration information and the test case configuration information are stored in the same test configuration file, so that the expected result case and the test case can be synchronously filled in, checked and modified.
By adopting the technical scheme of the application, when the test cases are created for different test scenes, the new scene test work of the test interface can be successfully completed only by filling the content of the corresponding test case configuration information in the test configuration file for the scenes. When the existing test cases need to be combed to meet the coverage scene, the existing test scenes can be quickly checked only by checking the test case configuration information in the test configuration file.
By adopting the technical scheme of the embodiment of the application, a tester can formulate different test scenes by formulating different test configuration files in the software test stage, and the interface test can be better completed through the different test scenes. During business iteration, the test case configuration information can be quickly supplemented or adjusted through the test configuration file, and a large amount of unit test coding work is not needed.
Before interface testing of the embodiment of the application is carried out, a test configuration file is created for a test interface, and test case configuration information, test simulation (MOCK) configuration information and expected result configuration information are filled in the test configuration file.
Prior to step 102, the test configuration file may be read into the memory to read the test case configuration information or the expected result configuration information in the test configuration file from the memory when the test case configuration information or the expected result configuration information is needed.
The following is the test case configuration information, the rock configuration information and the predicted result configuration information content of the test scenario a of one test interface in a certain test configuration file.
case.a= { "ParamName": "ParamValue", "ParamName2": "ParamValue2" }// test case configuration information of test scenario a;
mock.a.x= { "MOCKXParam": "MOCKXValue", "MOCKXParam2": "MOCKXValue2" }// MOCK configuration information of the access X system of test scenario a;
mock.a.y= { "MOCK yparam": "MOCK yvalue", "MOCK yparam2": "MOCK yvalue2" }// MOCK configuration information of access Y system of test scene a;
result.a= { "resultParam": "resultParamValue", "resultParam2": "resultParamValue 2" }// expected result configuration information for test scenario a;
specifically, case.a represents test case configuration information, when an interface is tested, the interface is taken as an interface input parameter, mock.a.x represents corresponding MOCK configuration information of accessing the X system under test scene a, mock.a.y represents corresponding MOCK configuration information of accessing the Y system under test scene a, and result.a represents expected result configuration information obtained after the tested interface is processed according to the request. The tested interface returns the test result and compares the test result with the expected result, so that the aim of testing the tested interface can be achieved. Wherein, the X system and the Y system are other systems except the system.
One test configuration file may include one test scene or multiple test scenes.
For example, when one test configuration file includes a plurality of test scenes, the plurality of test scenes include a test scene a, a test scene B, a test scene SUCCESS, a test scene FAIL, and other scenes, and each test scene corresponds to test case configuration information, dock configuration information, and expected result configuration information.
For example, in the test configuration file, the test case configuration information, the rock configuration information, and the prediction result configuration information of the test scenario B, the test scenario SUCCESS, and the test scenario FAIL may include the following:
case.b= { "ParamName": "ParamValue", "ParamName2": "ParamValue2" }// test case configuration information of test scenario B;
mock.b.x= { "MOCKXParam": "MOCKXValue", "MOCKXParam2": "MOCKXValue2" }// MOCK configuration information of the access X system of test scene B;
mock.b.z= { "MOCKZParam": "MOCKZValue", "MOCKZParam2": "MOCKZValue2" }// MOCK configuration information of the access Z system of test scene B;
result.b= { "resultParam": "resultParamValue", "resultParam2": "resultParamValue 2" }// expected result configuration information for test scenario B;
case. SUCCESS= { "ParamName": "ParamValue", "ParamName2": "ParamValue2" }// test case configuration information of test scenario SUCCESS;
mock.success.x= { "MOCKXParam": "MOCKXValue", "MOCKXParam2": "MOCKXValue2" }// MOCK configuration information of the access X system of the test scene SUCCESS;
mock.success.z= { "MOCKZParam": "MOCKZValue", "MOCKZParam2": "MOCKZValue2" }// MOCK configuration information of the access Z system of the test scene SUCCESS;
success= { "resultParam": "resultParamValue", "resultParam2": "result ParamValue" }// expected result configuration information of the test scenario SUCCESS;
case, FAIL= { "ParamName": "ParamValue", "ParamName2": "ParamValue2" }// test case configuration information of test scenario FAIL;
mock.fail.x= { "MOCKXParam": "MOCKXValue", "MOCKXParam2": "MOCKXValue2" }// MOCK configuration information of the access X system of the test scene FAIL;
mock.fail.z= { "MOCKZParam": "MOCKZValue", "MOCKZParam2": "MOCKZValue2" }// MOCK configuration information of the access Z system of the test scene FAIL;
result.fail= { "resultParam": "resultParamValue", "resultParam2": "result ParamValue" }// expected result configuration information for the test scenario FAIL;
as can be seen from the above program code, the naming of the test case configuration information includes the identification data of the test scenario corresponding to the test case configuration information, that is, the test case configuration information may be named with the identification of the test scenario. For example, when the identification data of the test scenario is a, the name of the test case configuration information, that is, the variable name of case.a, may be the identification data a of the test scenario.
Here, the identification data may be a name, a number, or other unique data.
When the naming of the test case configuration information includes the identification data of the test scene, in step 102, the test case configuration information matched with the current test scene may be read from the test configuration file according to the identification of the current test scene of the tested interface; in step 104, expected result configuration information matching the current test scenario may be read from the test configuration file according to the identification of the current test scenario of the tested interface.
When the test case configuration information corresponding to the test scene is extracted for different test scenes, the corresponding test case configuration information of the current test scene can be obtained only by searching according to the identification data such as the test scene name and the like, namely searching the test case name in the test configuration file.
Specifically, the test case configuration information may be named according to the identifier of the test scene, and when the test case configuration information is obtained, the test case configuration information matched with the current test scene is searched in the test configuration file according to the identifier of the current test scene of the tested interface.
And sequentially searching the test case configuration information corresponding to different test scenes of the test interface, and assembling the test case objects according to the searched test case configuration information so as to perform interface test of each test scene, thereby completing the interface test of the test interface.
Different test interfaces may use different test profiles, such that each test profile contains only one test case for a test interface, and each test interface may correspond to one or at least two test profiles. These test profiles may be named according to the identification data of the corresponding test interface. When different test interfaces are tested, the test configuration files corresponding to the test interfaces are only required to be called according to the identification data of the test interfaces.
For example, test interface M1 corresponds to two test profiles, which may be named M1-1.Properties and M1-2.Properties, respectively. The test interface M2 corresponds to three test profiles, which may be named M2-1.Properties, M2-2.Properties, and M2-3.Properties, respectively. Thus, when the test configuration file is called, the test configuration file corresponding to the tested interface is searched and called.
In addition, test cases for different test interfaces may also be stored in the same test configuration file. For example, in one embodiment, a test configuration file includes test cases of two test interfaces, namely test interface M3 and test interface M4, where identification data identifying different test interfaces, such as M3 and M4, may be used in the variable identification of the test cases to extract the test cases corresponding to the test interfaces when testing the different test interfaces.
For example, the test case configuration information corresponding to the test scenario N1 of the test interface M3 may be named as case.m3.n1, the dock configuration information corresponding to the access X system is dock.m3.n1.x, and the expected result case configuration information corresponding to the access X system is result.m3.n1. The test case configuration information corresponding to the test scene N2 of the named test interface M4 is case. M4.N2, the MOCK configuration information corresponding to the access X system is MOCK. M4.N2.X, and the corresponding expected result configuration information is result. M4.N2. Therefore, when the test interface is tested in different test scenes, the test case configuration information, the MOCK configuration information and the expected result configuration information in the test configuration file are only required to be searched according to the identification data of the test interface and the test scenes.
After the test configuration file in the embodiment of the application is adopted to store the test case configuration information, the configuration work of the test cases aiming at different scenes in the unit test codes can be omitted.
In the embodiment of the application, in the process of processing the test case object by the tested interface, other interfaces are not required to be accessed, and only the interior of the current system where the tested interface is positioned is required to be accessed, so that only the test case configuration information and the expected result configuration information corresponding to the test case are required to be obtained.
In the embodiment of the application, under the condition of obtaining an external dependency request from a tested interface, a test simulation object is assembled according to test simulation data configuration information in a test configuration file, and the test simulation object is sent to the tested interface for processing; the external dependency request corresponds to an external dependency interface of the tested interface, and the test simulation data is test simulation data of the external dependency interface.
And in the process of processing the test case by the tested interface, if the tested interface determines that other interfaces need to be accessed, acquiring MOCK configuration information corresponding to the other interfaces from the test configuration file, and acquiring corresponding MOCK return data so as to process the test case according to the MOCK return data.
Specifically, during the testing process, for some objects that are not easily constructed or easily obtained, a virtual MOCK object may be created to perform the test. According to the MOCK object, corresponding MOCK return data can be acquired to replace return data of the real object.
Here, the dock configuration information is obtained to obtain the dock object, which is a substitute for other interfaces to be called by the simulated tested interface. The MOCK return data simulates return data of other interfaces to be called by the tested interface.
Considering the situation that the test framework calls the MOCK to return data in the process of testing the tested interface, the interface test method shown in fig. 2 comprises the following steps:
step 201, obtaining a test case and sending the test case to a tested interface, wherein the test case is assembled according to the test case configuration information and the interface information.
Step 202, it is determined whether other interfaces need to be invoked. If yes, go to step 203, if no, go to step 205.
Step 203, obtaining MOCK return data corresponding to a MOCK case of the interface to be called, wherein the MOCK case is assembled according to the simulation test configuration information.
Step 204, the MOCK return data is sent to the tested interface.
Step 205, obtaining a first processing result obtained by processing the tested interface.
Step 206, obtaining the expected result case. The expected result case is assembled according to expected result configuration information. The expected return result is included in the expected result case.
Step 207, comparing the first processing result with the expected returned result, and determining the test result of the tested interface based on the comparison result.
As shown in fig. 3, when the interface test is performed, it can be seen that the interaction relationship between the test framework and the test configuration file is when the tested interface needs to call other interfaces. Specifically, the interface test method as shown in fig. 3 includes the following steps:
in step 301, test case configuration information 311 is extracted from the test configuration file to assemble test cases and send to the tested interface.
Step 302, the self-test configuration file extracts the dock configuration information 312, assembles a dock case, obtains dock return data according to the dock case, and sends the dock return data to the tested interface.
Step 303, obtaining a second processing result returned by the tested interface, where the second processing result is obtained after processing according to the received test case and the MOCK returned data.
In step 304, the expected result configuration information 313 is extracted from the test configuration file, the expected result case is assembled and the expected return result is obtained according to the expected result case.
And 305, comparing the expected returned result with the second processing result to obtain a test result of the tested interface.
In the related art, the adjustment of the test case cannot be completed quickly when the adjustment of the test scene is performed, and the code maintenance cost is high.
In the embodiment of the application, the test configuration file can be added or modified in response to the test configuration file editing instruction. Modifying the test profile may include a variety of ways.
In one way of modifying the test configuration file, when the test scenario is changed, the test case configuration information and the expected result configuration information corresponding to the changed test scenario in the test configuration file may be modified.
In another way of modifying the test configuration file, a new test scenario may be added to the test configuration file, and corresponding test case configuration information and expected result configuration information may be configured for the new test scenario.
In another way of modifying the test configuration file, a test scenario, the test case configuration information corresponding to the test scenario, and the expected result configuration information may be deleted from the test configuration file.
Therefore, if the test content of the existing scene needs to be adjusted, the adjustment of the test scene can be completed rapidly only by adjusting the test case configuration information, the MOCK configuration information and the expected result configuration information in the test configuration file. Specifically, when the test case is created through the test configuration file, the creation of the test case can be completed only by adding the corresponding test case configuration information into the test configuration file. When the test scene of the test interface is changed due to service adjustment, a great amount of manual change of the test program is not needed, and only the corresponding test case configuration information in the test configuration file is needed to be adjusted. When counting whether the current test case covers enough test scenes, the user can quickly know whether the current test scene meets the coverage requirement by uniformly checking the configuration information of the current test case in the test configuration file.
In the technical scheme of the embodiment of the application, the test configuration file is created, called and analyzed, the test case configuration information, the MOCK configuration information and the expected result configuration information corresponding to the test scene can be obtained from the analysis data of the test configuration file, and the interface test is carried out according to the test case configuration information, the MOCK configuration information and the expected result configuration information.
As shown in fig. 4, an interface testing method according to an embodiment of the present application includes the following steps:
step 401, a test configuration file is created for the test interface, and test case configuration information, MOCK configuration information and expected result configuration information corresponding to different test scenes of the test interface are filled in the test configuration file.
Step 402, a unit test method is created in which test case configuration information is obtained from a test configuration file through a test framework, and test cases are assembled.
Step 403, send the test case to the tested interface.
Step 404, obtaining the MOCK configuration information in the test configuration file through the test framework, and assembling a MOCK case to obtain MOCK return data and sending the MOCK return data to the tested interface.
And step 405, obtaining expected result configuration information in the test configuration file through the test framework, and assembling to obtain an expected result case.
And step 406, determining the test result of the tested interface according to the data returned by the tested interface and the expected result case.
Compared with the existing interface unit test mode, the technical scheme of the application can more conveniently create test cases, rapidly adjust the test cases and conveniently and statistically analyze the distribution situation of the test cases, and the test cases are assembled through the test configuration file, thereby being beneficial to the subsequent test case writing work aiming at different scene tests.
According to the interface test method provided by the embodiment of the application, the test case object and the expected result case are assembled respectively through the test case configuration information and the expected result configuration information stored in the test configuration file, so that the tested interface is tested, and the test case can be created more conveniently.
The interface testing device provided by the application is described below, and the interface testing device described below and the interface testing method described above can be referred to correspondingly.
As shown in fig. 5, an interface testing apparatus provided in an embodiment of the present application includes:
and the test case object assembling unit 502 is configured to assemble the test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface, and send the test case object to the tested interface for processing.
And an expected result object assembling unit 504, configured to assemble an expected result object with the same format as the test response data according to the expected result configuration information in the test configuration file, in the case of obtaining the test response data.
And a comparison unit 506, configured to compare the test response data with the expected result object, and determine a test result of the tested interface based on the comparison result.
By adopting the technical scheme of the application, when the test cases are created for different test scenes, the new scene test work of the test interface can be successfully completed only by filling the content of the corresponding test case configuration information in the test configuration file for the scenes. When the existing test cases need to be combed to meet the coverage scene, the existing test scenes can be quickly checked only by checking the test case configuration information in the test configuration file.
Specifically, the interface test apparatus may further include a test simulation object assembly unit for: under the condition of obtaining an external dependency request from a tested interface, assembling a test simulation object according to test simulation data configuration information in a test configuration file, and sending the test simulation object to the tested interface for processing; the external dependency request corresponds to an external dependency interface of the tested interface, and the test simulation data is test simulation data of the external dependency interface.
As shown in fig. 6, an interface testing apparatus according to another embodiment of the present application includes not only a test case object assembling unit 502, an expected result object assembling unit 504, and an alignment unit 506, but also a test simulation object assembling unit 601 and a configuration unit 602, compared with the interface testing apparatus shown in fig. 5.
A configuration unit 602, configured to perform one or more of the following steps: responding to the test configuration file editing instruction, and newly adding or modifying the test configuration file; modifying the test profile includes one or more of the following: modifying test case configuration information corresponding to the changed test scene in the test configuration file and expected result configuration information; adding a new test scene in the test configuration file, and configuring corresponding test case configuration information and expected result configuration information for the new test scene; and deleting a test scene, test case configuration information corresponding to the test scene and expected result configuration information in the test configuration file.
Compared with the existing interface unit test mode, the technical scheme of the application can more conveniently create test cases, rapidly adjust the test cases and conveniently and statistically analyze the distribution situation of the test cases, and the test cases are configured through the test configuration file, thereby being beneficial to the subsequent test case writing work aiming at different scene tests.
It can be understood that the above-mentioned interface testing device can implement each step of the interface testing method provided in the foregoing embodiment, and the relevant explanation about the interface testing method is applicable to the interface testing device, which is not repeated herein.
According to the interface testing device provided by the embodiment of the application, the test case object and the expected result case are assembled respectively through the test case configuration information and the expected result configuration information stored in the test configuration file, so that the tested interface is tested, and the test case can be created more conveniently.
Fig. 7 illustrates a physical schematic diagram of an electronic device, as shown in fig. 7, which may include: processor 710, communication interface (Communications Interface) 720, memory 730, and communication bus 740, wherein processor 710, communication interface 720, memory 730 communicate with each other via communication bus 740. Processor 710 may call logic instructions in memory 730 to perform an interface test method comprising: assembling a test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface, and sending the test case object to the tested interface for processing; under the condition of obtaining test response data, according to expected result configuration information in the test configuration file, assembling to obtain an expected result object with the same format as the test response data; and comparing the test response data with the expected result object, and determining a test result of the tested interface based on the comparison result.
Further, the logic instructions in the memory 730 described above may be implemented in the form of software functional units and may be stored in a computer readable storage medium when sold or used as a stand alone product. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present application also provides a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the interface test method provided by the above methods, the method comprising: assembling a test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface, and sending the test case object to the tested interface for processing; under the condition of obtaining test response data, according to expected result configuration information in the test configuration file, assembling to obtain an expected result object with the same format as the test response data; and comparing the test response data with the expected result object, and determining a test result of the tested interface based on the comparison result.
In yet another aspect, the present application also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, is implemented to perform the above-provided interface test methods, the method comprising: assembling a test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface, and sending the test case object to the tested interface for processing; under the condition of obtaining test response data, according to expected result configuration information in the test configuration file, assembling to obtain an expected result object with the same format as the test response data; and comparing the test response data with the expected result object, and determining a test result of the tested interface based on the comparison result.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present application without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (10)

1. An interface testing method, comprising:
assembling a test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface, and sending the test case object to the tested interface for processing;
under the condition of obtaining test response data, according to expected result configuration information in the test configuration file, assembling to obtain an expected result object with the same format as the test response data;
and comparing the test response data with the expected result object, and determining a test result of the tested interface based on the comparison result.
2. The interface testing method of claim 1, further comprising:
under the condition of obtaining an external dependency request from a tested interface, assembling a test simulation object according to test simulation data configuration information in the test configuration file, and sending the test simulation object to the tested interface for processing;
the external dependency request corresponds to an external dependency interface of the tested interface, and the test simulation data is the test simulation data of the external dependency interface.
3. Interface testing method according to claim 1 or 2, characterized in that the assembly is implemented based on a reflection mechanism.
4. The interface testing method according to claim 1, wherein the test configuration file includes test case configuration information and expected result configuration information corresponding to at least one test scenario.
5. The interface testing method of claim 4, further comprising:
responding to the test configuration file editing instruction, and newly adding or modifying the test configuration file; the modification test profile includes one or more of the following:
modifying test case configuration information and expected result configuration information corresponding to the changed test scene in the test configuration file;
adding a new test scene in the test configuration file, and configuring corresponding test case configuration information and expected result configuration information for the new test scene;
and deleting a test scene, test case configuration information corresponding to the test scene and expected result configuration information from the test configuration file.
6. The interface testing method of claim 4, wherein,
the test cases are named by the identification of the test scene;
the assembling the test case object according to the test case configuration information in the test configuration file and the interface information of the tested interface comprises the following steps:
reading test case configuration information matched with a current test scene of a tested interface from the test configuration file according to the identification of the current test scene;
the step of assembling the expected result object with the same format as the test response data according to the expected result configuration information in the test configuration file comprises the following steps:
and reading expected result configuration information matched with the current test scene from the test configuration file according to the identification of the current test scene of the tested interface.
7. The interface testing method of claim 1, wherein prior to assembling the test case object, the interface testing method further comprises:
and reading the test configuration file to a memory so as to read the test case configuration information or the expected result configuration information in the test configuration file from the memory when the test case configuration information or the expected result configuration information is required.
8. Interface testing device, characterized by means for implementing the steps of the interface testing method according to any of claims 1 to 7.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the interface testing method of any of claims 1 to 7 when the program is executed by the processor.
10. A non-transitory computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when executed by a processor, implements the steps of the interface testing method of any of claims 1 to 7.
CN202210442876.6A 2022-04-25 2022-04-25 Interface testing method, device, electronic equipment and storage medium Pending CN116991697A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210442876.6A CN116991697A (en) 2022-04-25 2022-04-25 Interface testing method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210442876.6A CN116991697A (en) 2022-04-25 2022-04-25 Interface testing method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116991697A true CN116991697A (en) 2023-11-03

Family

ID=88520067

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210442876.6A Pending CN116991697A (en) 2022-04-25 2022-04-25 Interface testing method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116991697A (en)

Similar Documents

Publication Publication Date Title
CN109800258B (en) Data file deployment method, device, computer equipment and storage medium
CN112052172B (en) Rapid test method and device for third-party channel and electronic equipment
CN114692169B (en) Page vulnerability processing method applying big data and AI analysis and page service system
CN110569194A (en) interface testing method and device, electronic equipment and storage medium
CN110532182A (en) A kind of automated testing method and device of virtual platform
CN114117977B (en) Method suitable for automatically verifying processor system scene
US11409928B2 (en) Configurable digital twin
CN112650689A (en) Test method, test device, electronic equipment and storage medium
CN116431522A (en) Automatic test method and system for low-code object storage gateway
CN116527536B (en) Test evaluation method, device and system based on parallel simulation
CN116991697A (en) Interface testing method, device, electronic equipment and storage medium
CN114721969A (en) Method and device for separating interface automation test data and test codes
CN111078527B (en) Auxiliary system and method for pressure testing of server
CN109800155B (en) Method and device for testing QTE interlocking application software based on Probe
CN115840715B (en) Software test management method, device and storage medium
CN113360406B (en) Method and device for testing JSbridge method of application program
CN112000581B (en) Testing method and tool for Cocos2D framework software
CN108628750B (en) Test code processing method and device
CN115220822A (en) Method and device for realizing interface baffle
CN116955120A (en) Test script generation method, device, computer equipment and storage medium
CN116483727A (en) Interface testing method, device, computer equipment and storage medium
CN118035072A (en) Automatic acceptance method and system based on multi-version upgrading
CN113704113A (en) Test report management method and device, readable storage medium and terminal equipment
CN117271298A (en) Test method and apparatus
CN113918455A (en) Automatic test case conversion 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