Interface testing method, device, equipment and storage medium
By building standardized interface testing templates and automated testing tools, the problems of inefficient and insufficient coverage of traditional interface testing methods are solved, efficient and accurate interface testing is achieved, and software updates and iterative needs are adapted to ensure the quality and stability of business data integration. .
Patent Information
- Application Number
- CN202411274316.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-09-12
AI Technical Summary
Traditional interface testing methods are inefficient and insufficient test coverage, making it difficult to meet the high requirements of modern enterprises for business data integration quality. Especially when software updates and iterations are frequent, it is difficult to complete a large number of regression tests in a short time, and manual testing efficiency is Low and error-prone, unable to adapt to changes in testing requirements.
By building a standardized interface test template, test cases for multiple business scenarios are generated based on business needs and interface specifications, combined with automated testing tools to automate the interface test process, configure test strategies to execute and analyze test cases, generate test results and report adjustments , to improve testing efficiency and accuracy.
It realizes efficient and accurate interface testing, reduces error rate, improves test coverage, is highly adaptable, and can quickly respond to demand changes in software updates and iterations, ensuring the quality and stability of business data integration.
Smart Images

Figure CN118820114B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of interface testing, and in particular to an interface testing method, device, equipment and storage medium. Background Art
[0002] With the rapid development of information technology, various types of business data are becoming increasingly large, and business data integration is an important part of enterprise informatization construction. As a key link to ensure the quality of business data integration, interface testing is of self-evident importance. However, traditional interface testing methods often have problems such as low efficiency and insufficient test coverage, which are difficult to meet the high requirements of modern enterprises for business data integration quality. Specifically, on the one hand, software updates and iterations are frequent, and based on the update method of existing test cases, it is difficult to complete a large number of regression tests of the software in a short period of time; on the other hand, most of the existing test scenario templates are fixed, and there is a problem that they cannot meet the test scenario requirements. Summary of the invention
[0003] In order to solve the above technical problems, the embodiments of the present disclosure provide an interface testing method, apparatus, device and storage medium.
[0004] In a first aspect, an embodiment of the present disclosure provides an interface testing method, including:
[0005] Build standardized interface test templates covering various business scenarios based on business requirements and interface specifications;
[0006] Obtaining a test request for a target interface, wherein the test request includes scenario requirements and business data;
[0007] Generate multiple test cases that meet the business logic corresponding to the target scenario according to the business data and the standardized interface test template, wherein the target scenario refers to a business scenario that meets the scenario requirements among the multiple business scenarios;
[0008] The target interface is tested based on the multiple test cases to generate a test result.
[0009] Optionally, the standardized interface test template containing multiple business scenarios is constructed according to business requirements and interface specifications, including:
[0010] Building a test scenario library according to business requirements and interface specifications, wherein the test scenario library includes multiple business scenarios, each of which has business logic and test data;
[0011] According to the business logic and data specifications, define the structure and generation rules of the test data to obtain a test data model;
[0012] According to the business logic, a corresponding test logic template is set for each business scenario;
[0013] The standardized interface test template includes the test scenario library, the test data model and the test logic template.
[0014] Optionally, generating a plurality of test cases that conform to the business logic corresponding to the target scenario according to the business data and the standardized interface test template includes:
[0015] Determine a target scenario that meets the scenario requirements among the multiple business scenarios;
[0016] Based on the test scenario library, the test data model and the test logic template, multiple test cases that conform to the business logic corresponding to the target scenario are generated.
[0017] Optionally, when there is no target scenario that meets the scenario requirement among the multiple business scenarios, determining the target scenario that meets the scenario requirement among the multiple business scenarios includes:
[0018] Determine an initial scenario that meets at least part of the scenario requirements from among the multiple business scenarios, adjust the initial scenario, and determine the adjusted initial scenario as the target scenario; or,
[0019] In the case that the initial scenario does not exist in the multiple business scenarios, a new business scenario is added according to the scenario requirements, and the new business scenario is determined as the target scenario.
[0020] Optionally, the testing the target interface based on the multiple test cases to generate a test result includes:
[0021] Configuring a test strategy for the multiple test cases, the test strategy comprising a test execution strategy and a test frequency strategy, wherein the test execution strategy represents the execution order of the multiple test cases, and the test frequency strategy represents the execution timing of the multiple test cases;
[0022] The multiple test cases are executed according to the test strategy, the test for the target interface is completed, and the test result is generated.
[0023] Optionally, the test execution strategy includes at least one of sequential execution, parallel execution and conditional execution, wherein the sequential execution refers to executing the test cases one by one in the order of precedence, the parallel execution refers to executing multiple test cases at the same time, and the conditional execution refers to determining the next test case to be executed according to the test result of the previous test case;
[0024] The test frequency strategy includes scheduled execution, event-triggered execution and on-demand execution, wherein the scheduled execution refers to using a scheduled task scheduler to determine the execution time of a test case, the event-triggered execution refers to determining the trigger time of a preset event as the execution time of the test case, and the on-demand execution refers to responding to a start operation of a test interface that displays the test case and executing the test case corresponding to the start operation.
[0025] Optionally, after testing the target interface based on the multiple test cases and generating test results, the method further includes:
[0026] Analyze and process the test results to generate a test report;
[0027] Adjusting the standardized interface test template and / or the business data based on the test report to obtain a plurality of updated test cases;
[0028] The updated multiple test cases are executed, and an automated testing tool is called to interact with the target interface to generate test results.
[0029] In a second aspect, an embodiment of the present disclosure provides an interface testing device, including:
[0030] The construction unit is used to build a standardized interface test template containing multiple business scenarios according to business requirements and interface specifications;
[0031] An acquisition unit, configured to acquire a test request for a target interface, wherein the test request includes scenario requirements and business data;
[0032] A test case generation unit, configured to generate a plurality of test cases that conform to the business logic corresponding to a target scenario according to the business data and the standardized interface test template, wherein the target scenario refers to a business scenario that meets the scenario requirements among the multiple business scenarios;
[0033] A test result generating unit is used to test the target interface based on the multiple test cases and generate a test result.
[0034] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0035] Memory;
[0036] Processor; and
[0037] Computer programs;
[0038] The computer program is stored in the memory and is configured to be executed by the processor to implement the interface testing method as described above.
[0039] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above-mentioned interface testing method when executed by a processor.
[0040] The interface testing method provided by the present disclosure includes: constructing a standardized interface testing template including multiple business scenarios according to business requirements and interface specifications; obtaining a test request for a target interface, wherein the test request includes scenario requirements and business data; generating multiple test cases that meet the business logic corresponding to the target scenario according to the business data and the standardized interface testing template, wherein the target scenario refers to a business scenario that meets the scenario requirements among the multiple business scenarios; testing the target interface based on the multiple test cases to generate test results. The method provided by the present application can efficiently and accurately complete interface testing, which is of great significance for improving the quality of business data integration. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0043] Figure 1 A flowchart of an interface testing method provided by an embodiment of the present disclosure;
[0044] Figure 2 A flowchart of another interface testing method provided by an embodiment of the present disclosure;
[0045] Figure 3 A schematic diagram of the structure of an interface testing device provided in an embodiment of the present disclosure;
[0046] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0047] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0048] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0049] Specifically, the current frequent updates and iterations of software functions require a lot of manpower, time and energy to maintain test cases, and the test case maintenance cost is high. Due to the large number of test cases and the fact that some old test cases become redundant as the software is updated, the burden of test execution is increased, resulting in low test case execution efficiency and difficulty in completing a large number of regression tests in a short period of time. Secondly, traditional manual testing is time-consuming and labor-intensive, not only inefficient, but also prone to errors, making it difficult to achieve comprehensive test coverage and unable to adapt to changes in test requirements. Therefore, the present application provides a standardized automated test template that can adjust test scenarios, and generates different test cases by modifying the data in the template file to quickly adapt to changes in requirements. Secondly, the use of standardized test templates can also achieve comprehensive test coverage, improve test execution efficiency and accuracy, and the standardized test template is scalable and can add new test cases or test scenarios.
[0050] In view of the above technical problems, the embodiments of the present disclosure provide an interface testing method, which aims to solve the problems of low efficiency and insufficient test coverage in the existing interface testing methods. Specifically, it is an automated interface testing method based on business data integration. The method realizes the automation of the interface testing process through an automated testing tool to improve the testing efficiency. At the same time, combined with the business data integration characteristics, the interface is comprehensively and accurately tested to reduce the error rate. It is specifically described in detail through one or more of the following embodiments.
[0051] The interface testing method provided by the embodiment of the present disclosure can be applied to the interface testing scenario. The method can be executed by an interface testing device, which can be implemented by software and / or hardware, and the device can be integrated in an electronic device. Among them, the electronic device can include but is not limited to mobile terminals such as smart phones, laptops, digital broadcast receivers, personal digital assistants (PDA), tablet computers (Tablet Personal Computer, Tablet PC), PMP (portable multimedia player), vehicle terminals (such as vehicle navigation terminals), wearable devices, etc., and fixed terminals such as digital televisions, desktop computers, smart home devices, etc.
[0052] Figure 1 A flowchart of an interface testing method provided by an embodiment of the present disclosure specifically includes the following steps: Figure 1 The following steps are shown:
[0053] S101. Build a standardized interface test template covering multiple business scenarios based on business requirements and interface specifications.
[0054] Understandably, business requirements and interface specifications are obtained, where interface specifications are a way to define detailed information of an interface, including interface name, request method, request parameters, return results, etc. Business requirements mainly include functional verification, boundary condition testing, performance testing, security testing, etc., to ensure the correctness and stability of the interface under various conditions. Business requirements specifically characterize the test requirements of multiple test interfaces of the system to be tested. Subsequently, based on the business requirements and interface specifications of the interface test, a standardized interface test template containing various typical business scenarios is defined, and multiple business scenarios can be applied to multiple test interfaces.
[0055] Optionally, the above-mentioned standardized interface test template containing multiple business scenarios is constructed according to business requirements and interface specifications, which can be implemented through the following steps:
[0056] A test scenario library is constructed according to business requirements and interface specifications, wherein the test scenario library includes multiple business scenarios, and each business scenario has business logic and test data; according to the business logic and data specifications, the structure and generation rules of the test data are defined to obtain a test data model; according to the business logic, a corresponding test logic template is set for each business scenario; wherein the standardized interface test template includes the test scenario library, the test data model and the test logic template.
[0057] Understandably, a test scenario library is constructed according to business requirements and interface specifications. The test scenario library stores all possible business scenarios, such as functional testing, security testing, integration testing, and abnormal scenario testing. Testing the interface in multiple business scenarios can ensure the stability and security of the interface. Each business scenario has corresponding business logic / test logic and test data. Business logic refers to the execution logic of test data. For example, the business logic of the above functional test refers to verifying whether the input parameters and output results meet expectations while ensuring that the application programming interface (API) works in accordance with specifications and expectations. In addition, the business scenario library supports dynamic expansion and dynamic adjustment, which is convenient for adding new test scenarios according to business requirements and adjusting stored business scenarios according to business requirements. After the test scenario library is constructed, the structure and generation rules of the test data are defined. Specifically, a reasonable test data model is designed according to the business logic and data specifications to ensure the authenticity and validity of the test data. Subsequently, a corresponding test logic template is designed for each business scenario. The test logic template includes parameters such as request parameters, request methods, and expected responses. At the same time, the test logic template can also be directly parameterized, which is convenient for generating specific test cases according to different test data. Among them, the standardized interface test template includes the above-mentioned test scenario library, test data model and test logic template.
[0058] It is understandable that when constructing a standardized interface test template, a test case generator can also be designed, which is used to automatically generate test cases that conform to business logic based on a test scenario library, a test data model, and a test logic template. A test execution engine can also be designed, which is used to execute test cases, call automated testing tools to interact with the interface to be tested, and record test results. Among them, the standardized interface test template also includes the above-mentioned test case generator and test execution engine.
[0059] It can be understood that after the modules of the standardized interface test template are constructed, an interface test script is designed. The interface test script is used to write the execution process between the modules so as to automatically generate test cases that conform to the business logic based on the standardized interface test template and business data.
[0060] S102: Obtain a test request for a target interface, wherein the test request includes scenario requirements and business data.
[0061] It is understandable that, based on the above S101, a test request for a target interface is obtained, and the target interface refers to at least one test interface among the multiple test interfaces involved in the above construction of the standardized interface test template, that is, at least one interface can be tested, wherein the test request includes scenario requirements and business requirements, and the scenario requirements can be a description statement of the business scenario, or a scenario identifier of the business scenario, and the scenario identifier can be an identifier of at least one business scenario directly selected by the user from the multiple business scenarios included in the standardized interface test template, that is, multiple business scenarios can be tested on the same interface. Business data refers to the data involved in interface testing, and each business scenario has corresponding business data. The business data corresponding to different business scenarios may be the same or different. When selecting at least one business scenario for interface testing, the business data corresponding to at least one business scenario can constitute a business data set. The specific requirements of business data and business requirements are not limited and can be determined according to user needs.
[0062] S103: Generate multiple test cases that meet the business logic corresponding to the target scenario based on the business data and the standardized interface test template.
[0063] The target scenario refers to a business scenario that meets the scenario requirements among the multiple business scenarios.
[0064] It can be understood that, based on the above S102, test cases that conform to the business logic corresponding to the target scenario are automatically generated according to the standardized interface test template and the business data set. The target scenario refers to at least one business scenario among multiple business scenarios that fully meets or at least partially meets the scenario requirements, that is, the satisfaction level of the scenario requirements can be set, wherein each business scenario can generate at least one test case. For example, when the business scenario is a functional test, the test case refers to data transmission and processing covering different situations, including normal situations, abnormal situations and boundary situations.
[0065] Optionally, the above-mentioned generating multiple test cases that meet the business logic corresponding to the target scenario according to the business data and the standardized interface test template can be specifically implemented by the following steps:
[0066] Determine a target scenario that meets the scenario requirements among the multiple business scenarios; and generate multiple test cases that conform to the business logic corresponding to the target scenario based on the test scenario library, the test data model and the test logic template.
[0067] It is understandable that a target scenario that meets the scenario requirements is determined from among the various business scenarios included in the business scenario library. The target scenario can be one that fully meets the scenario requirements, that is, the satisfaction level is set to fully meet, or one that meets at least part of the scenario requirements, that is, the satisfaction level is set to at least partially meet. The satisfaction level of the target scenario can be determined by the user according to the user's needs. After determining the target scenario, the test case generator is used to automatically generate multiple test cases that conform to the business logic according to the test scenario library, the test data model, and the test logic template.
[0068] Optionally, when there is no target scenario that meets the scenario requirement among the multiple business scenarios, determining the target scenario that meets the scenario requirement among the multiple business scenarios may be specifically implemented through the following steps:
[0069] Determine an initial scenario that meets at least part of the scenario requirements among the multiple business scenarios, adjust the initial scenario, and determine the adjusted initial scenario as the target scenario; or, if the initial scenario does not exist among the multiple business scenarios, add a new business scenario according to the scenario requirements, and determine the new business scenario as the target scenario.
[0070] It is understandable that, when the degree of satisfaction of the target scenario is to fully satisfy the scenario requirements, if there is no target scenario that fully satisfies the scenario requirements among multiple business scenarios, an initial scenario that meets some of the scenario requirements is determined among multiple business scenarios. The full satisfaction can be set as the first-level satisfaction degree with a higher priority, and the partial satisfaction can be set as the second-level satisfaction degree with a lower priority. The target scenario can be determined in different ways according to the priority of the satisfaction degree. For example, satisfying some scenario requirements means satisfying the scenario requirements of the output expected results, but not satisfying the scenario requirements of the input parameters. In this case, the initial scenario is adjusted according to the scenario requirements so that the adjusted initial scenario fully satisfies the scenario requirements, and the adjusted initial scenario is determined as the target scenario. Alternatively, if there is no target scenario that fully satisfies the scenario requirements among multiple business scenarios, and there is no initial scenario among multiple business scenarios, that is, there is no business scenario that meets at least some of the scenario requirements in the business scenario library, in this case, a new business scenario can be added according to the scenario requirements, that is, the business scenario is redefined, and the new business scenario is determined as the target scenario. Alternatively, a basic scenario is obtained. The basic scenario can be understood as a business scenario with a basic template for a defined scenario. The basic scenario is then redefined according to the scenario requirements, and the basic scenario is determined as the target scenario.
[0071] S104: Test the target interface based on the multiple test cases to generate a test result.
[0072] It is understandable that, based on the above S103, multiple test cases are executed, and the automated testing tool is called to interact with the target interface to generate test results. The automated testing tool is not limited and can perform interface testing.
[0073] Optionally, the above-mentioned testing of the target interface based on the multiple test cases to generate the test results can be specifically implemented through the following steps:
[0074] Configure a test strategy for the multiple test cases, the test strategy including a test execution strategy and a test frequency strategy, wherein the test execution strategy represents the execution order of the multiple test cases, and the test frequency strategy represents the execution timing of the multiple test cases; execute the multiple test cases according to the test strategy, complete the test of the target interface, and generate a test result.
[0075] It is understandable that test strategies can be configured for multiple test cases, and strategies can be configured for at least some of the multiple test cases. The test strategies configured for different test cases can be the same or different. Among them, the test strategy refers to the control strategy for the execution timing and execution frequency of the test case. The test case includes a test execution strategy and a test frequency strategy. The test execution strategy represents the execution order between multiple test cases. For example, multiple test cases are executed in the order of generation. The test frequency strategy represents the execution timing of multiple test cases. For example, multiple test cases are executed every 1 hour. After configuring the test strategy for each test case, execute it according to the test strategy configured for each test case, complete the test of the target interface, and generate test results. Each test case corresponds to a test result, and the test results corresponding to multiple test cases constitute a test result set.
[0076] Optionally, the test execution strategy includes at least one of sequential execution, parallel execution and conditional execution, wherein the sequential execution refers to executing the test cases one by one in the order of sequence, the parallel execution refers to executing multiple test cases at the same time, and the conditional execution refers to determining the next test case to be executed based on the test result of the previous test case; the test frequency strategy includes scheduled execution, event-triggered execution and on-demand execution, wherein the scheduled execution refers to using a scheduled task scheduler to determine the execution time of the test case, the event-triggered execution refers to determining the trigger time of a preset event as the execution time of the test case, and the on-demand execution refers to responding to the start operation of the test interface that displays the test case, executing the test case corresponding to the start operation.
[0077] It can be understood that the test execution strategy includes at least one of sequential execution, parallel execution and conditional execution, and can be configured for different test cases in multiple execution strategies. In one possible scenario, a sequential execution strategy is configured for the first part of multiple test cases, and a conditional execution strategy is configured for the second part of test cases, wherein sequential execution refers to executing the test cases one by one in the order in which they are generated, and is applicable to test cases with dependencies. Parallel execution refers to the simultaneous execution of multiple test cases, and is applicable to independent test cases without dependencies. For example, a preset number of test cases are executed simultaneously to improve test efficiency. Conditional execution refers to determining the next test case to be executed based on the test result of the previous test case, that is, deciding whether to execute a test case or test scenario based on the test result or external conditions. For example, after the first test case is executed and the first test result is obtained, the second test case is determined as the next test case to be executed based on the first test result. Specifically, a test interface automatically retries when the test fails, or is executed within a specific time period after the test failure. Test frequency strategies include scheduled execution, event-triggered execution, and on-demand execution. Scheduled execution refers to using a scheduled task scheduler (Windows scheduled tasks) to determine the execution time of a test case. For example, according to business needs, it can be executed periodically at a set time, or it can be configured as a test case to be executed daily, weekly, monthly, or on a specified date. Event-triggered execution refers to determining the trigger time of a preset event as the execution time of a test case, that is, when a specific time occurs (development code submission and version release, etc.), the corresponding test task is triggered. Event monitoring can be implemented through API calls or message queues. For example, after a version is updated, the test case is executed for interface testing to determine whether the new version affects the stability of the interface. On-demand execution refers to executing the test case corresponding to the start operation in response to the start operation of the test interface that displays the test case. For example, the test case that responds to the user operation is executed, that is, a user interface or API interface is provided to allow testers or business systems to manually trigger test tasks according to actual needs. On-demand execution can flexibly respond to sudden test needs or emergency problem troubleshooting.
[0078] Optionally, after testing the target interface based on the multiple test cases and generating test results, the method further includes:
[0079] The test results are analyzed and processed to generate a test report; based on the test report, the standardized interface test template and / or the business data are adjusted to obtain multiple updated test cases; the updated multiple test cases are executed, and an automated testing tool is called to interact with the target interface to generate test results.
[0080] It is understandable that the test results are analyzed and processed to generate a test report to provide reliable test data for the business. The analysis can be performed after each test result is generated, or after multiple tests are performed to obtain multiple test reports, a comprehensive analysis can be performed on multiple test reports. After completing the analysis of the test report, the standardized interface test template and / or business data are adjusted based on the test report, and multiple updated test cases are generated through the adjusted standardized interface test template and business data. Subsequently, the updated multiple test cases are continued to be executed, and the automated testing tool is called to interact with at least one target interface involved to generate new test results.
[0081] The interface testing method provided by the embodiment of the present disclosure is the key to realizing efficient, accurate and comprehensive automated interface testing through the customized standardized interface testing template and the specific logic of the test strategy configured for each test case. By continuously optimizing and improving the standardized interface testing template and the test strategy, the quality and efficiency of the interface testing can be further improved, and the stability and reliability of the business data integration can be ensured. Specifically, the introduction of automated testing frameworks such as standardized interface testing templates and automated testing strategies greatly reduces manual intervention and improves testing efficiency; the test case set generated according to business data and standardized interface testing templates can cover all key interfaces and business scenarios, timely discover potential problems and defects, reduce error rates, and ensure the comprehensiveness and effectiveness of the test; through automated interface testing, interface problems can be discovered and repaired in a timely manner to ensure the quality and stability of business data integration. The method provided by the present application has the advantages of high efficiency, accuracy, and comprehensiveness, and can effectively solve the problems existing in the existing interface testing methods. The method realizes comprehensive and efficient testing of the interface by defining standardized interface testing templates and automated testing strategies, combined with business data integration technology, and has important application value for improving interface quality and the overall performance of software systems.
[0082] Based on the above embodiments, see Figure 2 , Figure 2 A flowchart of another interface testing method provided by an embodiment of the present disclosure specifically includes the following steps:
[0083] 1) Define standardized interface test templates; 2) Write interface test scripts; 3) Generate test cases that conform to business logic based on business data and standardized interface test templates; 4) Configure interface test automatic execution strategies; 5) Execute test cases and record test results; 6) Analyze test results and generate test reports.
[0084] It can be understood that the defined standardized interface test template contains various possible business scenarios and corresponding test data. The standardized interface test template is defined in an extensible markup language to facilitate later maintenance, editing and expansion. Configure the interface test automatic execution strategy. Specifically, configure the corresponding test execution strategy and test frequency strategy according to the characteristics of the test case and the test requirements. Through business data integration technology, the business data is combined with the test case to make the test closer to the actual business scenario and improve the accuracy and effectiveness of the test. For the specific implementation steps of 1) to 6) above, please refer to the above embodiment and will not be repeated here.
[0085] Figure 3 Schematic diagram of the structure of an interface testing device provided by an embodiment of the present disclosure. The interface testing device provided by an embodiment of the present disclosure can execute the processing flow provided by an interface testing method embodiment, such as Figure 3 As shown, the interface testing device 300 includes a construction unit 301, an acquisition unit 302, a test case generation unit 303 and a test result generation unit 304, wherein:
[0086] The construction unit 301 is used to construct a standardized interface test template containing multiple business scenarios according to business requirements and interface specifications;
[0087] The acquisition unit 302 is used to acquire a test request for a target interface, wherein the test request includes scenario requirements and business data;
[0088] A test case generating unit 303 is used to generate a plurality of test cases that conform to the business logic corresponding to a target scenario according to the business data and the standardized interface test template, wherein the target scenario refers to a business scenario that meets the scenario requirements among the multiple business scenarios;
[0089] The test result generating unit 304 is used to test the target interface based on the multiple test cases and generate a test result.
[0090] Optionally, the construction unit 301 is used to:
[0091] Building a test scenario library according to business requirements and interface specifications, wherein the test scenario library includes multiple business scenarios, each of which has business logic and test data;
[0092] According to the business logic and data specifications, define the structure and generation rules of the test data to obtain a test data model;
[0093] According to the business logic, a corresponding test logic template is set for each business scenario;
[0094] The standardized interface test template includes the test scenario library, the test data model and the test logic template.
[0095] Optionally, the test case generating unit 303 is used to:
[0096] Determine a target scenario that meets the scenario requirements among the multiple business scenarios;
[0097] Based on the test scenario library, the test data model and the test logic template, multiple test cases that conform to the business logic corresponding to the target scenario are generated.
[0098] Optionally, the test case generating unit 303 is used to:
[0099] Determine an initial scenario that meets at least part of the scenario requirements from among the multiple business scenarios, adjust the initial scenario, and determine the adjusted initial scenario as the target scenario; or,
[0100] In the case that the initial scenario does not exist in the multiple business scenarios, a new business scenario is added according to the scenario requirements, and the new business scenario is determined as the target scenario.
[0101] Optionally, the test result generating unit 304 is used to:
[0102] Configuring a test strategy for the multiple test cases, the test strategy comprising a test execution strategy and a test frequency strategy, wherein the test execution strategy represents the execution order of the multiple test cases, and the test frequency strategy represents the execution timing of the multiple test cases;
[0103] The multiple test cases are executed according to the test strategy, the test for the target interface is completed, and the test result is generated.
[0104] Optionally, the test execution strategy in the interface testing device 300 includes at least one of sequential execution, parallel execution and conditional execution, wherein the sequential execution refers to executing the test cases one by one in the order of precedence, the parallel execution refers to executing multiple test cases at the same time, and the conditional execution refers to determining the next test case to be executed according to the test result of the previous test case;
[0105] The test frequency strategy includes scheduled execution, event-triggered execution and on-demand execution, wherein the scheduled execution refers to using a scheduled task scheduler to determine the execution time of a test case, the event-triggered execution refers to determining the trigger time of a preset event as the execution time of the test case, and the on-demand execution refers to responding to a start operation of a test interface that displays the test case and executing the test case corresponding to the start operation.
[0106] Optionally, the interface testing device 300 is further used for:
[0107] Analyze and process the test results to generate a test report;
[0108] Adjusting the standardized interface test template and / or the business data based on the test report to obtain a plurality of updated test cases;
[0109] The updated multiple test cases are executed, and an automated testing tool is called to interact with the target interface to generate test results.
[0110] Figure 3 The interface testing device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effect are similar and will not be described in detail here.
[0111] Figure 4 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 4 , which shows a schematic diagram of the structure of an electronic device 400 suitable for implementing the embodiment of the present disclosure. The electronic device 400 in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), wearable electronic devices, etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, etc. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0112] like Figure 4 As shown, the electronic device 400 may include a processing device 401 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 to a random access memory (RAM) 403 to implement the interface testing method of the embodiment described in the present disclosure. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0113] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0114] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the interface testing method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0115] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0116] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0117] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0118] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0119] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0120] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0121] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, constitute a limitation on the unit itself.
[0122] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0123] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0124] It should be noted that, in this article, relational terms such as "first" and "second" are only used 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 gateway that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or gateway. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or gateway that includes the elements.
[0125] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An interface testing method, characterized in that: include: Build standardized interface test templates covering various business scenarios based on business requirements and interface specifications; Obtaining a test request for a target interface, wherein the test request includes scenario requirements and business data, wherein the business data refers to data involved in performing interface testing; Generate multiple test cases that meet the business logic corresponding to the target scenario according to the business data and the standardized interface test template, wherein the target scenario refers to a business scenario that meets the scenario requirements among the multiple business scenarios; Testing the target interface based on the multiple test cases to generate a test result; Among them, the standardized interface test template containing multiple business scenarios is constructed according to business requirements and interface specifications, including: Build a test scenario library according to business requirements and interface specifications. The test scenario library includes multiple business scenarios. Each business scenario has business logic and test data. The business logic refers to the execution logic of the test data. According to the business logic and data specifications, define the structure and generation rules of the test data to obtain a test data model; According to the business logic, a corresponding test logic template is set for each business scenario; The standardized interface test template includes the test scenario library, the test data model and the test logic template.
2. The method according to claim 1, characterized in that: The generating, according to the business data and the standardized interface test template, a plurality of test cases that conform to the business logic corresponding to the target scenario comprises: Determine a target scenario that meets the scenario requirements among the multiple business scenarios; Based on the test scenario library, the test data model and the test logic template, multiple test cases that conform to the business logic corresponding to the target scenario are generated.
3. The method according to claim 2, characterized in that In a case where there is no target scenario that meets the scenario requirement among the multiple business scenarios, determining the target scenario that meets the scenario requirement among the multiple business scenarios includes: Determine an initial scenario that meets at least part of the scenario requirements from among the multiple business scenarios, adjust the initial scenario, and determine the adjusted initial scenario as the target scenario; or, In the case that the initial scenario does not exist in the multiple business scenarios, a new business scenario is added according to the scenario requirements, and the new business scenario is determined as the target scenario.
4. The method according to claim 1, characterized in that The step of testing the target interface based on the multiple test cases and generating a test result includes: Configuring a test strategy for the multiple test cases, the test strategy comprising a test execution strategy and a test frequency strategy, wherein the test execution strategy represents the execution order of the multiple test cases, and the test frequency strategy represents the execution timing of the multiple test cases; The multiple test cases are executed according to the test strategy, the test for the target interface is completed, and the test result is generated.
5. The method according to claim 4, characterized in that The test execution strategy includes at least one of sequential execution, parallel execution and conditional execution, wherein the sequential execution refers to executing the test cases one by one in the order of precedence, the parallel execution refers to executing multiple test cases at the same time, and the conditional execution refers to determining the next test case to be executed according to the test result of the previous test case; The test frequency strategy includes scheduled execution, event-triggered execution and on-demand execution, wherein the scheduled execution refers to using a scheduled task scheduler to determine the execution time of a test case, the event-triggered execution refers to determining the trigger time of a preset event as the execution time of the test case, and the on-demand execution refers to responding to a start operation of a test interface that displays the test case and executing the test case corresponding to the start operation.
6. The method according to claim 1, characterized in that After testing the target interface based on the multiple test cases and generating test results, the method further includes: Analyze and process the test results to generate a test report; Adjusting the standardized interface test template and / or the business data based on the test report to obtain a plurality of updated test cases; The updated multiple test cases are executed, and an automated testing tool is called to interact with the target interface to generate test results.
7. An interface testing device, characterized in that: include: The construction unit is used to build a standardized interface test template containing multiple business scenarios according to business requirements and interface specifications; An acquisition unit, configured to acquire a test request for a target interface, wherein the test request includes scenario requirements and business data, wherein the business data refers to data involved in performing an interface test; A test case generation unit, configured to generate a plurality of test cases that conform to the business logic corresponding to a target scenario according to the business data and the standardized interface test template, wherein the target scenario refers to a business scenario that meets the scenario requirements among the multiple business scenarios; A test result generating unit, configured to test the target interface based on the multiple test cases and generate a test result; Wherein, the building block is used for: A test scenario library is constructed according to business requirements and interface specifications, wherein the test scenario library includes multiple business scenarios, each of which has business logic and test data, and the business logic refers to the execution logic of the test data; according to the business logic and data specifications, the structure and generation rules of the test data are defined to obtain a test data model; according to the business logic, a corresponding test logic template is set for each business scenario; wherein the standardized interface test template includes the test scenario library, the test data model and the test logic template.
8. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the interface testing method as claimed in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the interface testing method according to any one of claims 1 to 6 are implemented.
