Data-driven testing method, device, equipment and computer-readable storage medium

By receiving data-driven test instructions and obtaining relevant identifiers and parameters, executing test cases and handling exceptions, the problem of insufficient comprehensive and inefficient data-driven test automation testing in the prior art is solved, and more targeted testing and more efficient exception testing are achieved.

CN112667512BActive Publication Date: 2025-05-27HANGZHOU QULIAN TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202011622433.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-30
Publication Date
2025-05-27
Estimated Expiration
2040-12-30

AI Technical Summary

Technical Problem

Existing data-driven test automation tests cannot be fully tested according to the needs of testers, and application data-driven abnormal tests are inefficient.

Method used

By receiving data-driven test instructions, obtain the tester identification and test scenario identification, obtain the corresponding test functions and test parameters, execute the test cases, and make assertions when an exception is caught, exit the current test step, enter the next test step, and finally output the test results.

Benefits of technology

It realizes personalized configuration of test cases, improves the targetedness of data-driven testing, ensures comprehensive data-driven testing, and improves the efficiency of application data-driven abnormal testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112667512B_ABST
    Figure CN112667512B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a data-driven testing method, apparatus, device, and computer-readable storage medium; the data-driven testing method in the embodiments of the present application includes: receiving a data-driven testing instruction, obtaining a tester identifier and a test scenario identifier associated with the data-driven testing instruction; obtaining a test function corresponding to the test scenario identifier, obtaining test parameters corresponding to the tester identifier, inputting the test parameters into the test function to obtain a test case and execute it; when an exception thrown by the test case is caught, making an assertion on the exception, exiting the current test step in the test case, and entering the next test step of the test case; when the test case is executed, outputting a data-driven test result; in the embodiments of the present application, test cases are configured according to the test scenario identifier and the tester identifier, realizing comprehensive data-driven testing and improving the efficiency of data-driven exception testing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of software automated testing, and specifically to a data-driven testing method, device, equipment, and computer-readable storage medium. Background Art

[0002] With the rapid development of computer technology, there are more and more various application software. After the application software is developed, a series of tests need to be carried out on the application software before it can be finally released and put on the market.

[0003] The testing of application software includes: data-driven testing (also known as: black-box testing or functional testing), performance testing, stability testing, etc.; data-driven testing is the basic part of application software testing. If there are problems with data-driven, the entire application software is likely to be unusable; existing data-driven testing solutions are suitable for simple scenarios (such as: numerical operations and simple logical judgments). In data-driven testing, the most complex part is the testing of abnormal situations. Currently, for the testing of abnormal situations in application software, testers conduct targeted testing on possible "unexpected abnormal situations". That is to say, in existing data-driven testing automation testing, testers usually write test cases according to test tasks. Such a data-driven testing method has fixed test cases, can only test simple scenarios, and the test abnormal situations corresponding to the test cases are not complete, and it cannot cover all abnormal situation scenarios in the testing process. In the case of test anomalies, users need to conduct anomaly troubleshooting before subsequent test steps can be carried out, resulting in low data-driven testing efficiency. Summary of the Invention

[0004] The embodiments of the present application provide a data-driven testing method, device, equipment, and computer-readable storage medium, aiming to solve the technical problems that existing data-driven testing automation testing cannot perform comprehensive testing according to the needs of testers, and the current efficiency of data-driven anomaly testing for application programs is relatively low.

[0005] On the one hand, the embodiments of the present application provide a data-driven testing method, and the data-driven testing method includes the following steps:

[0006] Receive a data-driven testing instruction, and obtain the tester identifier and test scenario identifier associated with the data-driven testing instruction;

[0007] Obtain the test function corresponding to the test scenario identifier, obtain the test parameters corresponding to the tester identifier, input the test parameters into the test function, obtain a test case and execute it;

[0008] When an exception thrown by the test case is caught, assert the exception, exit the current test step in the test case, and enter the next test step of the test case;

[0009] When the test case is executed, output the data-driven test result.

[0010] In some embodiments of the present application,

[0011] Before receiving the data-driven test instruction and obtaining the tester identifier and test scenario identifier associated with the data-driven test instruction, the method includes:

[0012] Receive a role setting request, obtain the target role associated with the role setting request, and the role permissions of the target role. Configure the test parameters of the target role according to the role permissions of the target role, and establish a mapping relationship between the target role and the test parameters;

[0013] When it is detected that the background interface of the application is updated, obtain the updated target interface identifier, determine the application function of the interface corresponding to the target interface identifier, obtain the target test function corresponding to the application function, and establish a mapping relationship between the target test function and the test scenario identifier to which the application function belongs.

[0014] In some embodiments of the present application, the obtaining the test function corresponding to the test scenario identifier, obtaining the test parameters corresponding to the tester identifier, inputting the test parameters into the test function, obtaining a test case and executing it includes:

[0015] Obtain the target function included in the test scenario identifier, query the preset function table, and obtain the test function corresponding to the target function;

[0016] Obtain the target role corresponding to the tester identifier, query the preset parameter table, and obtain the test parameters corresponding to the target role and the attributes of the test parameters;

[0017] Input the test parameters into the test function according to the respective attributes of the test parameters to obtain a test case and execute it.

[0018] In some embodiments of the present application, after obtaining the test function corresponding to the test scenario identifier, obtaining the test parameters corresponding to the tester identifier, inputting the test parameters into the test function, obtaining a test case and executing it, the method includes:

[0019] Determine whether the role corresponding to the tester identifier has the execution permission for the target test step to be executed in the test case;

[0020] If the role corresponding to the tester identifier does not have the execution permission for the target test step, an exception prompt message is output;

[0021] If the role corresponding to the tester identifier has the execution permission for the target test step, the test function included in the target test step is executed, and the execution result of the target test step is obtained and output.

[0022] In some embodiments of the present application, when an exception is thrown by the test case, asserting the exception and exiting the current test step of the test case and entering the next test step of the test case includes:

[0023] When an exception is thrown by the test case, query the preset exception data table to determine whether there is an error code corresponding to the exception in the preset exception data table;

[0024] If the preset exception data table does not have the error code corresponding to the exception, a prompt message is output to prompt the user to configure the error code corresponding to the exception and the assertion corresponding to the error code;

[0025] If the preset exception data table has the error code corresponding to the exception, obtain the assertion corresponding to the test code, exit the current test step of the test case, and enter the next test step of the test case.

[0026] In some embodiments of the present application, before receiving the data-driven test instruction and obtaining the tester identifier and test scenario identifier associated with the data-driven test instruction, the method includes:

[0027] When it is detected that the application program is updated, obtain the new target function in the application program;

[0028] Obtain the test function corresponding to the target function, and parse the test function to generate the test parameters corresponding to the test function;

[0029] Associate the test function and the test parameters to obtain the test case corresponding to the target function.

[0030] In some embodiments of the present application, before receiving the data-driven test instruction and obtaining the tester identifier and test scenario identifier associated with the data-driven test instruction, the method includes:

[0031] Extract test parameters from the test case through a predefined test framework, and divide the historical test case into test parameters and test functions;

[0032] Save the test parameters to a preset parameter table according to their respective attributes, and save the test functions to a preset function table according to the types of the test functions.

[0033] On the other hand, an embodiment of the present application further provides a data-driven test device, which includes:

[0034] An identification acquisition module, configured to receive a data-driven test instruction and acquire a tester identification and a test scenario identification associated with the data-driven test instruction;

[0035] An acquisition execution module, configured to acquire a test function corresponding to the test scenario identification, acquire test parameters corresponding to the tester identification, input the test parameters into the test function, obtain a test case and execute it;

[0036] An exception assertion module, configured to assert an exception when the test case throws an exception, exit the current test step in the test case, and enter the next test step of the test case;

[0037] A result output module, configured to output a data-driven test result when the test case is executed.

[0038] On the other hand, an embodiment of the present application further provides a data-driven test device, which includes:

[0039] One or more processors;

[0040] A memory; and

[0041] One or more applications, wherein the one or more applications are stored in the memory and are configured to be executed by the processor to implement the data-driven test method.

[0042] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is loaded by a processor to execute the steps in the data-driven test method.

[0043] In the technical solution of the embodiment of the present application, a data-driven test instruction is received, and the tester identifier and test scenario identifier associated with the data-driven test instruction are obtained; the test function corresponding to the test scenario identifier is obtained, the test parameters corresponding to the tester identifier are obtained, the test parameters are input into the test function, a test case is obtained and executed; when an exception thrown by the test case is captured, the exception is asserted, and the current test step in the test case is exited, and the next test step of the test case is entered; when the test case is executed, a data-driven test result is output; in the embodiment of the present application, the test function is obtained according to the test scenario identifier, and the test parameters are obtained according to the tester identifier, realizing the personalized configuration of the test case, making the data-driven test more targeted. At the same time, an exception is captured during the execution of the test case, and instead of directly jumping out of the test case, the exception is asserted and then jumped to the next step, realizing the comprehensive test of the data-driven and improving the efficiency of the data-driven exception test of the application program. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention, and those skilled in the art can obtain other drawings without creative efforts based on these drawings.

[0045] Figure 1 It is a schematic diagram of the scenario of data-driven testing provided by the embodiment of the present application;

[0046] Figure 2 It is a schematic flowchart of the first embodiment of the data-driven test method provided by the embodiment of the present application;

[0047] Figure 3 It is a schematic flowchart of an embodiment of the permission determination in the data-driven test method provided by the embodiment of the present application;

[0048] Figure 4 It is a schematic flowchart of an embodiment of the exception assertion in the data-driven test method provided by the embodiment of the present application;

[0049] Figure 5 It is a schematic flowchart of an embodiment of the test case creation in the data-driven test method provided by the embodiment of the present application;

[0050] Figure 6 It is a schematic flowchart of an embodiment of the saving of the test function and test parameters in the data-driven test method provided by the embodiment of the present application;

[0051] Figure 7It is a schematic structural diagram of an embodiment of the data-driven testing device provided in the embodiments of the present application;

[0052] Figure 8 It is a schematic structural diagram of an embodiment of the data-driven testing equipment provided in the embodiments of the present application. Detailed implementation manners

[0053] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope included in the present invention.

[0054] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "transverse", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus cannot be understood as a limitation to the present invention. In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of the described features. In the description of the present invention, "a plurality" means two or more, unless otherwise specifically defined.

[0055] In the embodiments of the present application, the term "exemplary" is used to mean "serving as an example, illustration, or explanation". Any embodiment described as "exemplary" in the embodiments of the present application is not necessarily construed as being more preferred or having more advantages than other embodiments. In order for any person skilled in the art to implement and use the present invention, the following description is given. In the following description, details are set forth for the purpose of explanation. It should be understood by those skilled in the art that the present invention can be implemented without these specific details. In other instances, well-known structures and processes are not elaborated in detail to avoid unnecessary details from obscuring the description of the present invention. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope that conforms to the principles and features disclosed in the embodiments of the present application.

[0056] The embodiments of the present application provide a data-driven testing method, device, equipment, and computer-readable storage medium, which will be described in detail below respectively.

[0057] The data-driven testing method in the embodiments of the present invention is applied to a data-driven testing device, which is set in a data-driven testing device. One or more processors, a memory, and one or more application programs are provided in the data-driven testing device. One or more of the application programs are stored in the memory and configured to be executed by the processor to implement the data-driven testing method. The data-driven testing device may be a terminal, such as a mobile phone or a tablet computer. The data-driven testing device may also be a server or a service cluster composed of multiple servers.

[0058] As Figure 1 shown, Figure 1 FIG. is a schematic diagram of a data-driven testing scenario according to an embodiment of the present application. In the data-driven testing scenario of the embodiments of the present invention, a data-driven testing device 100 (the data-driven testing device 100 integrates a data-driven testing device) is included. A computer-readable storage medium corresponding to the data-driven testing runs in the data-driven testing device 100 to execute the steps of the data-driven testing.

[0059] It can be understood that Figure 1 the data-driven testing device in the data-driven testing scenario shown, or the devices included in the data-driven testing device do not constitute a limitation to the embodiments of the present invention. That is, the number of devices, the types of devices included in the data-driven testing scenario, or the number of devices and the types of devices included in each device do not affect the overall implementation of the technical solution in the embodiments of the present invention, and can all be regarded as equivalent replacements or derivatives of the technical solution required to be protected in the embodiments of the present invention.

[0060] The data-driven testing device 100 in the embodiments of the present invention is mainly used for:

[0061] Receiving a data-driven testing instruction, and obtaining a tester identifier and a test scenario identifier associated with the data-driven testing instruction;

[0062] Obtaining a test function corresponding to the test scenario identifier, obtaining test parameters corresponding to the tester identifier, inputting the test parameters into the test function, obtaining a test case and executing it;

[0063] When an exception is thrown by the test case, making an assertion on the exception, exiting the current test step in the test case, and entering the next test step of the test case;

[0064] When the test case is executed, outputting a data-driven testing result.

[0065] In an embodiment of the present invention, the data-driven test device 100 may be an independent data-driven test device, or a network or cluster of data-driven test devices composed of data-driven test devices. For example, the data-driven test device 100 described in the embodiment of the present invention includes, but is not limited to, a computer, a network host, a single network data-driven test device, a set of multiple network data-driven test devices, or a cloud data-driven test device composed of multiple data-driven test devices. Among them, the cloud data-driven test device is composed of a large number of computers or network data-driven test devices based on cloud computing.

[0066] Those skilled in the art can understand that Figure 1 the application environment shown in Figure 1 is only one application scenario of the solution of the embodiment of the present application, and does not constitute a limitation on the application scenario of the solution of the embodiment of the present application. Other application environments may also include more or fewer data-driven test devices than Figure 1 shown in

[0067] or a network connection relationship of data-driven test devices. For example,

[0068] it is understood that only 1 data-driven test device is shown in Figure 1 . It can be understood that the scenario of this data-driven test may also include one or more other data-driven test devices, which are not specifically limited here; the data-driven test device 100 may also include a memory.

[0069] Based on the above scenario of data-driven testing, embodiments of the data-driven testing method are proposed.

[0070] As Figure 2 shown, Figure 2 is a schematic flowchart of the first embodiment of the data-driven test method in the embodiment of the present application. In this embodiment, the data-driven test method includes steps 201-204:

[0071] 201. Receive a data-driven test instruction, and obtain the tester identifier and test scenario identifier associated with the data-driven test instruction.

[0072] The data-driven test method in this embodiment is applied to a data-driven test device. The type of the data-driven test device is not specifically limited. For example, the data-driven test device can be a terminal or a server. In this embodiment, the terminal is taken as an example for illustration.

[0073] It can be understood that the computer program corresponding to the data-driven test method runs independently. The computer program corresponding to the data-driven test method can be directly installed on the terminal to implement data-driven automated testing. In addition, the computer program corresponding to the data-driven test method can also be carried on a third-party application software. When the third-party application software is executed, the computer program corresponding to the data-driven test method can be called to perform data-driven test operations.

[0074] In this embodiment, the terminal receives a data-driven test instruction. The triggering method of the data-driven test instruction is not specifically limited. That is, the data-driven test instruction can be actively triggered by the user. For example, the user enters: "xxx application" on the display interface of the terminal and clicks the test button to actively trigger the data-driven automated test. In addition, the data-driven test instruction can also be automatically triggered by the terminal. For example, the triggering condition for the data-driven test preset in the terminal is: perform a data-driven test on the newly installed application program. The terminal detects the change situation of the application program in real time. When a newly installed application program is detected, the terminal automatically triggers the data-driven test instruction.

[0075] The terminal receives a data-driven test instruction, and the terminal obtains the tester identifier and test scenario identifier associated with the data-driven test instruction. The tester identifier refers to the identifier information that uniquely identifies the data-driven tester. The tester identifier can be the tester's name and the tester's work number. The test scenario identifier refers to the identifier information of the scenario to be tested by the application program. The test occasion identifier can be the page identifier of the application program. For example, the test scenario identifier for the product order placement scenario in the xxx application program is the xxx order placement page. It can be understood that the number of functions to be tested in the test scenario corresponding to the test scenario identifier is not limited. For example, a test scenario identifier can include one function or multiple functions.

[0076] It should be noted that before the data-driven test method in this embodiment is executed, a mapping relationship between a test scenario identifier and a test function is established in advance in the terminal, and a mapping relationship between a tester identifier and test parameters is established in advance in the terminal, so that the terminal can select a test function and test parameters according to the test scenario identifier and the tester identifier respectively, and combine them to form a test case for data-driven testing. Specifically, the steps of establishing the mapping relationship include:

[0077] Step a1: Receive a role setting request, obtain the target role associated with the role setting request and the role permissions of the target role, configure the test parameters of the target role according to the role permissions of the target role, and establish a mapping relationship between the target role and the test parameters;

[0078] Step a2: When it is detected that the background interface of the application program is updated, obtain the updated target interface identifier, determine the application function of the interface corresponding to the target interface identifier, obtain the target test function corresponding to the application function, and establish a mapping relationship between the target test function and the test scenario identifier to which the application function belongs.

[0079] That is, the terminal receives a role setting request, the terminal obtains the target role associated with the role setting request (the target role can be flexibly set according to the data-driven test requirements, for example, the target role is set as: super administrator, repository owner, repository administrator, repository member or other users), and the role permissions of the target role. The terminal configures the test parameters of the target role according to the role permissions of the target role, and the terminal establishes a mapping relationship between the target role and the test parameters. After the terminal obtains the tester identifier, the terminal can determine the role corresponding to the tester identifier according to the tester identifier, and the terminal obtains the test parameters corresponding to the role for targeted testing.

[0080] The terminal monitors the changes of the target application program to be tested in real time. When the terminal detects that the background interface of the application program is updated, the terminal obtains the updated target interface identifier, the terminal determines the application function of the interface corresponding to the target interface identifier. A preset function table is set in the terminal, and different types of functions are included in the preset function table. The terminal obtains the target test function corresponding to the application function, and the terminal establishes a mapping relationship between the target test function and the test scenario identifier to which the application function belongs.

[0081] 202. Obtain the test function corresponding to the test scenario identifier, obtain the test parameters corresponding to the tester identifier, input the test parameters into the test function, obtain a test case and execute it.

[0082] In this embodiment, the terminal obtains the test function corresponding to the test scenario identifier, obtains the test parameters corresponding to the tester identifier, inputs the test parameters into the test function, obtains the test case and executes it. Specifically, it includes:

[0083] 1. Obtain the target function included in the test scenario identifier, query the preset function table, and obtain the test function corresponding to the target function;

[0084] 2. Obtain the target role corresponding to the tester identifier, query the preset parameter table, and obtain the test parameters corresponding to the target role and the attributes of the test parameters;

[0085] 3. Input the test parameters into the test function according to the respective attributes of the test parameters, obtain the test case and execute it.

[0086] That is, there is a preset function table in the terminal. The preset function table contains different types of test functions. The terminal obtains the test function included in the test scenario identifier, queries the preset function table, and obtains the test function corresponding to the target function mapping relationship; there is a preset parameter table in the terminal. The preset parameter table contains different types of test parameters. The preset parameter table can be an excel table. The header of the excel table contains keyword field information, and the excel table contains the test parameters corresponding to each keyword field information; the terminal determines the target role corresponding to the tester identifier, the terminal queries the preset parameter table, and obtains the test parameters corresponding to the target role and the attributes of the test parameters (the attributes of the test parameters refer to the type of the test parameters, the position of the test parameters, the association relationship between the test parameters, etc.); the terminal inputs the test parameters into the test function according to the respective attributes of the test parameters, obtains the test case and executes it.

[0087] 203. When an exception is thrown by the test case, assert the exception, exit the current test step in the test case, and enter the next test step of the test case.

[0088] The terminal detects the execution status of the test case in real time. When an exception is thrown in the test case, the terminal catches the exception and makes an assertion about the exception. That is, different assertions corresponding to different exceptions are pre - saved in the terminal. After the terminal catches the exception, it exits the current test step in the test case and enters the next test step of the test case. For example, when the terminal conducts tests related to the process in an application software, if the previous operation affects the subsequent operation, after detecting that the operation throws an exception, the terminal directly makes an assertion based on the error code corresponding to the exception, and then exits the current test and continues the subsequent test; if the previous operation has no impact on the subsequent operation, the terminal continues to execute the subsequent operations in the test case. The complete process in the application program is operation step 1, operation step 2, operation step 3, and operation step 4. Each operation step depends on the previous operation step. When an expected or unexpected exception occurs in operation step 3, it indicates that the operation fails, and the function directly returns, ending the entire process.

[0089] In this embodiment, the data - driven test is a test related to permissions. Each operation may or may not have permissions, and there is no dependence between steps. Therefore, after each operation is completed, it can be directly compared with the expectation. When an exception is captured, an assertion is made about the error code. For example, if the permissions of user A for operation steps 1, 2, 3, and 4 are {true, true, false, true}, then when an exception is thrown during the execution of operation step 3, an exception judgment can be directly made, and then operation step 4 is continued to verify that the permissions are normal.

[0090] 204. When the test case execution is completed, the data - driven test result is output.

[0091] The terminal detects the execution status of the test case in real time. When the test case execution is completed, the terminal obtains the execution results of the test steps in the test case, aggregates the execution results, and outputs the data - driven test result.

[0092] In the technical solution of the embodiment of the present application, a data-driven test instruction is received, and the tester identifier and test scenario identifier associated with the data-driven test instruction are obtained; the test function corresponding to the test scenario identifier is obtained, the test parameters corresponding to the tester identifier are obtained, the test parameters are input into the test function, a test case is obtained and executed; when an exception thrown by the test case is caught, the exception is asserted, and the current test step in the test case is exited, and the next test step of the test case is entered; when the test case is executed, a data-driven test result is output; in the embodiment of the present application, the test function is obtained according to the test scenario identifier, and the test parameters are obtained according to the tester identifier, realizing personalized configuration of the test case, making the data-driven test more targeted. At the same time, an exception is caught during the execution of the test case, and instead of directly jumping out of the test case, the exception is asserted and then jumped to the next step, realizing a comprehensive test of the data-driven and improving the efficiency of the data-driven exception test of the application program.

[0093] That is, in the embodiment of the present application, an open-source automation testing framework (for example, TestNG) is used for testing. The use case data is maintained in Excel, and a function is encapsulated to read the data therein and pass it to the test function for testing. Specifically, in the way of a test case document plus an automated test project (or test data plus test code), the total test cases are maintained in one document. Similar scenarios use the same process. By separating the key parameters of each use case and making a table; this document is convenient for checking and review. When writing the automated test code, the key parameters of the use cases separated above are passed as parameters to the test function; one Sheet in the test data Excel corresponds to a large test scenario, and the fields in the Sheet correspond to these parameters one by one.

[0094] As Figure 3 shown, Figure 3 is a schematic flowchart of an embodiment of permission determination in the data-driven test method provided in the embodiment of the present application.

[0095] In some embodiments of the present application, when the data-driven test method executes a test case, it includes the following steps 301-303:

[0096] 301. Determine whether the role corresponding to the tester identifier has the execution permission for the target test step to be executed in the test case.

[0097] The terminal obtains the role corresponding to the calibration of the tester, and the terminal determines whether the role corresponding to the tester identifier has the execution permission for the target test step to be executed in the test case, that is, the terminal determines whether the test permission set of the role corresponding to the tester identifier contains the execution permission for the test step in the test case. If the test permission set of the role corresponding to the tester identifier contains the execution permission for the test step in the test case, then the role corresponding to the tester identifier has the execution permission for the target test step; if the test permission set of the role corresponding to the tester identifier does not contain the execution permission for the test step in the test case, then the role corresponding to the tester identifier does not have the execution permission for the target test step.

[0098] 302, if the role corresponding to the tester identifier does not have the execution permission for the target test step, an exception prompt message is output.

[0099] If the role corresponding to the tester identifier does not have the execution permission for the target test step, the terminal outputs an exception prompt message, so that the tester can understand the execution information of the test case.

[0100] 303, if the role corresponding to the tester identifier has the execution permission for the target test step, the test function included in the target test step is executed, and the execution result of the target test step is obtained and output.

[0101] If the role corresponding to the tester identifier has the execution permission for the target test step, the terminal executes the test function included in the target test step, obtains the execution result of the target test step and outputs it. In this embodiment, the test of the application program of the terminal is combined with the permissions of the tester, making the test of the application program more targeted. Different testers execute the test steps corresponding to their test permissions, so that the test scenario and permission management are combined, making the data-driven test more reasonable.

[0102] For example, the test task corresponding to the test scenario identifier is relatively complex, so a single test case often contains more operations. The terminal combines the test cases with similar processes together and numbers the positions of each operation. For example, in the normal and abnormal scenarios, parameters are passed in the form of Pair<>. For normal operations, 0 can be directly passed. In the abnormal scenario, assertions are made on the positions and error codes where an exception is expected to occur. For example, Pair<2, 10201> means that an error is expected to occur at the second operation, and the error code is 10201; in the permission test scenario, parameters are passed in the form of an array. For example, {true, true, false, true} means that the user has operation permissions at the 1st / 2nd / 4th positions and does not have operation permissions at the 3rd position. It is verified that an exception can be normally captured when there is no permission, and the error code is correct.

[0103] Refer to Figure 4 , Figure 4It is a schematic flowchart of an embodiment of an exception assertion in the data-driven testing method provided in the embodiments of the present application.

[0104] In some embodiments of the present application, the processing steps when the terminal captures a test exception during data-driven testing are specifically described, including steps 401-403:

[0105] 401. When an exception thrown by the test case is captured, query the preset exception data table to determine whether there is an error code corresponding to the exception in the preset exception data table.

[0106] The preset exception data table in the terminal refers to an exception data table formed by the tester representing historical exceptions with error codes and the terminal associating the error codes with assertions; when the terminal catches an exception, the terminal queries the preset exception data table to determine whether there is an error code corresponding to the exception in the preset exception data table.

[0107] 402. If there is no error code corresponding to the exception in the preset exception data table, output a prompt message to prompt the user to configure the error code corresponding to the exception and the assertion corresponding to the error code.

[0108] If there is no error code corresponding to the exception in the preset exception data table, the terminal outputs a prompt message to prompt the user to configure the error code corresponding to the exception and the assertion corresponding to the error code. In this embodiment, when there is no error code corresponding to the exception, the terminal outputs a prompt message, enabling the user to flexibly configure the error code corresponding to the exception and the assertion corresponding to the error code, making the data-driven testing more convenient and flexible.

[0109] 403. If there is an error code corresponding to the exception in the preset exception data table, obtain the assertion corresponding to the test code, and exit the current test step of the test case and enter the next test step of the test case.

[0110] If there is an error code corresponding to the exception in the preset exception data table, obtain the assertion corresponding to the test code. Further, the terminal obtains the currently executed test step in the test case, and the terminal determines whether there is an association relationship between the current test step and the subsequent test steps in the test case. If there is an association relationship between the current test step and the subsequent test steps in the test case, exit the test. If there is no association relationship between the current test step and the subsequent test steps in the test case, the terminal exits the current test step of the test case and enters the next test step of the test case. In this embodiment, the terminal can make an assertion on the exception in the test case, enabling the user to understand the execution situation of the test case in real time.

[0111] Refer to Figure 5 , Figure 5It is a schematic flowchart of an embodiment of test case creation in the data-driven test method provided in the embodiments of the present application.

[0112] In some embodiments of the present application, after data-driven testing in this embodiment, test cases are pre-constructed in the terminal. When the terminal performs data-driven testing later, the terminal decomposes the pre-constructed test cases and configures them to form new test cases that meet different test scenarios. The steps of pre-constructing test cases in the terminal are specifically described in this embodiment, including steps 501-503:

[0113] 501. When it is detected that the application is updated, obtain the new target function in the application.

[0114] 502. Obtain the test function corresponding to the target function, and parse the test function to generate the test parameters corresponding to the test function.

[0115] When the terminal detects that the application is updated, the terminal obtains the new target function in the application. In this embodiment, the terminal pre-defines different sets of test functions, obtains the test function corresponding to the target function, parses the test function, obtains the dependent variables in the test function, and the setting rules for each dependent variable. The terminal generates the test parameters corresponding to the test function according to the setting rules for the dependent variables. For example, if the dependent variable is a phone number, the terminal generates a phone number as the test parameter according to the rules for phone numbers.

[0116] 503. Associate the test function and the test parameters to obtain the test case corresponding to the target function.

[0117] The terminal associates the test function and the test parameters to obtain the test case corresponding to the target function. In this embodiment, the terminal combines the test function and the test function to generate the corresponding test parameters, and associates the test parameters and the test function to generate a test case; so that the terminal can parse the generated test case for subsequent data-driven automated testing.

[0118] Refer to Figure 6 , Figure 6 It is a schematic flowchart of an embodiment of saving test functions and test parameters in the data-driven test method provided in the embodiments of the present application.

[0119] In some embodiments of the present application, it is specifically described that the terminal parses the pre-constructed test cases, and the terminal decomposes the test cases into test functions and test parameters, so that the terminal can re-combine the test parameters and test functions later to form new test cases for performing data-driven automated testing. This implementation is the step of decomposing and saving test cases by the terminal, including 601-602:

[0120] 601. Extract test parameters from the test cases through a predefined test framework, and divide the historical test cases into test parameters and test functions.

[0121] A test framework is predefined in the terminal. Different test code automatic running programs are set in the test framework. The terminal extracts test parameters from the test cases through the predefined test framework, and the terminal divides the historical test cases into test parameters and test functions.

[0122] 602. Save the test parameters to a preset parameter table according to their respective attributes, and save the test functions to a preset function table according to the respective types of the test functions.

[0123] The terminal saves the test parameters to a preset parameter table according to their respective attributes, and the terminal saves the test functions to a preset function table according to the respective types of the test functions. In this embodiment, the terminal can save the test parameters and test functions to the preset parameter table and the preset function table respectively to facilitate data-driven automated testing in the later stage.

[0124] For the convenience of understanding, a specific scenario of data-driven testing in the implementation of this application includes:

[0125] 1) First, organize the complete test cases. For example, for the resource library permissions, set the horizontal axis of the table as resource library operations (including viewing the resource library / updating the resource library / adding members / updating members / removing members / deleting the resource library), and the vertical axis as roles (including super administrator / resource library owner / resource library administrator / resource library member / other users), and then mark whether all roles have the corresponding permissions according to the requirement document.

[0126] 2) Then, organize the permission table data into Excel.

[0127] 3) The program reads the data in Excel row by row and passes each group of data to the test function to verify that the relevant permissions meet the expectations.

[0128] 4) If a new role is added / role deleted / role permissions modified in the system requirements, directly add / delete / modify the corresponding rows in the test cases and Excel. The test code does not need to be changed, and the test program automatically reads the data in the Excel when running. For example, the permissions of a module in the application under test mainly include operations such as create / view / modify / upload / download / delete. Since creation is the basis for subsequent operations, a separate test case is specified to perform permission data-driven testing on the creation function; other operations share a data-driven test case. When executing the test case for different users in each round, let the specified user create first and then execute the subsequent operations. All the permissions of a user in a module are used as a set of test data; when there are permissions, the operations are completed normally, and when there are no permissions, an exception is thrown with the status code being the specified value; after obtaining the error message, assert and compare each captured exception status code, and the current test continues.

[0129] 5) If the back-end interface is changed, only the corresponding test function needs to be modified separately, and the data in the Excel does not need to be changed.

[0130] As Figure 7 shown, Figure 7 is a schematic structural diagram of an embodiment of the data-driven test device.

[0131] To better implement the data-driven test method in the embodiments of the present application, based on the data-driven test method, an embodiment of the present application also provides a data-driven test device, and the data-driven test device includes:

[0132] An identification acquisition module 701, configured to receive a data-driven test instruction, and acquire a tester identification and a test scenario identification associated with the data-driven test instruction;

[0133] An acquisition execution module 702, configured to acquire a test function corresponding to the test scenario identification, acquire test parameters corresponding to the tester identification, input the test parameters into the test function, obtain a test case and execute it;

[0134] An exception assertion module 703, configured to, when an exception thrown by the test case is captured, assert the exception, exit the current test step in the test case, and enter the next test step of the test case;

[0135] A result output module 704, configured to output a data-driven test result when the test case is executed.

[0136] In some embodiments of the present application, the data-driven test device includes:

[0137] Receive a role setting request, obtain the target role associated with the role setting request, and the role permissions of the target role. Configure the test parameters of the target role according to the role permissions of the target role, and establish a mapping relationship between the target role and the test parameters;

[0138] When it is detected that the background interface of the application is updated, obtain the updated target interface identifier, determine the application function of the interface corresponding to the target interface identifier, obtain the target test function corresponding to the application function, and establish a mapping relationship between the target test function and the test scenario identifier to which the application function belongs.

[0139] In some embodiments of the present application, the obtaining execution module 702 includes:

[0140] Obtain the target function included in the test scenario identifier, query the preset function table, and obtain the test function corresponding to the target function;

[0141] Obtain the target role corresponding to the tester identifier, query the preset parameter table, and obtain the test parameters corresponding to the target role and the attributes of the test parameters;

[0142] Input the test parameters into the test function according to their respective attributes to obtain test cases and execute them.

[0143] In some embodiments of the present application, the data-driven test device includes:

[0144] Determine whether the role corresponding to the tester identifier has the execution permission for the target test step to be executed in the test case;

[0145] If the role corresponding to the tester identifier does not have the execution permission for the target test step, output an exception prompt message;

[0146] If the role corresponding to the tester identifier has the execution permission for the target test step, execute the test function included in the target test step, and obtain and output the execution result of the target test step.

[0147] In some embodiments of the present application, the exception assertion module 703 includes:

[0148] When an exception thrown by the test case is caught, query the preset exception data table to determine whether there is an error code corresponding to the exception in the preset exception data table;

[0149] If the preset exception data table does not have the error code corresponding to the exception, output a prompt message to prompt the user to configure the error code corresponding to the exception and the assertion corresponding to the error code;

[0150] If the preset exception data table has an error code corresponding to the exception, obtain the assertion corresponding to the test code, exit the current test step of the test case, and enter the next test step of the test case.

[0151] In some embodiments of the present application, the data-driven test device includes:

[0152] When it is detected that the application is updated, obtain the target function newly added in the application;

[0153] Obtain the test function corresponding to the target function, and parse the test function to generate test parameters corresponding to the test function;

[0154] Associate the test function and the test parameters to obtain a test case corresponding to the target function.

[0155] In some embodiments of the present application, the data-driven test device includes:

[0156] Extract test parameters from the test case through a predefined test framework, and divide the historical test case into test parameters and test functions;

[0157] Save the test parameters to a preset parameter table according to their respective attributes, and save the test functions to a preset function table according to the respective types of the test functions.

[0158] In the embodiments of the present application, the data-driven test device receives a data-driven test instruction, obtains the tester identifier and test scenario identifier associated with the data-driven test instruction; obtains the test function corresponding to the test scenario identifier, obtains the test parameters corresponding to the tester identifier, inputs the test parameters into the test function, obtains a test case and executes it; when an exception thrown by the test case is caught, assert the exception, and exit the current test step in the test case, and enter the next test step of the test case; when the test case is executed, output the data-driven test result; in the embodiments of the present application, obtain the test function according to the test scenario identifier, obtain the test parameters according to the tester identifier, realize the personalized configuration of the test case, make the data-driven test more targeted, and at the same time, catch exceptions during the execution of the test case, do not directly jump out of the test case, but assert the exception and then jump to the next step, realizing the comprehensive test of data-driven and improving the efficiency of data-driven exception testing of the application.

[0159] The embodiments of the present invention also provide a data-driven test device, such as Figure 8 shown, Figure 8 is a schematic structural diagram of an embodiment of the data-driven test device provided in the embodiments of the present application.

[0160] The data-driven test device integrates any one of the data-driven test apparatuses provided in the embodiments of the present invention. The data-driven test device includes:

[0161] One or more processors;

[0162] A memory; and

[0163] One or more applications, wherein the one or more applications are stored in the memory and are configured to be executed by the processor to perform the steps in the data-driven test method described in any one of the embodiments of the data-driven test method embodiments above.

[0164] Specifically: The data-driven test device may include components such as a processor 801 with one or more processing cores, a memory 802 with one or more computer-readable storage media, a power supply 803, and an input unit 804. Those skilled in the art can understand that Figure 8 The data-driven test device structure shown in does not constitute a limitation on the data-driven test device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Among them:

[0165] The processor 801 is the control center of the data-driven test device, connecting various parts of the entire data-driven test device through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 802, and calling data stored in the memory 802, it performs various functions of the data-driven test device and processes data, thereby monitoring the data-driven test device as a whole. Optionally, the processor 801 may include one or more processing cores; preferably, the processor 801 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above modem processor may not be integrated into the processor 801 either.

[0166] The memory 802 can be used to store software programs and modules. The processor 801 executes various functional applications and data processing by running the software programs and modules stored in the memory 802. The memory 802 mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the data-driven test device. In addition, the memory 802 can include high-speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices. Correspondingly, the memory 802 can also include a memory controller to provide the processor 801 with access to the memory 802.

[0167] The data-driven test device further includes a power supply 803 for powering each component. Preferably, the power supply 803 can be logically connected to the processor 801 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 803 can also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.

[0168] The data-driven test device may further include an input unit 804, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.

[0169] Although not shown, the data-driven test device may further include a display unit, etc., which will not be elaborated here. Specifically, in this embodiment, the processor 801 in the data-driven test device will load the executable files corresponding to the processes of one or more application programs into the memory 802 according to the following instructions, and the processor 801 will run the application programs stored in the memory 802 to realize various functions as follows:

[0170] Receive a data-driven test instruction, and obtain the tester identification and test scenario identification associated with the data-driven test instruction;

[0171] Obtain the test function corresponding to the test scenario identification, obtain the test parameters corresponding to the tester identification, input the test parameters into the test function, obtain a test case and execute it;

[0172] When an exception is thrown by the test case, assert the exception, exit the current test step in the test case, and enter the next test step of the test case;

[0173] When the execution of the test case is completed, the data-driven test result is output.

[0174] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions or by controlling related hardware through instructions. The instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0175] For this reason, an embodiment of the present invention provides a computer-readable storage medium, which may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), a magnetic disk, an optical disc, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any of the data-driven test methods provided by the embodiments of the present invention. For example, when the computer program is loaded by the processor, the following steps can be executed:

[0176] Receive a data-driven test instruction, and obtain the tester identifier and test scenario identifier associated with the data-driven test instruction;

[0177] Obtain the test function corresponding to the test scenario identifier, obtain the test parameters corresponding to the tester identifier, input the test parameters into the test function, obtain a test case and execute it;

[0178] When an exception thrown by the test case is caught, assert the exception, exit the current test step in the test case, and enter the next test step of the test case;

[0179] When the execution of the test case is completed, the data-driven test result is output.

[0180] In the above embodiments, the descriptions of the various embodiments each have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the detailed descriptions of other embodiments above, and details will not be repeated here.

[0181] In specific implementation, the above-mentioned units or structures can be implemented as independent entities, or can be combined arbitrarily to be implemented as the same or several entities. The specific implementation of the above-mentioned units or structures can refer to the method embodiments above, and details will not be repeated here.

[0182] The specific implementation of the above operations can refer to the previous embodiments, and details will not be repeated here.

[0183] The above has introduced in detail a data-driven testing method provided by an embodiment of the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.

Claims

1. A data-driven testing method, characterized in that, the data-driven testing method includes: Receiving a data-driven test instruction, and obtaining a tester identifier and a test scenario identifier associated with the data-driven test instruction; Obtaining a test function corresponding to the test scenario identifier, obtaining test parameters corresponding to the tester identifier, inputting the test parameters into the test function, obtaining a test case and executing it; When an exception is thrown by the test case, making an assertion on the exception, exiting the current test step in the test case, and entering the next test step of the test case; the step of, when an exception is thrown by the test case, making an assertion on the exception, exiting the current test step in the test case, and entering the next test step of the test case, includes: When an exception is thrown by the test case, querying a preset exception data table to determine whether there is an error code corresponding to the exception in the preset exception data table; If there is no error code corresponding to the exception in the preset exception data table, outputting a prompt message to prompt the user to configure the error code corresponding to the exception and the assertion corresponding to the error code; If there is an error code corresponding to the exception in the preset exception data table, obtaining the assertion corresponding to the test code, exiting the current test step of the test case, and entering the next test step of the test case; When the test case is executed, outputting a data-driven test result.

2. The data-driven testing method according to claim 1, characterized in that, before receiving the data-driven test instruction and obtaining the tester identifier and the test scenario identifier associated with the data-driven test instruction, the method includes: Receiving a role setting request, obtaining a target role associated with the role setting request and the role permissions of the target role, configuring the test parameters of the target role according to the role permissions of the target role, and establishing a mapping relationship between the target role and the test parameters; When it is detected that the background interface of the application program is updated, obtaining the updated target interface identifier, determining the application function of the interface corresponding to the target interface identifier, obtaining the target test function corresponding to the application function, and establishing a mapping relationship between the target test function and the test scenario identifier to which the application function belongs.

3. The data-driven testing method according to claim 1, characterized in that, the step of obtaining a test function corresponding to the test scenario identifier, obtaining test parameters corresponding to the tester identifier, inputting the test parameters into the test function, obtaining a test case and executing it, includes: Obtaining the target function included in the test scenario identifier, querying a preset function table, and obtaining the test function corresponding to the target function; Obtaining the target role corresponding to the tester identifier, querying a preset parameter table, obtaining the test parameters corresponding to the target role and the attributes of the test parameters; inputting the test parameters into the test function according to the respective attributes of the test parameters, obtaining a test case and executing it.

4. The data-driven testing method according to claim 1, characterized in that, After obtaining the test function corresponding to the test scenario identifier, obtaining the test parameters corresponding to the tester identifier, inputting the test parameters into the test function, obtaining a test case and executing it, the method includes: Determine whether the role corresponding to the tester identifier has the execution permission for the target test step to be executed in the test case; if the role corresponding to the tester identifier does not have the execution permission for the target test step, output an exception prompt message; If the role corresponding to the tester identifier has the execution permission for the target test step, execute the test function included in the target test step, obtain the execution result of the target test step and output it.

5. The data-driven test method according to any one of claims 1-4, characterized in that, Before receiving the data-driven test instruction and obtaining the tester identifier and test scenario identifier associated with the data-driven test instruction, the method includes: When detecting an update of the application program, obtain the new target function in the application program; Obtain the test function corresponding to the target function, and parse the test function to generate the test parameters corresponding to the test function; Associate the test function and the test parameters to obtain the test case corresponding to the target function.

6. The data-driven test method according to claim 5, characterized in that, Before receiving the data-driven test instruction and obtaining the tester identifier and test scenario identifier associated with the data-driven test instruction, the method includes: Extract test parameters from the test cases through a predefined test framework, and divide the historical test cases into test parameters and test functions; Save the test parameters to a preset parameter table according to their respective attributes, and save the test functions to a preset function table according to the types of the test functions.

7. A data-driven test device, characterized in that, The data-driven test device includes: An identifier acquisition module, configured to receive a data-driven test instruction and obtain a tester identifier and a test scenario identifier associated with the data-driven test instruction; An acquisition execution module, configured to obtain the test function corresponding to the test scenario identifier, obtain the test parameters corresponding to the tester identifier, input the test parameters into the test function, obtain a test case and execute it; An exception assertion module, configured to assert the exception when catching an exception thrown by the test case, and exit the current test step in the test case and enter the next test step of the test case; The step of asserting the exception when catching an exception thrown by the test case, and exiting the current test step in the test case and entering the next test step of the test case includes: When an exception thrown by the test case is captured, query the preset exception data table to determine whether there is an error code corresponding to the exception in the preset exception data table; if there is no error code corresponding to the exception in the preset exception data table, output a prompt message to prompt the user to configure the error code corresponding to the exception and the assertion corresponding to the error code; if there is an error code corresponding to the exception in the preset exception data table, obtain the assertion corresponding to the test code, exit the current test step of the test case, and enter the next test step of the test case. A result output module, configured to output a data-driven test result when the test case is executed.

8. A data-driven test device characterized in that the data-driven test device includes: one or more processors; a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the data-driven test method according to any one of claims 1 to 6.

9. A computer-readable storage medium characterized in that a computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the data-driven test method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and device for testing program interface

    CN105630685A

  • Automatic scene test platform oriented to task application and method

    CN107273286A

  • Application test method and apparatus, computer device and storage medium

    CN107908543A