Interface test method, electronic equipment and storage medium
By using test scripts that describe keywords in interface testing and combining the parameter generation framework to generate specific parameter values, the existing interface testing methods require writing a large number of scripts, which improves testing efficiency and maintenance simplicity.
Patent Information
- Application Number
- CN202411546074.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-02-11
AI Technical Summary
Existing interface testing methods require writing a large number of scripts for each interface to cover different parameters, resulting in complexity and high workload and reducing testing efficiency.
By receiving a test script containing flag keywords and description keywords, using the parameter generation framework to parse the flag keywords, generate specific parameter values based on the description keywords, and integrate them into the test script to achieve testing of the interface.
It improves the efficiency of interface testing, reduces the workload of testers, simplifies the maintenance and management of test scripts, and only needs to modify one test script when the interface changes.
Smart Images

Figure CN119415398A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of interface testing, and more specifically to an interface testing method, electronic equipment and storage medium. Background Art
[0002] With the rapid development of Internet technology, the complexity of application systems is increasing. As a bridge for interaction between systems, the stability and reliability of interfaces are directly related to the normal operation of the entire system. As an important part of software quality assurance, interface testing plays an increasingly critical role in the current software development process.
[0003] In existing interface testing, multiple scripts need to be written separately for each interface to meet the interface testing requirements under different parameter conditions. For example, if an interface has three input parameters A, B, and C, and each parameter has a different value range, then the tester needs to write multiple scripts for the interface to cover different parameter combinations. In this way, it is necessary to write a large number of test scripts to verify whether the interface function is normal, which increases the complexity and workload of maintenance and reduces the efficiency of interface testing. Summary of the invention
[0004] The present invention is proposed in view of the above problems. According to one aspect of the present invention, an interface testing method is provided, comprising: Receive a test script, the test script comprising a plurality of flag keywords and description keywords corresponding to the plurality of flag keywords, each of the plurality of flag keywords being used to represent a name of a different parameter in an interface test, and the description keyword being used to represent a value requirement of the corresponding parameter; Execute the test script to test the interface to be tested, wherein, during the execution of the test script, perform the following parameter generation operations: when a flag keyword in the test script is identified, determine the parameter type of the flag keyword; when the parameter type of the flag keyword is an interface parameter, call a parameter generation framework to parse the flag keyword to generate an interface parameter value based on a description keyword corresponding to the flag keyword; integrate the generated interface parameter value into the test script; Generate a test result of the interface to be tested.
[0005] Exemplarily, the value requirement is a value range; the calling parameter generation framework parses the flag keyword, including: using the parameter generation framework to perform the following operations: Determine the description keyword corresponding to the flag keyword; When the description keyword is a value range of a corresponding interface parameter, a parameter value of the interface parameter is randomly generated within the value range.
[0006] Exemplarily, before the calling parameter generation framework parses the flag keyword, the method further includes: Based on a first selection operation of the user, determining a first keyword template corresponding to the current test scenario from a plurality of preset interface keyword templates; inputting the first keyword template into the parameter generation framework; The step of determining the description keyword corresponding to the flag keyword includes: The description keyword corresponding to the flag keyword is determined from the test script using the first keyword template.
[0007] Exemplarily, the parameter generation operation further includes: When the parameter type of the flag keyword is an environment parameter, calling the environment generation framework to parse the flag keyword to generate an environment parameter value based on a description keyword corresponding to the flag keyword; The generated environmental parameter values are sent to a corresponding environmental simulation tool so as to utilize the environmental simulation tool to simulate the interface test environment.
[0008] Exemplarily, the value requirement is a value range or a value description; the calling environment generation framework parses the flag keyword, including: Determine the description keyword corresponding to the flag keyword; When the description keyword is a value range of a corresponding environmental parameter, a parameter value of the parameter is randomly generated within the value range; When the description keyword is a value description of the corresponding environment parameter, an environment parameter value corresponding to the value description is generated.
[0009] Exemplarily, before the calling environment generation framework parses the flag keyword, the method further includes: Based on the user's second selection operation, determining a second keyword template corresponding to the current test scenario from a plurality of preset environment keyword templates; inputting the second keyword template into the environment generation framework; The step of determining the description keyword corresponding to the flag keyword includes: The description keyword corresponding to the flag keyword is determined from the test script using the second keyword template.
[0010] Exemplarily, the parameter generation operation further includes: When the parameter type of the flag keyword is a fault parameter, the calling environment generation framework parses the flag keyword to determine the fault type based on the description keyword corresponding to the flag keyword; The fault type is simulated using an environmental simulation tool.
[0011] Exemplarily, executing the test script to test the interface to be tested includes: Repeat the test script according to the preset execution times.
[0012] According to another aspect of the present invention, there is provided an electronic device, including a processor and a memory, wherein a computer program is stored in the memory, and the processor is used to execute the computer program to implement the above method.
[0013] According to another aspect of the present invention, a computer-readable storage medium is provided, storing a computer program / instruction, and the computer program / instruction implements the above method when executed by a processor.
[0014] In the above technical solution, the test parameters of the interface can be described in the test script using the flag keywords and the corresponding description keywords. During the script execution, the specific parameters can be parsed and generated according to the parameter value requirements to achieve the simulation of the test scenario. Therefore, in the script writing process, the tester only needs to write the parameter value requirements into the script, which helps to improve the test efficiency of the interface test and reduce the workload of the tester. In this way, when the interface to be tested changes, the tester only needs to modify a test script, which helps to further improve the test efficiency and facilitates the maintenance and management of the test script.
[0015] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The above and other purposes, features and advantages of the present invention will become more apparent by describing the embodiments of the present invention in more detail in conjunction with the accompanying drawings. The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings, the same reference numerals generally represent the same components or steps.
[0017] Figure 1 A schematic flow chart showing an interface testing method according to one aspect of the present invention; Figure 2 A schematic block diagram of an electronic device according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical scheme and advantages of the present invention more obvious, the exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments of the present invention, and it should be understood that the present invention is not limited to the exemplary embodiments described herein. Based on the embodiments of the present invention described in the present invention, all other embodiments obtained by those skilled in the art without creative work should fall within the protection scope of the present invention.
[0019] As described above, in the existing interface test, multiple scripts need to be written separately for each interface to meet the interface test requirements under different parameter conditions. For example, if an interface has three input parameters A, B, and C, and each parameter has a different value range, then the tester needs to write multiple scripts for the interface to cover different parameter combinations. And when there is a mutual dependence between the input parameters, the tester also needs to manually determine whether the selected parameter value can meet this mutual dependence, which greatly increases the complexity and workload of interface testing and maintenance, and seriously affects the efficiency of interface testing. In view of this, the present invention provides an interface testing method, an electronic device, and a storage medium, which can solve the problem of needing to write a large number of scripts to cover different parameter combinations during interface testing, which helps to improve the test efficiency of interface testing and reduce the workload of testers. The method, electronic device, and storage medium are described in detail below.
[0020] According to one aspect of the present invention, an interface testing method is provided. Figure 1 FIG. 1 is a schematic flow chart of an interface testing method according to one aspect of the present invention. Figure 1 As shown, the method may include the following steps S110, S120 and S130.
[0021] In step S110, a test script is received, the test script including a plurality of flag keywords and description keywords corresponding to the plurality of flag keywords one by one, each of the plurality of flag keywords is used to represent the name of a different parameter in the interface test, and the description keyword is used to represent the value requirement of the corresponding parameter.
[0022] In the solution of this example, the test script can be edited in real time by the tester (i.e., the user) according to the test requirements. In some embodiments, the tester can edit the test script in advance according to the test requirements of this test (including requirements for interface parameters and / or requirements for the test environment) before testing the interface to be tested. In a specific embodiment, the tester can write a test case according to the test requirements, and then write a test script according to the test case.
[0023] The test script can also be selected by the tester from multiple preset scripts. Optionally, before receiving the test script, the method may further include: selecting a test script from multiple preset scripts in response to a user's selection operation. In the scheme of this embodiment, multiple preset scripts corresponding to different test requirements can be pre-edited. Before testing the interface, a preset script corresponding to the current test requirement can be selected from multiple preset scripts as a test script. This method does not require users to edit test scripts in real time, which helps to further improve test efficiency and can reduce the requirements for testers during interface testing (for example, experienced testers can pre-edit multiple preset scripts).
[0024] In the scheme of this example, each of the multiple flag keywords is used to represent the name of different parameters in the interface test, and the description keyword is used to represent the value requirements of the corresponding parameters. It can be understood that a variety of different parameters need to be set in the interface test, and these parameters may include access point name, access point type, user name, password, test temperature, network signal strength, etc. Each parameter has its own corresponding value requirement. For example, when the parameter name is a user name, the value requirement of the parameter can be the actual user name (this value requirement can be called a value description); when the parameter name is a test temperature, the value requirement of the parameter can be a test temperature value or a test temperature range.
[0025] In step S120, the test script is executed to test the interface to be tested, wherein, during the execution of the test script, the following parameter generation operations are performed: when a flag keyword in the test script is identified, the parameter type of the flag keyword is determined; when the parameter type of the flag keyword is an interface parameter, the parameter generation framework is called to parse the flag keyword to generate an interface parameter value based on the description keyword corresponding to the flag keyword; and the generated interface parameter value is integrated into the test script.
[0026] The execution of the test script can be implemented by any existing or future developed automated testing framework. The automated testing framework includes but is not limited to Selenium, TestNG, JUnit, etc. In the solution of this example, after receiving the test script, the test script can be executed. During the execution of the test script, the keywords in the test script can be parsed through the parameter generation operation to test the interface under different test scenarios.
[0027] As described above, the description keyword is used to indicate the value requirement of the corresponding parameter. In the scheme of this example, when the parameter type of the flag keyword is an interface parameter (i.e., an API parameter). When the flag keyword is identified, the parameter generation framework can be used to parse the flag keyword to generate an interface parameter value based on the description keyword corresponding to the flag keyword, that is, according to the value requirement corresponding to the flag keyword, the value of the parameter (i.e., the interface parameter value) is generated. The interface parameter value can be the actual user name (e.g., user1) as described above. Of course, the interface parameter can also be a specific numerical value. For example, if the value requirement of a certain API parameter is 10-20, in the scheme of this embodiment, a specific numerical value (e.g., 12) can be automatically generated according to the value requirement. This is conducive to the accurate simulation of the test scenario in subsequent steps.
[0028] Optionally, the API parameters may include but are not limited to access point name, access point type, user name, password, etc., which is not limited in the present invention.
[0029] Optionally, any existing or future developed parameter parsing method may be used to generate an interface parameter value based on a description keyword corresponding to the flag keyword. For example, a pre-trained neural network may be used to determine the description keyword, and the interface parameter value may be generated based on the description keyword. Of course, the description keyword may also be determined using the keyword template described below, and then the interface parameter value may be generated based on the determined description keyword, which will not be described in detail.
[0030] It can be understood that the steps of executing the test script can be divided into two steps. In the first step, the keywords in the test script are parsed through the parameter generation operation. In the second step, after the keyword parsing is completed, the test script is used to test the interface to be tested. In this way, the test of the interface to be tested can be completed.
[0031] It is understood that the test script may include one or more flag keywords to be parsed. In some embodiments, after each flag keyword is parsed (i.e., the interface parameter value corresponding to the flag keyword is generated), the parsing result (i.e., the generated interface parameter value) may be integrated into the test script. In other embodiments, after all flag keywords are parsed, the parsing result may be integrated into the test script.
[0032] In step S130, a test result of the interface to be tested is generated.
[0033] After the test is completed, the test result of the interface to be tested can be obtained. The test result can provide a relatively accurate basis for the tester to verify the interface function. Those skilled in the art can understand the specific implementation method of how to judge whether the interface function is normal through the test result, which will not be repeated.
[0034] In the above technical solution, the test parameters of the interface can be described in the test script using the flag keywords and the corresponding description keywords. During the script execution, the specific parameters can be parsed and generated according to the parameter value requirements to achieve the simulation of the test scenario. Therefore, in the script writing process, the tester only needs to write the parameter value requirements into the script, which helps to improve the test efficiency of the interface test and reduce the workload of the tester. In this way, when the interface to be tested changes, the tester only needs to modify a test script, which helps to further improve the test efficiency and facilitates the maintenance and management of the test script.
[0035] Exemplarily, the value requirement is a value range; calling the parameter generation framework to parse the flag keyword can specifically include the following steps: using the parameter generation framework to perform the following operations: determine the description keyword corresponding to the flag keyword; when the description keyword is the value range of the corresponding interface parameter, randomly generate the parameter value of the interface parameter (i.e., the interface parameter value) within the value range.
[0036] In the scheme of this example, when the value requirement is a value range, the parameter value of the interface parameter can be randomly generated within the value range. In this way, different test scenarios corresponding to the value range can be randomly simulated. When the API parameter has a specific value range, the specific value range can be directly input into the test script as a description keyword of the API parameter, and different parameter values within the specific value range can be randomly generated by repeatedly executing the test script to cover the value range of the parameter. When multiple API parameters have specific value ranges, different parameter combinations can be randomly generated by repeatedly executing the test script to achieve simulation of different test scenarios. Therefore, in the scheme of this example, when the interface parameter has a corresponding value range, coverage of the value range can be achieved using only one test script, without the need to write a large number of test scripts with different parameter values, which helps to improve test efficiency and reduce the workload of testers.
[0037] Optionally, the value requirement may also be a preset parameter value. In this embodiment, calling the parameter generation framework to parse the flag keyword may specifically include the following steps: using the parameter generation framework to perform the following operations: determining a description keyword corresponding to the flag keyword; when the description keyword is a preset parameter value of the corresponding interface parameter, using the preset parameter value as the parameter value of the interface parameter.
[0038] Exemplarily, before calling the parameter generation framework to parse the flag keyword, the method further includes: based on the user's first selection operation, determining a first keyword template corresponding to the current test scenario from a plurality of preset interface keyword templates; and inputting the first keyword template into the parameter generation framework.
[0039] Determining the description keyword corresponding to the flag keyword includes: using a first keyword template to determine the description keyword corresponding to the flag keyword from a test script.
[0040] In the solution of this example, multiple preset interface keyword templates can be predefined, and the multiple preset interface keyword templates can correspond to different test scenarios respectively. Before testing, the user can select the corresponding preset interface keyword template as the first keyword template according to the current test scenario. And use the first keyword template to determine the description keyword.
[0041] In the above technical solution, the user can determine the first keyword template corresponding to the current test scenario from multiple preset interface keyword templates according to actual needs, so that when conducting a test, different test scenarios can be covered by selecting different preset interface keyword templates. And because the selected first keyword template corresponds to the current test scenario, the description keyword can be determined more accurately using the first keyword template, which helps to improve the accuracy of the test.
[0042] Exemplarily, the parameter generation operation also includes: when the parameter type of the flag keyword is an environment parameter, calling the environment generation framework to parse the flag keyword to generate an environment parameter value based on the description keyword corresponding to the flag keyword; sending the generated environment parameter value to the corresponding environment simulation tool to use the environment simulation tool to simulate the interface test environment.
[0043] Optionally, after generating the environment parameter value, the parameter generation operation may further include: integrating the environment parameter value into the test script.
[0044] Optionally, the environmental parameters include but are not limited to test temperature, signal strength, signal attenuation, etc., which are not limited in the present invention. In this example, the environmental parameter value can be a specific value (such as 40°C) or an unspecified value (such as continuous fluctuation between 30-60°C). The specific environmental parameter value can be set according to actual needs and will not be described in detail.
[0045] In the solution of this example, when the parameter type of the flag keyword is an environment parameter, the environment generation framework can be called to parse the flag keyword to obtain the environment parameter value, that is, to generate the environment parameter value according to the value requirement of the environment parameter. After obtaining the environment parameter value, the environment parameter value can be sent to the corresponding environment simulation tool, and the environment simulation tool can be adjusted according to the environment parameter value to simulate the interface test environment.
[0046] It can be understood that the environmental simulation tool in this example can be any one or more existing or future developed tools that can simulate the interface test environment. The tool can be a software tool used in interface testing, or it can be a physical device. For example, the environmental simulation tool can include but is not limited to a shielding box, a digitally controlled attenuator, a channel simulator, a noise simulator, a high and low temperature test box, a network performance test tool (such as Iperf), a packet loss simulation tool (such as Packet LossSimulator), a hardware network tester, etc.
[0047] The specific method of generating the environment parameter value based on the description keyword corresponding to the flag keyword is similar to the method of generating the interface parameter value, which is not repeated here.
[0048] In the above technical solution, the test script may only include the value requirements for the environmental parameters. When executing the test script, the parameter value of the environmental parameter can be automatically generated according to the value requirements for the environmental parameters, thereby simulating the interface test environment. The solution is simple to execute and can quickly generate environmental parameters, thereby providing a simulated communication environment scenario for interface testing, and further more accurately determining whether the interface functions normally in different communication environments.
[0049] Exemplarily, the value requirement is a value range or a value description; calling the environment generation framework to parse the flag keyword, including: determining the description keyword corresponding to the flag keyword; when the description keyword is the value range of the corresponding environment parameter, randomly generating a parameter value of the parameter (which can be called an environment parameter value) within the value range; when the description keyword is the value description of the corresponding environment parameter, generating an environment parameter value corresponding to the value description.
[0050] In the scheme of this example, when the value requirement is a value range, the parameter value of the environmental parameter can be randomly generated within the value range. In this way, different test environments corresponding to the value range can be randomly simulated. When the environmental parameter has a specific value range, the specific value range can be directly input into the test script as a description keyword of the environmental parameter. For example, in one embodiment, the flag keyword is the test temperature, and the description keyword is 30-60°C. In this case, any temperature value within the range of 30-60°C can be randomly generated as the environmental parameter value, for example, it can be 40°C.
[0051] It can be understood that when the value requirement is a value range, different parameter values within the value range can be randomly generated by repeatedly executing the test script to cover the value range of the environmental parameter. When multiple environmental parameters have specific value ranges, different combinations of environmental parameters can be randomly generated by repeatedly executing the test script to simulate different test environments. Therefore, in the solution of this example, when the interface parameter has a corresponding value range, only one test script can be used to cover the value range, without the need to write a large number of test scripts with different parameter values.
[0052] As described above, when the value requirement is a value description, an environmental parameter value corresponding to the value description can be generated. Optionally, the environmental parameter value corresponding to the value description may include parameter values corresponding to one or more environmental parameters. In some embodiments, generating an environmental parameter value corresponding to the value description includes: for any environmental parameter corresponding to the value description, randomly generating an environmental parameter value within a preset value range of the environmental parameter. The preset value range of each environmental parameter corresponding to the value description can be pre-set as needed, and will not be repeated. In one embodiment, the environmental parameters corresponding to the network quality can be pre-defined to include signal strength and noise level, and the levels of signal strength are defined to include weak, moderate, and strong, and the levels of noise level include low, medium, and high, and each level corresponds to a different parameter range. Among them, if the signal strength is "strong" and the noise level is "low", the signal quality is considered to be "excellent", and if the signal strength is "moderate" and the noise level is "medium", the signal quality is considered to be good. In this case, if the flag keyword is network quality and the description keyword is good, a numerical value can be generated within the parameter range corresponding to the signal strength being "moderate" as the signal strength value. A value is generated within the parameter range corresponding to the noise level of "medium" as the noise level value. The signal strength value and the noise level value are the environmental parameter values corresponding to the value description.
[0053] In this solution, when the value requirement is a value description, repeatedly executing the test script can generate one or more environmental parameter combinations within one or more environmental parameter ranges corresponding to the value description, thereby enabling testing of the interface under different test environments.
[0054] In the above technical solution, when the description keyword has a corresponding value range, only one test script can be used to cover the value range, thereby simulating different test environments. This solution does not require testers to write a large number of test scripts with different parameter values, which helps to improve test efficiency and reduce the workload of testers.
[0055] Exemplarily, before calling the environment generation framework to parse the flag keyword, the method further includes: based on the user's second selection operation, determining a second keyword template corresponding to the current test scenario from a plurality of preset environment keyword templates; and inputting the second keyword template into the environment generation framework.
[0056] Determining the description keyword corresponding to the flag keyword includes: using the second keyword template to determine the description keyword corresponding to the flag keyword from the test script.
[0057] It can be understood that the test scenario includes the test environment and the usage scenario, wherein the API parameters are mainly used to simulate the actual usage scenario of the interface, and the environment parameters are mainly used to simulate the working environment of the interface.
[0058] In the solution of this example, multiple preset environment keyword templates can be predefined, and the multiple preset environment keyword templates can correspond to different test environments respectively. Before testing, the user can select the corresponding preset environment keyword template as the second keyword template according to the current test environment. And use the second keyword template to determine the description keyword.
[0059] In the above technical solution, the user can determine the second keyword template corresponding to the current test scenario (the current test scenario includes the test environment) from multiple preset environment keyword templates according to actual needs, so that when conducting a test, different test environments can be covered by selecting different preset environment keyword templates. And because the selected second keyword template corresponds to the current test scenario, the description keyword can be determined more accurately using the second keyword template, which helps to improve the accuracy of the test.
[0060] Exemplarily, the parameter generation operation also includes: when the parameter type of the flag keyword is a fault parameter, calling the environment generation framework to parse the flag keyword to determine the fault type based on the description keyword corresponding to the flag keyword; and simulating the fault type using an environment simulation tool.
[0061] Optionally, the fault parameters may include hardware faults, network faults, etc., which are not described in detail. As described above, the description keyword is used to indicate the value requirements of the corresponding parameters. When the parameter type of the flag keyword is a fault parameter, the description keyword corresponding to the fault parameter may be the fault type. For example, when the flag keyword is a hardware fault, the description keyword may be a simulator error, a sensor fault, etc. When the flag keyword is a network fault, the description keyword may be packet loss, increased latency, etc.
[0062] In the solution of this example, the environmental simulation tool can be used to simulate the fault type. For example, when the fault type is packet loss, a network performance test tool (such as Iperf), a packet loss simulation tool (such as Packet LossSimulator) or a hardware network tester can be used to simulate packet loss.
[0063] The parameter type of the flag keyword of the above technical solution can be a fault parameter. In other words, a fault simulation mechanism can be added to the test script, so that when the interface is tested, the actual working conditions of the interface when a fault occurs can be tested, which helps to verify the stability of the interface function, thereby facilitating users to analyze the interface function more accurately based on the test results.
[0064] Exemplarily, executing a test script to test the interface to be tested includes: repeatedly executing the test script according to a preset number of executions. By repeatedly executing the test script according to the preset number of executions, a plurality of parameter combinations can be generated using the parameter generation operation, thereby simulating different test scenarios. In short, the solution helps to verify the usage of the interface in different scenarios, and can facilitate users to more accurately analyze the interface function based on the test results.
[0065] Exemplarily, before the generated interface parameter values are integrated into the test script, the parameter generation operation also includes the following steps: for any two or more interdependent interface parameters, judging whether the interface parameter values corresponding to the two or more interdependent interface parameters satisfy the constraint conditions; wherein the step of integrating the generated interface parameter values into the test script is performed when the interface parameter values corresponding to the two or more interdependent interface parameters satisfy the constraint conditions.
[0066] Optionally, when the interface parameter values corresponding to the two or more interdependent interface parameters do not satisfy the constraint conditions, the parameter generation operation further includes: regenerating the interface parameter values of at least some of the two or more interface parameters using a parameter generation framework.
[0067] It is understandable that some API parameters may be interdependent. In the solution of this example, it is possible to determine whether the generated interface parameter values meet the constraints, which helps to ensure the rationality of the simulated test scenario and thus ensure the comprehensiveness and accuracy of the test.
[0068] The solution of the present invention is described below through a specific embodiment. In this embodiment, the test requirements are: testing an APN data dial-up Internet API for 10 minutes, the test scene temperature fluctuates continuously between 30 and 60 degrees, the network signal strength is in the weak network range (such as -70dBm to -90dBm), and packet loss failure is simulated.
[0069] First, the user can write test cases according to the test requirements, and then write test scripts based on the test cases.
[0070] After the test script is written, the test script can be input into the automated test framework to execute the test script using the automated test framework. During the execution of the test script, each flag keyword is parsed using the parameter generation operation. For example, if the flag keyword is network signal strength and the description keyword is weak network, a parameter value (e.g. -70dBm) can be randomly generated in the network signal strength range corresponding to the weak network (i.e. -70dBm to -90dBm). And send it to the corresponding environment simulation tool.
[0071] After the test script is executed, the test result can be obtained, and a test report can be generated based on the test result so that the user can understand the usage of the interface and whether the function is normal.
[0072] According to yet another aspect of the embodiments of the present invention, an electronic device is provided. Figure 2 FIG. 2 shows a schematic block diagram of an electronic device according to an embodiment of the present invention. Figure 2 As shown, the electronic device 200 includes: a processor 210 and a memory 220. The memory 220 stores a computer program, and the processor 210 is used to execute the computer program to implement the above method.
[0073] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is also provided. The storage medium stores a computer program / instruction, and the computer program / instruction implements the above method when executed by a processor. The storage medium may include, for example, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), a USB memory, or any combination of the above storage media. The computer-readable storage medium may be any combination of one or more computer-readable storage media.
[0074] A person skilled in the art can easily understand the implementation structure, working principle and beneficial effects of the electronic device and the computer-readable storage medium by reading the above method, and will not be described in detail for the sake of brevity.
[0075] Although example embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above example embodiments are merely exemplary and are not intended to limit the scope of the present invention thereto. Various changes and modifications may be made therein by one of ordinary skill in the art without departing from the scope and spirit of the present invention. All such changes and modifications are intended to be included within the scope of the present invention as required by the appended claims.
[0076] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0077] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed.
[0078] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0079] Similarly, it should be understood that in order to streamline the present invention and help understand one or more of the various inventive aspects, in the description of the exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, the method of the present invention should not be interpreted as reflecting the following intention: the claimed invention requires more features than the features explicitly stated in each claim. More specifically, as reflected in the corresponding claims, the inventive point is that the corresponding technical problem can be solved with less than all the features of a single disclosed embodiment. Therefore, the claims following the specific embodiment are hereby expressly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present invention.
[0080] Those skilled in the art will understand that, except for mutually exclusive features, all features disclosed in this specification (including the accompanying claims, abstract and drawings) and all processes or units of any method or device disclosed in this specification may be combined in any combination. Unless otherwise explicitly stated, each feature disclosed in this specification (including the accompanying claims, abstract and drawings) may be replaced by an alternative feature that provides the same, equivalent or similar purpose.
[0081] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims, any one of the claimed embodiments may be used in any combination.
[0082] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all functions of some modules in an electronic device according to an embodiment of the present invention. The present invention may also be implemented as a device program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0083] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.
[0084] The above is only a specific embodiment of the present invention or an explanation of a specific embodiment. The protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. The protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. An interface testing method, characterized in that: include: Receive a test script, the test script comprising a plurality of flag keywords and description keywords corresponding to the plurality of flag keywords one by one, each of the plurality of flag keywords being used to represent a name of a different parameter in an interface test, and the description keyword being used to represent a value requirement of the corresponding parameter; Execute the test script to test the interface to be tested, wherein, during the execution of the test script, perform the following parameter generation operations: when a flag keyword in the test script is identified, determine the parameter type of the flag keyword; when the parameter type of the flag keyword is an interface parameter, call a parameter generation framework to parse the flag keyword to generate an interface parameter value based on a description keyword corresponding to the flag keyword; integrate the generated interface parameter value into the test script; Generate a test result of the interface to be tested.
2. The interface testing method according to claim 1, characterized in that: The value requirement is a value range; the calling parameter generation framework parses the flag keyword, including: using the parameter generation framework to perform the following operations: Determine the description keyword corresponding to the flag keyword; When the description keyword is a value range of a corresponding interface parameter, a parameter value of the interface parameter is randomly generated within the value range.
3. The interface testing method according to claim 2, characterized in that: Before the calling parameter generation framework parses the flag keyword, the method further includes: Based on a first selection operation of the user, determining a first keyword template corresponding to the current test scenario from a plurality of preset interface keyword templates; inputting the first keyword template into the parameter generation framework; The step of determining the description keyword corresponding to the flag keyword includes: The description keyword corresponding to the flag keyword is determined from the test script using the first keyword template.
4. The testing method according to claim 1, characterized in that: The parameter generation operation further includes: When the parameter type of the flag keyword is an environment parameter, calling the environment generation framework to parse the flag keyword to generate an environment parameter value based on a description keyword corresponding to the flag keyword; The generated environmental parameter values are sent to a corresponding environmental simulation tool so as to utilize the environmental simulation tool to simulate the interface test environment.
5. The testing method according to claim 4, characterized in that: The value requirement is a value range or a value description; The calling environment generation framework parses the flag keyword, including: Determine the description keyword corresponding to the flag keyword; When the description keyword is a value range of a corresponding environmental parameter, a parameter value of the parameter is randomly generated within the value range; When the description keyword is a value description of the corresponding environment parameter, an environment parameter value corresponding to the value description is generated.
6. The testing method according to claim 5, characterized in that: Before the calling environment generation framework parses the flag keyword, the method further includes: Based on the user's second selection operation, determining a second keyword template corresponding to the current test scenario from a plurality of preset environment keyword templates; inputting the second keyword template into the environment generation framework; The step of determining the description keyword corresponding to the flag keyword includes: The description keyword corresponding to the flag keyword is determined from the test script using the second keyword template.
7. The testing method according to claim 4, characterized in that: The parameter generation operation further includes: When the parameter type of the flag keyword is a fault parameter, the calling environment generation framework parses the flag keyword to determine the fault type based on the description keyword corresponding to the flag keyword; The fault type is simulated using an environmental simulation tool.
8. The method according to claim 1, characterized in that The executing the test script to test the interface to be tested includes: Repeat the test script according to the preset execution times.
9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: A computer program / instruction is stored, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 8 is implemented.