Interface testing method and related device

Through interface testing methods and devices, the interface testing is automatically acquired and executed using pre-configured configuration files, and the existing test efficiency is solved, achieving more efficient test coverage and continuous integration delivery requirements.

CN118964182APending Publication Date: 2024-11-15永赢金融租赁有限公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410972773.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

Existing testing methods are inefficient, difficult to meet the needs of continuous integration and continuous delivery, and are prone to omissions.

Method used

Provide an interface testing method and device, which can obtain interface use cases and obtain target parameters from pre-configured configuration files by responding to interface test requests, perform interface testing to obtain test results, and realize automated testing.

Benefits of technology

Improves testing efficiency, ensures the expansion and accuracy of test coverage, and meets the needs of continuous integration and continuous delivery.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118964182A_ABST
    Figure CN118964182A_ABST
Patent Text Reader

Abstract

The invention discloses an interface test method and a related device, in response to an interface test request, an interface case corresponding to the interface test request is obtained, a target parameter corresponding to the interface case is obtained from a pre-configured configuration file, and the target parameter can refer to data corresponding to the interface case and required when an interface test is executed. Then interface testing can be executed according to the target parameters, a testing result is obtained, and the testing result is used for indicating the execution result of the interface testing. Wherein the configuration file comprises the use case parameters corresponding to the interface test, and the configuration file is pre-configured, so that when the interface test needs to be carried out, the required data can be obtained from the configuration file, and the test efficiency can be improved. Meanwhile, once a new test exists, the corresponding data can be pre-configured into the configuration file in a mode of configuring the configuration file, and then the automatic test is realized in a mode of obtaining the data from the configuration file, so that the test efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to an interface testing method and related devices. Background Art

[0002] As the business volume increases, the software functions become more and more complex, which requires a large number of test cases to be executed in daily iterative development to ensure the normal operation of the functions.

[0003] However, currently, most commonly used tests (such as regression tests) rely on manual execution of test cases, which is inefficient, time-consuming and labor-intensive, and has limited coverage, which is prone to omissions. In addition, manual execution of tests cannot meet the requirements of continuous integration and continuous delivery, and has low test efficiency.

[0004] It can be seen that how to improve testing efficiency is of great significance. Summary of the invention

[0005] In order to solve the above technical problems, the present application provides an interface testing method and related devices, which are conducive to improving testing efficiency.

[0006] The embodiments of the present application disclose the following technical solutions:

[0007] On the one hand, an embodiment of the present application provides an interface testing method, the method comprising:

[0008] In response to an interface test request, obtaining an interface use case corresponding to the interface test request;

[0009] Obtaining target parameters corresponding to the interface use case from a pre-configured configuration file, wherein the configuration file includes use case parameters corresponding to the interface test;

[0010] An interface test is performed according to the target parameters to obtain a test result.

[0011] On the other hand, an embodiment of the present application provides an interface testing device, the device comprising a first acquisition unit, a second acquisition unit and an execution unit:

[0012] The first acquisition unit is used to respond to the interface test request and acquire the interface use case corresponding to the interface test request;

[0013] The second acquisition unit is used to acquire the target parameters corresponding to the interface use case from a pre-configured configuration file, wherein the configuration file includes the use case parameters corresponding to the interface test;

[0014] The testing unit is used to perform interface testing according to the target parameters to obtain test results.

[0015] In another aspect, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory:

[0016] The memory is used to store program code and transmit the program code to the processor;

[0017] The processor is used to execute the interface testing method described in the above aspects according to the instructions in the program code.

[0018] On the other hand, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the interface testing method described in the above aspects.

[0019] On the other hand, an embodiment of the present application provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the interface testing method described in the above aspects.

[0020] It can be seen from the above technical solution that in response to the interface test request, the interface use case corresponding to the interface test request can be obtained first. Then, the target parameters corresponding to the interface use case can be obtained from the pre-configured configuration file, and the target parameters can refer to the data required when executing the interface test corresponding to the interface use case. Finally, the interface test can be performed according to the target parameters to obtain the test results, and the test results can be used to indicate the execution results of this interface test. Among them, the configuration file includes the use case parameters corresponding to the interface test, and the configuration file is pre-configured, so when the interface test is required, the required data can be obtained from the configuration file, which is conducive to improving the test efficiency. At the same time, once there is a new test, the corresponding data can be pre-configured into the configuration file by configuring the configuration file, and then the automated test can be realized by obtaining it from the configuration file, thereby improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 A flowchart of an interface testing method provided in an embodiment of the present application;

[0023] Figure 2 A schematic diagram of a system architecture for interface testing provided in an embodiment of the present application;

[0024] Figure 3 A structural diagram of an interface testing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0026] The interface testing method provided in the embodiment of the present application can be implemented by a computer device, which can be a terminal device or a server, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Terminal devices include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, etc. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions on this.

[0027] The specific examples are as follows:

[0028] Figure 1 A flowchart of an interface testing method provided in an embodiment of the present application is provided, and a server is used as the aforementioned computer device for illustration. The method includes S101-S103:

[0029] S101: In response to an interface test request, obtain an interface use case corresponding to the interface test request.

[0030] When an interface test is required, an interface test request can be triggered to trigger an automatic test process. It should be noted that this application does not impose any restrictions on the triggering mechanism of the interface test request. For example, it can be a tester manually executing to initiate an interface test request. For another example, it can be a task set for scheduled execution, and when the set conditions for scheduled execution are met, an interface test request is automatically initiated. For another example, a certain strategy can be preset (such as when a software function is updated, etc.), and then it can be executed according to the strategy to initiate an interface test request. Specifically, it can be flexibly selected according to the actual situation.

[0031] Correspondingly, in response to the interface test request, the interface use case corresponding to the interface test request may be first obtained, and the interface use case may be used to indicate which interface is tested in this test, and the like.

[0032] S102: Obtain target parameters corresponding to the interface use case from a pre-configured configuration file.

[0033] Among them, the configuration file can be pre-configured, and the configuration file can include use case parameters corresponding to the interface test. The use case parameters can refer to the relevant data required when performing the interface test. For the aforementioned interface test request, the target parameters corresponding to the interface use case can be obtained from the pre-configured configuration file. The target parameters can refer to the data required when executing the interface test corresponding to the interface use case. In this way, when the interface test is required, the required data can be obtained from the configuration file. Based on this, there is no need to rely on manual writing one by one according to the test format, etc., which is conducive to improving the test efficiency.

[0034] It is understandable that interface testing usually requires multiple tests, or the execution of multiple use cases, etc. Therefore, through the configuration file, all the test-related data that need to be executed can be pre-configured, which is more flexible. In one possible implementation method, in response to a dynamic configuration request, the use case parameters to be executed corresponding to the dynamic configuration request can be obtained. The use case parameters to be executed can refer to the required data corresponding to the interface test that needs to be executed later. Then, the use case parameters stored in the configuration file can be updated according to the use case parameters to be executed. For example, the use case parameters to be executed can be directly configured into the configuration file. For example, if the dynamic configuration this time is to modify certain data to complete the configuration, the use case parameters to be executed can be used to replace and overwrite those use case parameters that need to be modified.

[0035] In addition to the use case parameters, the configuration file may also be configured with global parameters corresponding to the interface test. Exemplarily, in one possible implementation, the configuration file may be configured with a global token, and in subsequent interface tests, the global token may be used for identity verification, legality verification, etc., to ensure test security.

[0036] During specific implementation, on the one hand, in response to an interface test request, the token parameters carried by the interface test request can be obtained, and the login status of the test account corresponding to the interface test request can be detected based on the token parameters, and whether the user has the authority to perform the test can be determined based on the detection of the login status. If the login status is logged in, it means that the test can be performed. At the same time, in order to ensure that the test initiated this time is a legal test, the token parameters can also be matched with the global token in the configuration file to detect the legality. Accordingly, during the specific implementation of the aforementioned S102, if the detection determines that the login status is logged in and the token parameters are consistent with the global token in the configuration file, the target parameters corresponding to the interface use case are obtained from the configuration file. Based on this, identity verification and legality verification are performed through the detection of the login status and the matching with the global token to ensure the security of the test.

[0037] Correspondingly, if the detection determines that the login status is not logged in, you can log in first. In a possible implementation, the login case is first executed to obtain the token parameters and globally configure them to complete the login.

[0038] S103: Execute interface test according to target parameters to obtain test results.

[0039] Finally, the interface test can be executed according to the target parameters, and correspondingly, a test result can be obtained, which can be used to represent the execution result of the interface test.

[0040] It should be noted that this application does not make any limitation on how to perform the interface test according to the target parameters to obtain the test results. For ease of understanding, the embodiments of this application provide the following methods as examples:

[0041] In actual applications, different interfaces are usually used to implement different functions, so the corresponding interface request methods may be different. Therefore, in a possible implementation, the interface test can be performed according to the interface request method of the interface call to ensure the correct execution of the interface test and improve the test efficiency.

[0042] In specific implementation, if the interface use case indicates to call the target interface, that is, the target interface needs to be called in this interface test, the interface request method corresponding to the target interface can be obtained. Then, the interface test is performed according to the target parameters using the interface request method corresponding to the target interface to obtain the test result. Based on this, the interface test is performed using the interface request method corresponding to the current call interface, which is conducive to ensuring the correct execution of the interface test, and this is also conducive to improving the test efficiency.

[0043] Exemplarily, the interface request mode may be a POST request, a GET request, etc. Different interface request modes may be used to implement different functions. For example, the purpose of a GET request is to obtain resources, and it is usually used for query operations, etc.

[0044] In addition, the formats of the input data corresponding to different interfaces may be different. Therefore, in another possible implementation method, the interface test can also be performed according to the input data format of the interface called this time to ensure that the target parameters can be correctly processed during the interface test process, thereby improving the test efficiency.

[0045] During specific implementation, if the interface use case indicates to call the target interface, that is, the target interface needs to be called for this interface test, the input parameter data format corresponding to the target interface can be obtained. Then, according to the input parameter data format corresponding to the target interface, the data format of the target parameters can be converted to obtain the converted target parameters, and the data format of the converted target parameters matches the input parameter data format of the target interface. Finally, the interface test can be performed according to the converted target parameters to obtain the test results. Based on this, through data format conversion, it is ensured that the format of the data that needs to be processed when executing the interface test (that is, the input parameter data of the target interface) is that the target interface can handle it, so as to ensure the correct execution of the interface test, which is also conducive to improving the test efficiency.

[0046] After obtaining the test results, in order to be able to more intuitively display the situation of this test, in a possible implementation method, assertion analysis can also be performed on the test results. In specific implementation, the expected results corresponding to the interface use case are obtained, and the expected results can be used as a reference for the execution results corresponding to this interface test. Then, the test results can be matched with the expected results to obtain the assertion analysis results corresponding to the test results. The assertion analysis results can be used to indicate the matching situation, and based on the matching situation, reflect whether the test meets expectations, locate places that do not meet expectations, etc. Therefore, based on the assertion analysis results, the situation of this test can be more intuitively displayed.

[0047] It can be understood that since the data required for interface testing (i.e. the aforementioned target parameters) are configured in the configuration file, when obtaining the expected results corresponding to the interface use case, the corresponding expected results can be determined based on the target parameters to ensure that the expected results obtained are the expected results corresponding to this interface test, thereby improving the accuracy of assertion analysis.

[0048] In actual applications, you can add assertion rules and implement the steps of matching the test results with the expected results based on the assertion rules to obtain the corresponding assertion analysis results. Usually, if the assertion analysis result is true, it means that the test is normal and you can continue to execute subsequent cases, that is, continue the subsequent interface test. If the assertion analysis result is false, it means that there is an exception in the test. At this time, you can throw an exception so that testers can check and locate the problem of the exception in time. Of course, whether it is true or false, you can call the log to record the test situation and print relevant information so that you can trace the specific test situation by querying the log later.

[0049] It can be seen from the above technical solution that in response to the interface test request, the interface use case corresponding to the interface test request can be obtained first. Then, the target parameters corresponding to the interface use case can be obtained from the pre-configured configuration file, and the target parameters can refer to the data required when executing the interface test corresponding to the interface use case. Finally, the interface test can be performed according to the target parameters to obtain the test results, and the test results can be used to indicate the execution results of this interface test. Among them, the configuration file includes the use case parameters corresponding to the interface test, and the configuration file is pre-configured, so when the interface test is required, the required data can be obtained from the configuration file, which is conducive to improving the test efficiency. At the same time, once there is a new test, the corresponding data can be pre-configured into the configuration file by configuring the configuration file, and then the automated test can be realized by obtaining it from the configuration file, thereby improving the test efficiency.

[0050] In practical applications, the interface testing method provided in this application can be deployed and implemented based on the Karate automated testing framework. Figure 2 The schematic diagram of the system architecture of an interface test shown may include:

[0051] The Application Programming Interface (API) library, namely the API library, is used to manage various interfaces.

[0052] The interface case encapsulation module is used for interface encapsulation. For example, the use case name, use case meaning, etc. can be encapsulated according to the request message format requirements, etc., so as to perform interface testing later. The expected result can refer to the pre-defined execution result reference corresponding to each use case parameter, which is used to perform assertion analysis on the test result. In practical applications, the steps of the interface case encapsulation module may include: obtaining the corresponding interface information from the interface library, defining the interface request method of the interface, parameterizing and encapsulating the request header parameters and request body parameters of the back-end interface with behavior-driven development (BDD) syntax, pre-defining the default values ​​of the parameters with default values, and adding assertion rules for the test results of the test case. Based on this, using BDD syntax that is more in line with human natural language to write test cases is conducive to simplifying the code architecture and making it easier to write and understand.

[0053] The test data configuration module is used to configure the aforementioned configuration file. Among them, the global parameters can be, for example, the aforementioned global token. Usually, interface testing may also involve linkage with other databases, so in the test data configuration module, database configuration can also be performed, such as configuring database address and other information. In actual applications, the relevant configuration steps can be implemented through the config.js file. For example, the address can be configured. Correspondingly, the aforementioned S102 can be implemented by reading the data in the config.js file. In actual applications, the configuration file can be configured in the form of key-value pairs. For example, the key can represent the request parameter (such as the name of the request parameter, etc.), and the value can refer to the value of the dynamically configured use case parameter to be executed. Based on this, the parameterized configuration capability of the data is expanded by means of data dictionaries and the like.

[0054] The data preprocessing module is used to preprocess the data. For example, it can be the aforementioned data format conversion of the target parameters, which is usually associated with the business process. In this way, the data can be preprocessed according to the relevant format requirements of the target interface corresponding to the current test. In practical applications, the test data preprocessing script can be written in JavaScript to preprocess the data to meet the parameterized configuration requirements, and the database query, case custom execution method and other scripts can be written in Java to meet the needs of custom execution requirements for different cases according to different test plans.

[0055] The test case execution module is used to trigger the interface test request. For example, it can include the aforementioned manual execution, scheduled execution, and policy-based execution and other different triggering mechanisms. In practical applications, the test case execution module can be implemented by running the testRunner.java file, and its execution steps may include: printing the test case start execution information, defining the test report output directory and number, and judging whether the test case directory exists. If it exists, execute the corresponding case according to the predefined label or directly execute all cases in the directory. If it does not exist, it ends. During execution, it can be judged whether the test case receives the customized parameters. If it does, it will be passed into the corresponding parameter configuration entry of the interface case, otherwise the predefined default parameters will be used directly. In addition, the test case is executed in the specified operating mode and environment according to the test plan. After all cases are executed, print and save the information output by all test cases and generate a test report, save it in the corresponding directory, and finally, end the execution.

[0056] The test plan module is used to create test plans, associate scenario use cases, and edit report templates.

[0057] The report generation module is used to generate test results and result access. For example, the test results can be managed directly, and assertion analysis can be performed to generate assertion analysis results and manage assertion analysis results, etc. Of course, test reports can also be printed based on log records, etc., and test reports can be managed, etc. In actual applications, the format of the test results can be defined, including the test report name, generation time, case return results, assertion analysis results, etc., and the path for saving the test report can be set. All use case lists can be traversed. If the traversal is completed, the test report is output according to the pre-defined test report format and saved in the corresponding directory. Otherwise, the execution results of the test cases obtained by the traversal are obtained, and the time function is called to obtain the total execution time. Finally, the results of the current use case execution and the rest of the information can be saved in the test report. Based on this, by introducing the test report generation process, the test report includes richer information, which improves the content richness of the test report, and is conducive to developers to eliminate bugs, etc.

[0058] In addition, a log generation module can also be included to record the execution results of test cases. And a continuous integration module can better meet the needs of software functions for continuous integration and continuous delivery. In actual applications, a jenkins server can be installed, and a network complete protocol (Secure Shell, SSH) can be used to remotely connect to the test server, and a continuous integration test script can be built to define execution rules and error handling methods. When the development code is updated, the code is automatically pulled and the test case is executed, the test report is output, and the corresponding personnel are notified (such as email notification, etc.). Based on this, the data processing capability is expanded by using script code and other methods, which is conducive to improving test efficiency.

[0059] It can be understood that it basically corresponds to the method embodiment, so the relevant parts can refer to the partial description of the method embodiment.

[0060] Figure 3 This is a structural diagram of an interface testing device provided in an embodiment of the present application, wherein the device includes a first acquisition unit 301, a second acquisition unit 302, and an execution unit 303:

[0061] The first acquisition unit 301 is used to respond to an interface test request and acquire an interface use case corresponding to the interface test request;

[0062] The second acquisition unit 302 is used to acquire the target parameters corresponding to the interface use case from a pre-configured configuration file, wherein the configuration file includes the use case parameters corresponding to the interface test;

[0063] The testing unit 303 is used to perform interface testing according to the target parameters to obtain test results.

[0064] In a possible implementation, the testing unit is further used for:

[0065] If the interface use case indicates calling a target interface, obtaining an interface request method corresponding to the target interface;

[0066] An interface test is performed in an interface request mode corresponding to the target interface according to the target parameters to obtain the test result.

[0067] In a possible implementation manner, the first acquiring unit is further configured to:

[0068] In response to the interface test request, obtaining a token parameter carried by the interface test request;

[0069] Detecting the login status of the test account corresponding to the interface test request according to the token parameters;

[0070] The second acquisition unit is further configured to acquire the target parameter corresponding to the interface use case from the configuration file if it is detected that the login state is login and the token parameter is consistent with the global token in the configuration file.

[0071] In a possible implementation manner, the apparatus further includes a third acquisition unit, and the third acquisition unit is configured to:

[0072] Obtain the expected result corresponding to the interface use case;

[0073] The test result is matched with the expected result to obtain an assertion analysis result corresponding to the test result.

[0074] In a possible implementation, the testing unit is further used for:

[0075] If the interface use case indicates calling a target interface, obtaining the input parameter data format corresponding to the target interface;

[0076] According to the input parameter data format corresponding to the target interface, the target parameter is converted into a data format to obtain a converted target parameter, wherein the data format of the converted target parameter matches the input parameter data format of the target interface;

[0077] An interface test is performed according to the converted target parameters to obtain the test result.

[0078] In a possible implementation manner, the apparatus further includes a fourth acquiring unit, and the fourth acquiring unit is configured to:

[0079] In response to a dynamic configuration request, obtaining parameters of a use case to be executed corresponding to the dynamic configuration request;

[0080] The use case parameters stored in the configuration file are updated according to the use case parameters to be executed.

[0081] It can be seen from the above technical solution that in response to the interface test request, the interface use case corresponding to the interface test request can be obtained first. Then, the target parameters corresponding to the interface use case can be obtained from the pre-configured configuration file, and the target parameters can refer to the data required when executing the interface test corresponding to the interface use case. Finally, the interface test can be performed according to the target parameters to obtain the test results, and the test results can be used to indicate the execution results of this interface test. Among them, the configuration file includes the use case parameters corresponding to the interface test, and the configuration file is pre-configured, so when the interface test is required, the required data can be obtained from the configuration file, which is conducive to improving the test efficiency. At the same time, once there is a new test, the corresponding data can be pre-configured into the configuration file by configuring the configuration file, and then the automated test can be realized by obtaining it from the configuration file, thereby improving the test efficiency.

[0082] In another aspect, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory:

[0083] The memory is used to store program code and transmit the program code to the processor;

[0084] The processor is used to execute the interface testing method provided in the above embodiment according to the instructions in the program code.

[0085] The computer device may include a terminal device or a server, and the aforementioned interface testing apparatus may be configured in the computer device.

[0086] On the other hand, an embodiment of the present application further provides a storage medium, wherein the storage medium is used to store a computer program, and the computer program is used to execute the interface testing method provided in the above embodiment.

[0087] In addition, an embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the interface testing method provided in the above embodiment.

[0088] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium can be at least one of the following media: read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc., various media that can store program codes.

[0089] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.

[0090] It should be noted that, in this article, relational terms such as "first" and "second", etc. (if any) are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0091] The above is a detailed introduction to an interface testing method and related devices provided by the embodiment of the present application. The principle and implementation method of the present application are described in detail using specific examples. The description of the above embodiments is only used to help understand the method of the present application. At the same time, for those skilled in the art, according to the method of the present application, there will be changes in the specific implementation method and application scope.

[0092] In summary, the content of this specification should not be understood as limiting the present application, and any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in this application should be included in the protection scope of this application. Moreover, based on the implementations provided in the above aspects, this application can also be further combined to provide more implementations.

Claims

1. An interface testing method, characterized in that: The method comprises: In response to an interface test request, obtaining an interface use case corresponding to the interface test request; Obtaining target parameters corresponding to the interface use case from a pre-configured configuration file, wherein the configuration file includes use case parameters corresponding to the interface test; An interface test is performed according to the target parameters to obtain a test result.

2. The method according to claim 1, characterized in that The performing of the interface test according to the target parameter to obtain the test result includes: If the interface use case indicates calling a target interface, obtaining an interface request method corresponding to the target interface; An interface test is performed in an interface request mode corresponding to the target interface according to the target parameters to obtain the test result.

3. The method according to claim 1, characterized in that: The method further comprises: In response to the interface test request, obtaining a token parameter carried by the interface test request; Detecting the login status of the test account corresponding to the interface test request according to the token parameters; The obtaining target parameters corresponding to the interface use case from a pre-configured configuration file includes: If the detection determines that the login state is login and the token parameter is consistent with the global token in the configuration file, the target parameter corresponding to the interface use case is obtained from the configuration file.

4. The method according to claim 1, characterized in that The method further comprises: Obtain the expected result corresponding to the interface use case; The test result is matched with the expected result to obtain an assertion analysis result corresponding to the test result.

5. The method according to claim 1, characterized in that The performing of the interface test according to the target parameter to obtain the test result includes: If the interface use case indicates calling a target interface, obtaining the input parameter data format corresponding to the target interface; According to the input parameter data format corresponding to the target interface, the target parameter is converted into a data format to obtain a converted target parameter, wherein the data format of the converted target parameter matches the input parameter data format of the target interface; An interface test is performed according to the converted target parameters to obtain the test result.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: In response to a dynamic configuration request, obtaining parameters of a use case to be executed corresponding to the dynamic configuration request; The use case parameters stored in the configuration file are updated according to the use case parameters to be executed.

7. An interface testing device, characterized in that: The device comprises a first acquisition unit, a second acquisition unit and an execution unit: The first acquisition unit is used to respond to the interface test request and acquire the interface use case corresponding to the interface test request; The second acquisition unit is used to acquire the target parameters corresponding to the interface use case from a pre-configured configuration file, wherein the configuration file includes the use case parameters corresponding to the interface test; The testing unit is used to perform interface testing according to the target parameters to obtain test results.

8. A computer device, characterized in that: The computer device comprises a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the method according to any one of claims 1 to 6 according to the instructions in the program code.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 6.

10. A computer program product comprising instructions, which, when executed on a computer, causes the computer to execute the method according to any one of claims 1 to 6.

Citation Information

Cited By

  • Single-code multi-platform compiling method and device

    CN119718335A