CN109446075B - Interface testing method and device - Google Patents

Interface testing method and device Download PDF

Info

Publication number
CN109446075B
CN109446075B CN201811158041.8A CN201811158041A CN109446075B CN 109446075 B CN109446075 B CN 109446075B CN 201811158041 A CN201811158041 A CN 201811158041A CN 109446075 B CN109446075 B CN 109446075B
Authority
CN
China
Prior art keywords
test
interface
preset
environment
configuration information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811158041.8A
Other languages
Chinese (zh)
Other versions
CN109446075A (en
Inventor
赵家盈
赵园园
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Internet Security Software Co Ltd
Original Assignee
Beijing Kingsoft Internet Security Software 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 Beijing Kingsoft Internet Security Software Co Ltd filed Critical Beijing Kingsoft Internet Security Software Co Ltd
Priority to CN201811158041.8A priority Critical patent/CN109446075B/en
Publication of CN109446075A publication Critical patent/CN109446075A/en
Application granted granted Critical
Publication of CN109446075B publication Critical patent/CN109446075B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Abstract

The embodiment of the invention provides an interface testing method and device, and the scheme is as follows: configuration information required by the interface test can be determined, the preset test environment is initialized according to the configuration information, the test environment for the interface test is obtained, and the interface test is executed according to the preset test request data in the test environment. By the scheme provided by the embodiment of the invention, the testing environment required by the test can be automatically configured in the interface testing process, the interface test is completed, the human resources are greatly saved, and the interface testing efficiency is improved.

Description

Interface testing method and device
Technical Field
The invention relates to the technical field of computer application, in particular to an interface testing method and device.
Background
At present, many online service systems involve the interworking between an API (Application Programming Interface) and a third-party system, and generally, after the third-party system is introduced, an Interface test can be directly performed on the online service system and the third-party system for an online service system with a mature technology and supporting a recognized standard protocol. If the test is passed, the interaction between the online service system and the third-party system can be directly realized.
However, in the interface testing process, the configuration of the testing environment, the simulation of the real online request and the verification of the correctness of the interface response parameters are all completed manually, and especially, the validity of each field needs to be checked manually in the interface response parameter verification process. Therefore, a large amount of human resources are consumed in the interface testing process.
In addition, for each interface test item, because configuration of the test environment of the item needs to be completed manually, in the interface test process, due to the item scheduling and resource allocation of the tester, the test period of the item may be lengthened, which affects the efficiency of the interface test.
Disclosure of Invention
The embodiment of the invention aims to provide an interface testing method and device, so that in the interface testing process, human resources are saved, and the testing efficiency is improved. The specific technical scheme is as follows:
the embodiment of the invention provides an interface testing method, which comprises the following steps:
determining configuration information required for interface testing;
initializing a preset test environment according to the configuration information to obtain a test environment for the interface test;
and executing the interface test according to preset test request data in the test environment.
Further, the interface test is a real request test;
the initializing a preset test environment according to the configuration information to obtain a test environment for the interface test includes:
and loading the configuration information into a preset test environment based on the preset test environment, and initializing the preset test environment to obtain the test environment required by the real request test.
Further, the interface test is a response sample test;
the determining configuration information required for the interface test includes:
environmental configuration information and simulation server configuration information required for the interface test are determined.
Further, initializing a preset test environment according to the configuration information to obtain a test environment for the interface test, including:
and loading the environment configuration information into a preset test environment, initializing the preset test environment, loading the configuration information of the simulation server into a preset simulation service mock server, and initializing the preset mock server to obtain the test environment required by the response sample test.
Further, in the test environment, according to preset test request data, executing the interface test includes:
in the test environment, sending preset test request data to the initialized preset mock server;
and after the initialized preset mock server receives the preset test request data, responding to the preset test request data.
Further, after the interface test is executed according to preset test request data in the test environment, the method further includes:
obtaining a test response result of the interface test and a test log (log) of the interface test;
and determining the test result of the interface test according to the test response result and the test log.
Further, after determining the test result of the interface test according to the test response result and the test log, the method further includes:
storing the test request data, the test response result and the test result in a preset database as test data;
judging whether the interface test passes or not according to the test result;
if the interface test is passed, displaying the test result in a test interface, wherein the test interface is a program application interface for a tester to perform the interface test;
if the interface test is failed, extracting data in the test data according to the test response result, determining the reason why the interface test fails, and displaying the test response result and the reason why the interface test fails in the test interface.
The embodiment of the invention also provides an interface testing device, which comprises:
the configuration information determining module is used for determining configuration information required by interface testing;
the test environment configuration module is used for initializing a preset test environment according to the configuration information to obtain a test environment for the interface test;
and the interface test execution module is used for executing the interface test according to preset test request data in the test environment.
Further, the interface test is a real request test;
the test environment configuration module is specifically configured to load the configuration information into a preset test environment based on the preset test environment, and perform initialization processing on the preset test environment to obtain a test environment required by the real request test.
Further, the interface test is a response sample test;
the configuration information determining module is specifically configured to determine environment configuration information and simulation server configuration information required for the interface test.
Further, the test environment configuration module is specifically configured to load the environment configuration information into a preset test environment, perform initialization processing on the preset test environment, load the simulation server configuration information into a preset simulation service mock server, perform initialization processing on the preset mock server, and obtain a test environment required by the response sample test.
Further, the interface test execution module is specifically configured to send preset test request data to the initialized preset mock server in the test environment; and after the initialized preset mock server receives the preset test request data, responding to the preset test request data.
Further, the apparatus further comprises:
a test result determining module, configured to obtain a test response result of the interface test and a test log (log) of the interface test; and determining the test result of the interface test according to the test response result and the test log.
Further, the apparatus further comprises:
the test data storage module is used for storing the test request data, the test response result and the test result in a preset database as test data;
the judging module is used for judging whether the interface test passes or not according to the test result; if the interface test is passed, displaying the test result in a test interface, wherein the test interface is a program application interface for a tester to perform the interface test; if the interface test is failed, extracting data in the test data according to the test response result, determining the reason why the interface test fails, and displaying the test response result and the reason why the interface test fails in the test interface.
The embodiment of the invention also provides electronic equipment, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing any step of the interface testing method when executing the program stored in the memory.
Embodiments of the present invention further provide a computer program product containing instructions, which when run on a computer, cause the computer to execute any of the above-mentioned interface testing methods.
According to the interface testing method and device provided by the embodiment of the invention, the configuration information required by the interface testing can be determined, the initialization processing is carried out on the preset testing environment according to the configuration information, the testing environment for the interface testing is obtained, and the interface testing is executed according to the preset testing request data in the testing environment. By the scheme provided by the embodiment of the invention, the testing environment required by the test can be automatically configured in the interface testing process, the interface test is completed, the human resources are greatly saved, and the interface testing efficiency is improved.
Of course, not all of the advantages described above need to be achieved at the same time in the practice of any one product or method of the invention.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of an interface testing method according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of an interface testing apparatus according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
According to the interface testing method and device provided by the embodiment of the invention, the configuration information required by the interface testing can be determined, the initialization processing is carried out on the preset testing environment according to the configuration information, the testing environment for the interface testing is obtained, and the interface testing is executed according to the preset testing request data in the testing environment. By the scheme provided by the embodiment of the invention, the testing environment required by the test can be automatically configured in the interface testing process, the interface test is completed, the human resources are greatly saved, and the interface testing efficiency is improved.
An embodiment of the present invention provides an interface testing method, as shown in fig. 1, which at least includes the following steps:
step S101, determining configuration information required for interface testing.
In this step, before performing the interface test, configuration information required for the interface test may be determined, for example, environment configuration information required for the test environment configuration, or simulation server configuration information required for the preset mock server configuration in the response sample test, and the like. The configuration information at least includes an interface type, a transaction mode, and a URL (Uniform Resource Locator) address.
In the embodiment of the present invention, the determination of the configuration information may be obtained by a test platform. For example, when the user selects to actually request the test, a proper interface type and a proper transaction mode can be selected on the front-end interface of the test platform according to the configuration information, and the URL address of the system to be tested and the like can be entered. When the user selects the response sample test, a test sample text box is arranged on the front-end interface of the test platform, and the user can select to import or copy the configuration information into the test sample text box. When the rear end of the test platform monitors that the front end has a test event, for example, a user selects a "start test" button at the front end of the test platform, the rear end and the front end perform information interaction, and the configuration information is obtained from the front end by the rear end of the test platform.
As can be seen from the above description, in the embodiment of the present invention, at least two test methods, namely a true request test and a response sample test, can be supported. To illustrate the selection of the actual request test and the response sample test, if the system a is a research and development product of the company a and the system B is a research and development product of the company B, an interface test between the system a and the system B is required. In the interface test process, a real system A sends a data request instruction to a system B, and the system B feeds back a corresponding response result to the system A according to the data request instruction. If the system B provided by the company B to the company A is a real existing system, the real system A and the real system B are adopted to carry out interface test, and the interface test method belongs to real request test. If company B provides company a with only some parameters related to system B, then the real system a and the system B simulated according to the parameters provided by company B are used to perform an interface test, and the interface test method belongs to a response sample test. In addition, when a real system a and a real system B are used to perform a real request test, and the system B may not be able to respond 100% of the data request command sent by the system a due to factors such as the system itself or the environment, the simulated system B and the real system a may be used to perform a response sample test. Therefore, when determining whether the interface test is a real request test or a response sample test, a specific interface test method can be selected according to actual conditions.
It can be understood that, when the system B cannot respond 100% to the data request instruction sent by the system a due to factors such as the system itself or the environment, the real request test may be converted into the response sample test, and the conversion of the test method may be to select the response sample test to perform the interface test again after the real request test is completed and it is determined that there is an unresponsive condition according to the test result. For example, when the API interface of the system B fails to receive the data request instruction sent by the system a, which directly results in a test failure, and when the test result is analyzed and a situation that the test request instruction is not responded is found, the system B which responds to the sample test simulation may be selected to complete the interface test between the system a and the system B. Meanwhile, the test method may be changed such that, in the real request test process, when the data request command does not respond, the real request test is directly changed into the response sample test according to the parameters of the real system B, for example, the test request command is to obtain the age information of a certain user, but there is no age information about the user in the real system B, so that the real system B cannot respond to the request test command, and at this time, the interface test may be directly executed according to the parameters of the real system B and the preset test request data according to the step of the response sample test. At this time, the response sample test may be performed from the test request command that the real system B does not respond to, and the interface test between the system a and the simulation system B may be performed, or may be restarted.
In the embodiment of the present invention, before the interface test is performed on the system a and the system B or the simulated system B, it may be determined whether the interface test is possible. For example, the interface test may be performed by whether the system a and the system B support the same interface protocol, such as an Open Real-Time Bidding (Open Real-Time Bidding) 1.0 protocol or an Open RTB 2.0 protocol.
Further, when the interface test is a real request test, determining environment configuration information required for the real request test as configuration information.
When the interface test is a response sample test, determining environment configuration information and simulation server configuration information required by the response sample test.
Specifically, when the interface test is a real request test, information such as a state of a test system required for the real request test or a network state required for the test is acquired as configuration information. For example, taking the example that the system a sends the data request instruction to the system B as an example for explanation, since both the system a and the system B may have corresponding API interfaces, assuming that the system a sends the test request instruction to the system B now, when the user selects the real response test, if the current working state of the system a is that the system a receives the data request instruction of another system or the user, and responds to the received data request instruction. At this time, the operating state of the system a needs to be adjusted according to the acquired configuration information.
When the interface test is a response sample test, acquiring configuration information of a test environment required by the response sample test as environment configuration information and configuration information of a simulation server for receiving and responding to a data request instruction as simulation server configuration information. Compared with the real request test, in the response sample test process, the system B is replaced by the simulation system, so when the user selects the response sample test, the environment configuration information can be represented as environment configuration information such as the state of the test system or the network state required by the test for the response sample test, and the simulation server configuration information required by the simulation system corresponding to the system B.
As can be seen from the above, when the interface test is performed by different test methods, the corresponding test environments are different, and the required configuration information is also different. Therefore, in the embodiment of the present invention, before determining the configuration information, it is necessary to determine the test method adopted by the interface test, and after determining the test method, the step S101 is executed to determine the configuration information required for the interface test according to the test method.
And S102, initializing a preset test environment according to the configuration information to obtain the test environment for the interface test.
In this step, according to the configuration information determined in step S101, the configuration information is loaded into a preset test environment, so as to implement initialization processing on the preset test environment, and obtain a test environment for interface testing.
In the embodiment of the present invention, for the configuration information, the configuration information may be stored in a preset database, and a configuration file is generated.
Specifically, before initializing the preset test environment according to the configuration information to obtain the test environment for interface testing, the configuration information may be stored in a preset database to generate a configuration file.
In the embodiment of the present invention, after the configuration information is loaded into the preset environment, a data file corresponding to the configuration information is generated in the preset environment. However, during the interface test process, the interface test process of the system may not be completed by one test. Therefore, the data file in the preset environment will be continuously updated with the progress of each interface test, and the configuration information corresponding to the previous interface test will be covered. In order to facilitate the user to accurately track the configuration information corresponding to each test in the later stage, the method may be adopted, and for each interface test, the corresponding configuration file is generated in the preset database, and the phenomenon that the configuration file is covered does not occur, so that the user can conveniently search or call the configuration file after the interface test is completed.
Further, when the interface test is a real request test, based on a preset test environment, the configuration information is loaded into the preset test environment, and the initialization processing is performed on the preset test environment, so that a test environment required by the real request test is obtained.
Optionally, when the interface test is a real request test, based on the preset test environment, the configuration information is loaded into the preset test environment, parameters in the preset test environment are adjusted according to the configuration information, an initialization process of the preset test environment is completed, and a test environment required by the interface test is obtained. Taking the example that the system a sends the data request instruction to the system B as an example, the current working state of the system a is that the system a provides response data to other systems or users, when the system a sends the test request instruction to the system B, the test platform may load the configuration information into the system a, and the system a may adjust the current working state according to the configuration information to obtain a test environment required for the interface test.
Further, when the interface test is a response sample test, loading the environment configuration information into a preset test environment, initializing the preset test environment, loading the configuration information of the simulation server into a preset mock server (simulation service), and initializing the preset mock server to obtain a test environment required by the response sample test.
Optionally, when the interface test is a response sample test, the environment configuration information included in the configuration information may be loaded into a preset test environment, and parameters in the preset test environment are adjusted according to the environment configuration information, so as to complete initialization of the preset test environment; meanwhile, the configuration information of the simulation server contained in the configuration information can be loaded into the preset mock server, parameters in the preset mock server are adjusted according to the configuration information of the simulation server, and initialization of the preset mock server is completed; and taking the initialized preset test environment and the initialized mock server as the test environment required by the response sample test. For example, when the interface test is a response sample test, compared with a real request test, the system B may be simulated by using a preset mock server, at this time, the system a is still used to send a test request instruction to the preset mock server, and besides the working state of the system a may be adjusted according to the environment configuration information in the configuration information, parameters in the preset mock server may also be adjusted according to the simulator configuration information in the configuration information, so as to complete the initialization processing of the preset mock server, and the system B is simulated by using the initialized preset mock server, so that the test environment for responding to the sample test is formed by the initialized preset test environment and the initialized preset mock server.
In the embodiment of the present invention, the configuration of the test environment is only described from the sending end of the test request data, and in the actual configuration process, the configuration may also be performed on the responding end of the test request data, that is, the system B in the real request test and the preset mock server in the response sample test. For example, if the test request instruction is to acquire user login information of the system B, a user may be simulated in the system B to log in the system B, and login information of the user may be generated.
As can be seen from the above, the preset mock server can be initialized according to the configuration information, and the initialized preset mock server is obtained and used for response sample testing, so that the embodiment of the present invention can support response sample testing.
Step S103, in the test environment, according to the preset test request data, executing the interface test.
In this step, in the test environment configured in step S102, a test request instruction is sent to the system to be tested according to the preset test request data, and the system to be tested receives and identifies the preset test request data in the test request instruction, and responds to the preset test request data to complete the interface test.
Specifically, if the interface test is a real request test, assuming that the system a sends the test request instruction to the system B, in the test environment, when the system B receives the test request instruction, recognizing preset test request data in the test request instruction, and feeding back a result corresponding to the test request instruction to the system a as a test response result according to the preset test request data, thereby completing the real request test. For example, the preset test request data is an ID name for obtaining user login in the system B, when a real request test is performed, the system a sends a test request instruction including the test request data to the system B, when the system B receives the test request instruction, the system B identifies the test request instruction, and feeds back the ID name for user login to the system a according to an identification result, for example, three pieces of data are fed back to the system a, thereby completing an interface test.
Further, when the interface test is a response sample test, sending preset test request data to the initialized preset mock server in the test environment; and after the initialized preset mock server receives the preset test request data, responding to the preset test request data.
Specifically, if the interface test is a response sample test, assuming that the test request instruction is received by the system a, when the initialized preset mock server receives the test request instruction, the preset test request data in the test request instruction is identified, and a result corresponding to the test request instruction is fed back to the system a as a test response result according to the preset test request data, so as to complete the response sample test. Compared with the real request test, the response sample test is to simulate the system B by the initialized preset mock server, that is, the system a sends a data request instruction to the initialized preset mock server, and the initialized preset mock server responds to the data request instruction.
In the embodiment of the present invention, a part of data in the preset test request data may be preset, and a part of data may be set according to the configuration information. For example, the data interaction mode between the system a and the system B may be set according to the configuration information. The expected test response result in the preset request data may be preset, for example, the preset test request data obtains the ID name of the user login in the system B, and the ID name of the user login may be set to zhang.
Further, in a test environment, after the interface test is executed according to the preset test request data, a test response result of the interface test and a test log (log) of the interface test can be obtained; and determining the test result of the interface test according to the test response result and the test log.
Specifically, after the interface test is completed, the test result needs to be analyzed, and a response test result obtained by the interface test and a test log generated in the interface test process can be obtained; and comparing the test response result with the test log to determine whether each field in the test response result has a problem or not, so as to obtain a test result.
Furthermore, after the test result of the interface test is determined according to the test response result and the test log, the test request data, the test response result and the test result can be stored in a preset database to be used as test data; judging whether the interface test passes or not according to the test result; if the interface test is passed, displaying a test result in a test interface, wherein the test interface is a program application interface for a tester to perform the interface test; if the interface test is failed, extracting data in the test data according to the test response result, determining the reason why the interface test fails, and displaying the test response result and the reason why the interface test fails in the test interface.
Specifically, after determining the test result of the interface test, the test request data, the test response result, and the test result in the interface test process are stored in the preset database in step S102 as the test data.
And judging whether the interface test passes or not according to the test result, wherein the interface test fails when a problem field exists in the test result. For example, the above example of obtaining the ID name of the user login in the system B is described, where the test response result is zhang, but the expected corresponding result in the test log is lie-four, at this time, a problem field exists in the test response result, and a problem field exists in the test result of the interface test, and the interface test fails.
And if the interface test is determined to pass according to the test result, displaying the test response result in the test page. And if the interface test is determined to fail according to the test result, extracting data in the test data according to the problem field in the test response result to obtain the reason why the interface test fails, and displaying the test response result and the reason why the test fails in the test interface.
In the embodiment of the present invention, the test failure reason may include key information in the test request data, the test response result, and the test result, and the user may determine the test failure reason according to the key information. For example, the key information may include at least key corresponding to the time of interface test, test request data, response result, and pass or fail of the test. Wherein, the key of the time and interface test can be expressed as: 2018_09_01_10_30_20_ native (native test), the meaning of the key of the time and interface test is that the field is used for performing the interface test with the native interface type at 10 o' clock 30 min 20 sec on 1 st n.2018, of course, the key of the time and interface test may include but is not limited to information such as time and interface type, and may also include transaction mode of the interface.
In the embodiment of the present invention, in the actual interface test process, the system a sends a test request instruction to the system B, and the system B responds to the test request instruction as an example for description. A web interface can be constructed by using computer languages such as html (HyperText Markup Language) or css (Cascading Style Sheets) and the like, and the web interface is used as the front end of the test platform. The user can select an interface test method and set corresponding configuration information in the web interface. Js, when the service monitors that an interface test event exists on the front-end web interface, the back-end service interacts with the front-end web interface to obtain configuration information in the front-end web interface, and stores the data information in a preset database to generate a configuration file.
If the user selects the real request test in the front-end web interface, the test platform acquires a program or data from the system B according to the test request data, loads the configuration information obtained at the back end into a cnf (configuration) file or a data file corresponding to the system A by calling a python script, and generates a corresponding data file. According to the configuration information in the data file, the initialization process of the system a is completed, and the test environment required for the real request test is obtained, for example, when the interface type is video, the interface type of the system a may be set to be the video type. And then in the test environment, the system A sends a test request instruction to the system B according to the URL address in the configuration information, and the system B responds to the test request data contained in the received test request instruction and feeds back a test response result to the system A to finish the real request test process.
If the user selects a response sample test in the front-end web interface, the test platform acquires a program or data from the system B according to the test request data, loads the environment configuration information in the configuration information acquired at the back end into a cnf file or a data file corresponding to the system A by calling a python script, and generates a corresponding data file; and loading the configuration information of the simulation server in the configuration information into a preset mock server, initializing the preset mock server, and simulating the system B by using the initialized mock server, wherein when the interface type is native, for example, the interface type of the pre-mock server can be set as native. And obtaining a test environment for responding to the sample test according to the initialized system A and the initialized preset mock sever. In the test environment, a system A sends a test request instruction to the mock server, the mock server responds to test request data in the received test request instruction and feeds back a test response result to the system A, and response sample test is completed.
After the interface response test is completed, the system A feeds back the test response result and the test log to the test platform. And the test platform compares the test log with the test response result according to the received test response result and the test log, determines a problem field in the test response result to obtain the test result, and stores the test response result, the test request data and the test result in a preset database. When the system B passes the interface test, the test response result is displayed in the front-end web interface, when the system B fails the interface test, the reason of the test failure is determined according to the test response result, the test request data, the test result and the like, and the reason of the test failure and the test response result are displayed in the front-end web interface.
In the embodiment of the present invention, all the systems a are real systems, such as an online service system or a third-party system. However, in the actual testing process, a simulation system can be configured according to the configuration information to realize the interface test with the system B or the initialized mock server.
As can be seen from the above, in the embodiment of the present invention, the preset database at least stores the configuration information, the test request data, the test response result, and the test result, so that the embodiment of the present invention can support a plurality of users to perform an interface test at the same time.
In summary, the embodiment provided by the invention can at least support the real request test and the response sample test; in the interface testing process, the configuration of the testing environment is completed by the system according to the configuration information without depending on manual configuration; meanwhile, after the interface test is finished, the data sorting and analysis are also automatically finished by the system, so that the human resources are greatly saved, and the interface test efficiency is improved. In addition, because the test data, the configuration information and the like can be stored in the preset database, the interference phenomenon among data when a plurality of people test at the same time can be effectively avoided, and the interface test efficiency can be further improved.
Based on the same inventive concept, according to the interface testing method provided in the above embodiment of the present invention, an embodiment of the present invention further provides an interface testing apparatus, as shown in fig. 2, which at least includes the following modules:
a configuration information determining module 201, configured to determine configuration information required for the interface test;
the test environment configuration module 202 is configured to initialize a preset test environment according to the configuration information to obtain a test environment for interface testing;
the interface test execution module 203 is configured to execute an interface test according to preset test request data in a test environment.
Further, the interface test is a real request test;
the test environment configuration module 202 is specifically configured to load configuration information into a preset test environment based on the preset test environment, and perform initialization processing on the preset test environment to obtain a test environment required by a real request test.
Further, the interface test is a response sample test;
the configuration information determining module 201 is specifically configured to determine environment configuration information and simulation server configuration information required for the interface test.
Further, the test environment configuration module 202 is specifically configured to load the environment configuration information into a preset test environment, perform initialization processing on the preset test environment, load the simulation server configuration information into a preset simulation service mock server, perform initialization processing on the preset mock server, and obtain a test environment required by the response sample test.
Further, the interface test execution module 203 is specifically configured to send preset test request data to the initialized preset mock server in the test environment; and after the initialized preset mock server receives the preset test request data, responding to the preset test request data.
Further, the above apparatus further comprises:
the test result determining module is used for obtaining the test response result of the interface test and the test log (log) of the interface test; and determining the test result of the interface test according to the test response result and the test log.
Further, the above apparatus further comprises:
the test data storage module is used for storing the test request data, the test response result and the test result in a preset database as test data;
the judging module is used for judging whether the interface test passes or not according to the test result; if the interface test is passed, displaying a test result in a test interface, wherein the test interface is a program application interface for a tester to perform the interface test; if the interface test is failed, extracting data in the test data according to the test response result, determining the reason why the interface test fails, and displaying the test response result and the reason why the interface test fails in the test interface.
The embodiment of the present invention further provides an electronic device, as shown in fig. 3, which includes a processor 301, a communication interface 302, a memory 303, and a communication bus 304, where the processor 301, the communication interface 302, and the memory 303 complete mutual communication through the communication bus 304,
a memory 303 for storing a computer program;
the processor 301, when executing the program stored in the memory 303, implements the following steps:
determining configuration information required for interface testing;
initializing a preset test environment according to the configuration information to obtain a test environment for interface testing;
and in the test environment, executing the interface test according to the preset test request data.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
In a further embodiment of the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any of the above-mentioned interface testing methods.
In a further embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform any of the interface testing methods of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for embodiments of devices, electronic devices, and the like, since they are substantially similar to the method embodiments, the description is relatively simple, and reference may be made to some descriptions of the method embodiments for relevant points.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (11)

1. An interface testing method, comprising:
determining configuration information required for an interface test, the interface test being a response sample test,
the determining configuration information required for the interface test includes:
determining environment configuration information and simulation server configuration information required by interface testing; the environment configuration information is the configuration information of a test environment required by response sample test, and the simulation server configuration information is the configuration information of a simulation server used for receiving and responding to a data request instruction;
initializing a preset test environment according to the configuration information to obtain a test environment for the interface test;
and executing the interface test according to preset test request data in the test environment.
2. The method according to claim 1, wherein initializing a preset test environment according to the configuration information to obtain a test environment for the interface test comprises:
and loading the environment configuration information into a preset test environment, initializing the preset test environment, loading the configuration information of the simulation server into a preset simulation service mock server, and initializing the preset mock server to obtain the test environment required by the response sample test.
3. The method of claim 2, wherein the performing the interface test according to the preset test request data in the test environment comprises:
in the test environment, sending preset test request data to the initialized preset mock server;
and after the initialized preset mock server receives the preset test request data, responding to the preset test request data.
4. The method of claim 1, wherein after executing the interface test according to preset test request data in the test environment, the method further comprises:
obtaining a test response result of the interface test and a test log of the interface test;
and determining the test result of the interface test according to the test response result and the test log.
5. The method of claim 4, further comprising, after said determining a test result of said interface test based on said test response result and said test log:
storing the test request data, the test response result and the test result in a preset database as test data;
judging whether the interface test passes or not according to the test result;
if the interface test is passed, displaying the test result in a test interface, wherein the test interface is a program application interface for a tester to perform the interface test;
if the interface test is failed, extracting data in the test data according to the test response result, determining the reason why the interface test fails, and displaying the test response result and the reason why the interface test fails in the test interface.
6. An interface testing apparatus, comprising:
a configuration information determining module, configured to determine configuration information required for an interface test, where the interface test is a response sample test, and the determining the configuration information required for the interface test includes:
determining environment configuration information and simulation server configuration information required by interface testing; the environment configuration information is the configuration information of a test environment required by response sample test, and the simulation server configuration information is the configuration information of a simulation server used for receiving and responding to a data request instruction;
the test environment configuration module is used for initializing a preset test environment according to the configuration information to obtain a test environment for the interface test;
and the interface test execution module is used for executing the interface test according to preset test request data in the test environment.
7. The apparatus according to claim 6, wherein the test environment configuration module is specifically configured to load the environment configuration information into a preset test environment, perform initialization processing on the preset test environment, load the simulation server configuration information into a preset simulation service mock server, and perform initialization processing on the preset mock server to obtain the test environment required by the response sample test.
8. The apparatus according to claim 7, wherein the interface test execution module is specifically configured to send, in the test environment, preset test request data to the initialized preset mock server; and after the initialized preset mock server receives the preset test request data, responding to the preset test request data.
9. The apparatus of claim 6, further comprising:
the test result determining module is used for obtaining a test response result of the interface test and a test log of the interface test; and determining the test result of the interface test according to the test response result and the test log.
10. The apparatus of claim 9, further comprising:
the test data storage module is used for storing the test request data, the test response result and the test result in a preset database as test data;
the judging module is used for judging whether the interface test passes or not according to the test result; if the interface test is passed, displaying the test result in a test interface, wherein the test interface is a program application interface for a tester to perform the interface test; if the interface test is failed, extracting data in the test data according to the test response result, determining the reason why the interface test fails, and displaying the test response result and the reason why the interface test fails in the test interface.
11. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.
CN201811158041.8A 2018-09-30 2018-09-30 Interface testing method and device Active CN109446075B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811158041.8A CN109446075B (en) 2018-09-30 2018-09-30 Interface testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811158041.8A CN109446075B (en) 2018-09-30 2018-09-30 Interface testing method and device

Publications (2)

Publication Number Publication Date
CN109446075A CN109446075A (en) 2019-03-08
CN109446075B true CN109446075B (en) 2022-02-25

Family

ID=65544892

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811158041.8A Active CN109446075B (en) 2018-09-30 2018-09-30 Interface testing method and device

Country Status (1)

Country Link
CN (1) CN109446075B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110096395A (en) * 2019-03-12 2019-08-06 深圳壹账通智能科技有限公司 Interface joint debugging test method, device, computer equipment and storage medium
CN110191013A (en) * 2019-04-19 2019-08-30 深圳壹账通智能科技有限公司 Electronic device, the Mock test method of more capital's interfaces and storage medium
CN111190811A (en) * 2019-12-05 2020-05-22 东方微银科技(北京)有限公司 Method, device, equipment and storage medium for testing resource allocation system
CN111198821B (en) * 2020-01-06 2021-07-16 瑞庭网络技术(上海)有限公司 Interface abnormity judgment method and device and readable storage medium
CN112699027A (en) * 2020-12-29 2021-04-23 平安银行股份有限公司 Interface testing method, device, equipment and readable storage medium
CN113392026B (en) * 2021-07-07 2023-12-19 北京智慧星光信息技术有限公司 Interface automatic test method, system, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107748717A (en) * 2017-09-26 2018-03-02 深圳市牛鼎丰科技有限公司 Automatic interface testing method, device, storage medium and computer equipment
CN107797919A (en) * 2017-07-24 2018-03-13 平安普惠企业管理有限公司 The method and computing device of a kind of automatic test
CN108415847A (en) * 2018-05-08 2018-08-17 平安普惠企业管理有限公司 Performance test methods, device, computer equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107797919A (en) * 2017-07-24 2018-03-13 平安普惠企业管理有限公司 The method and computing device of a kind of automatic test
CN107748717A (en) * 2017-09-26 2018-03-02 深圳市牛鼎丰科技有限公司 Automatic interface testing method, device, storage medium and computer equipment
CN108415847A (en) * 2018-05-08 2018-08-17 平安普惠企业管理有限公司 Performance test methods, device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN109446075A (en) 2019-03-08

Similar Documents

Publication Publication Date Title
CN109446075B (en) Interface testing method and device
EP3842948B1 (en) Method and apparatus for testing edge computing, device, and readable storage medium
US8745641B1 (en) Automatic verification and anomaly detection in a representational state transfer (REST) application programming interface
CN110825618B (en) Method and related device for generating test case
CN110798380B (en) Data acquisition method, system, device, test equipment and test server
CN109840192B (en) Method and device for automatic testing
CN105099811A (en) Interface testing method and device
WO2018184361A1 (en) Application test method, server, terminal, and storage media
CN110955409B (en) Method and device for creating resources on cloud platform
CN112199300A (en) Interface testing method and device, electronic equipment and storage medium
CN104753909A (en) Updated information authentication method, device and system
CN108229980B (en) Question feedback method and device and storage medium
CN111367531A (en) Code processing method and device
CN110609786A (en) Software testing method and device, computer equipment and storage medium
CN115292187A (en) Method and device for automatically testing code-free page, electronic equipment and medium
CN114693116A (en) Method and device for detecting code review validity and electronic equipment
CN111400623B (en) Method and device for searching information
CN109902004B (en) Method and device for testing application program link channel
CN106202319B (en) Abnormal URL (Uniform resource locator) verification method and system
CN111159988A (en) Model processing method and device, computer equipment and storage medium
JP7320211B1 (en) Systems, methods and programs for testing website vulnerabilities
JP7344614B1 (en) Systems, methods, and programs for testing website vulnerabilities
CN115145464B (en) Page testing method and device, electronic equipment and storage medium
CN113190779B (en) Webpage evaluation method and device
CN116257432A (en) Service system testing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant