Test method and device, computer equipment, readable storage medium and program product
By automatically determining the target test cases from candidate test cases and determining the target input data based on the preset mapping relationship, the problem of low testing efficiency in the prior art is solved, and efficient and accurate acquisition of test results is achieved.
Patent Information
- Application Number
- CN202411759142.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-02-28
AI Technical Summary
In the prior art, it is necessary to manually write test scripts for different test situations, resulting in low testing efficiency.
The target test case is automatically executed to obtain test results by determining the target test case from the candidate test case and determining the target input data based on the preset mapping relationship.
There is no need to manually write test scripts, which improves testing efficiency and achieves efficient and accurate test results.
Smart Images

Figure CN119537247A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to a testing method, apparatus, computer equipment, readable storage medium and program product. Background Art
[0002] With the rapid development of computer technology, the functions of interactive interfaces are becoming increasingly complex and diverse. In order to enable users to use the interactive interface stably, testing based on the interactive interface is an essential link.
[0003] However, currently, it is necessary to manually write corresponding test scripts for different test situations and obtain test results by executing the test scripts. Therefore, the efficiency of the current test method is not high. Summary of the invention
[0004] Based on this, it is necessary to provide a testing method, apparatus, computer equipment, readable storage medium and program product that can improve testing efficiency in response to the above technical problems.
[0005] In a first aspect, the present application provides a testing method, comprising:
[0006] Determine a target test case from the candidate test cases; the target test case includes at least one target test operation based on an interactive interface and execution logic of the target test operation;
[0007] Determine the target input data corresponding to the target test case according to the preset mapping relationship; the preset mapping relationship includes the corresponding relationship between the input data and the test case;
[0008] Execute the target test case according to the target input data and determine the test result of the target test case.
[0009] In one embodiment, executing a target test case according to target input data to determine a test result of the target test case includes:
[0010] According to the current target input data, execute the target test case corresponding to the current target input data;
[0011] If an unexpected error occurs in the target test case corresponding to the current target input data, the test is stopped to obtain the test result;
[0012] If the target test case corresponding to the current target input data does not have unexpected errors, the next target input data will be used as the current target input data, and the steps of executing the target test case corresponding to the current target input data will be returned according to the current target input data until all target test cases corresponding to the target input data are executed to obtain the test results.
[0013] In one embodiment, the method further comprises:
[0014] In response to a first editing operation based on the graphical editing interface, determining an editing test operation from a plurality of candidate test operations;
[0015] In response to a second editing operation based on the editing test operation in the graphical editing interface, an execution logic of the editing test operation is determined to obtain a candidate test case.
[0016] In one embodiment, executing a target test case according to target input data to determine a test result of the target test case includes:
[0017] Determine performance parameters of target test operations during execution of target test cases;
[0018] Determine the test results of the target test cases based on the performance parameters.
[0019] In one embodiment, the method further comprises at least one of the following:
[0020] According to a plurality of preset input rules, generating candidate input data corresponding to each preset input rule;
[0021] Generate candidate input data according to a preset generation algorithm;
[0022] Determine candidate input data according to the type of preset test case, at least one item of preset input data, and the intelligent model.
[0023] In one embodiment, the method further comprises:
[0024] In response to a mapping operation based on the candidate input data and the candidate test case, a preset mapping relationship is determined.
[0025] In a second aspect, the present application also provides a testing device, comprising:
[0026] A first determination module is used to determine a target test case from candidate test cases; the target test case includes at least one target test operation based on an interactive interface and execution logic of the target test operation;
[0027] A second determination module is used to determine the target input data corresponding to the target test case according to a preset mapping relationship; the preset mapping relationship includes a correspondence between the input data and the test case;
[0028] The third determination module is used to execute the target test case according to the target input data and determine the test result of the target test case.
[0029] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any of the above methods when executing the computer program.
[0030] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of any of the above methods when executed by a processor.
[0031] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of any of the above methods when executed by a processor.
[0032] The above-mentioned test method, apparatus, computer equipment, readable storage medium and program product can determine the target test case from the candidate test cases. Since the preset mapping relationship includes the corresponding relationship between the input data and the test case, the target input data corresponding to the target test case can be determined according to the preset mapping relationship. Furthermore, since the target test case includes at least one target test operation based on the interactive interface and the execution logic of the target test operation, after executing the target test case according to the target input data, the test result of the target test case can be determined efficiently and accurately. In this process, there is no need to write corresponding test scripts separately for different test situations, nor is there a need to execute test scripts. Instead, the target test case is executed automatically, thereby improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0034] FIG1 is an application environment diagram of a test method in one embodiment;
[0035] Figure 2 A schematic diagram of a test method in one embodiment;
[0036] Figure 3 A schematic diagram of a process for determining a test result in an embodiment;
[0037] Figure 4 A schematic diagram of a process for determining a target test case in an embodiment;
[0038] Figure 5 A schematic diagram of a process for determining a test result in an embodiment;
[0039] Figure 6 A schematic diagram of mapping in one embodiment;
[0040] Figure 7 A process schematic diagram of a testing method in an embodiment;
[0041] Figure 8 is an execution flow chart of a test method in an embodiment;
[0042] Fig. 9 FIG. 4 is a structural block diagram of a testing device in an embodiment. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0044] At present, most of the applications in the front-end interactive interface are single-page applications built using frameworks such as the Vue framework. The front-end relies on the actual return of the back-end to display on the interactive interface. At the same time, the front-end also interacts with the back-end through a series of form inputs and button clicks, waiting for the back-end to return the results, and then displays the corresponding results on the interactive interface. In the related technology, it is usually necessary to manually write corresponding test scripts for different test situations, and obtain test results by executing the test scripts. Therefore, the current testing method is not efficient. Based on this, it is necessary to provide an efficient testing method, which will be introduced below.
[0045] FIG. 1 is an application environment diagram of a test method in an embodiment. In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG. The computer device includes a processor, a memory, an input / output interface (I / O for short) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store relevant data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a test method is implemented.
[0046] Those skilled in the art will understand that the structure shown in FIG. 1 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0047] This embodiment uses the method applied to a terminal as an example for illustration. It is understandable that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. The terminal can be, but is not limited to, various personal computers, laptops, smart phones, and tablet computers. The server can be implemented as an independent server or a server cluster consisting of multiple servers.
[0048] Figure 2 FIG. 1 is a flow chart of a test method in an embodiment. In an exemplary embodiment, Figure 2 As shown, a testing method is provided, which is described by taking the method applied to the computer device in FIG. 1 as an example, and includes the following S201 to S203.
[0049] S201, determining a target test case from candidate test cases; the target test case includes at least one target test operation based on an interactive interface and execution logic of the target test operation.
[0050] In this embodiment, the computer device can determine candidate test cases. The candidate test cases can be stored in the computer device or in other devices that can communicate with the computer device, and this embodiment does not limit this. Candidate test cases are test cases that are set in advance. Test cases refer to descriptions of test tasks for a specific software product, which embody test plans, methods, techniques, and strategies. Each candidate test case includes at least one test operation based on an interactive interface and the execution logic of the test operation.
[0051] The test operation can be an interactive operation or a verification operation. Among them, the interactive operation refers to the interactive operation initiated based on the interactive interface, including but not limited to scrolling, form input, clicking and other operations in the interactive interface. The verification operation refers to the operation of verification based on the features in the interactive interface, including but not limited to user identity authentication, data accuracy verification, permission verification, information comparison, error prompts and other operations. Further optionally, when performing interactive operations, the Web single-page application generally has corresponding feedback features in the interactive interface. Therefore, the computer device can encapsulate the feedback features corresponding to the interactive operation into a verification operation, which is conducive to verifying the interactive operation.
[0052] Exemplarily, the computer device may include a test engine module, the test engine module includes at least one test operation, and each test operation is encapsulated on an application programming interface (Application Programming Interface, API) provided by puppeteer.
[0053] The execution logic of the test operation can characterize the pipeline for executing the test operation. The execution logic may include the input, output, execution steps, conditional branches, loop control, exception handling and other logic of the test operation. Exemplarily, the computer device may include a process configuration module, and the user may configure the execution logic of the test operation through the process configuration module to obtain candidate test cases.
[0054] Further, when a test is required, the computer device determines a target test case from the candidate test cases. Exemplarily, the computer device may display each candidate test case for the user to specify, and then use the candidate test case specified by the user as the target test case. The computer device may also select a candidate test case from the candidate test cases as the target test case according to a certain rule or randomly, and the present embodiment is not limited thereto.
[0055] It is understandable that, since the target test case is a test case determined from the candidate test cases, the target test case includes at least one target test operation based on an interactive interface and the execution logic of the target test operation, wherein the interactive interface includes but is not limited to a web front-end page.
[0056] Exemplarily, the candidate test cases may include test case A, test case B, and test case C. Test case A may include interaction operation A, interaction operation B, and corresponding execution logic. Test case B may include interaction operation A, verification operation A, and corresponding execution logic. Test case C may include interaction operation B and corresponding execution logic. Assuming that the target test case is test case A, the target test operations are interaction operation A and interaction operation B, and the execution logic of the target test operation is also the execution logic of interaction operation A and interaction operation B.
[0057] S202, determining target input data corresponding to a target test case according to a preset mapping relationship; the preset mapping relationship includes a correspondence relationship between input data and test cases.
[0058] In this embodiment, the computer device can determine the preset mapping relationship between the input data and the test case, wherein the preset mapping relationship can be a mapping relationship sent to the computer device by other devices, a mapping relationship determined by the computer device, or a mapping relationship specified by the user.
[0059] Further optionally, the preset mapping relationship may include a correspondence between input data and a test operation in a test case. It should be noted that a test case may correspond to multiple input data, and each input data corresponds to a test operation in the test case. The input data corresponding to different test cases may be the same, different, or partially the same, and this embodiment does not limit this.
[0060] That is, the candidate test cases may be mapped with corresponding candidate input data. Exemplarily, in the preset mapping relationship: test case A corresponds to input data A and input data B, wherein the interaction operation A in test case A corresponds to input data A, and the interaction operation B in test case A corresponds to input data B. Test case B corresponds to input data C, wherein the interaction operation A in test case B corresponds to input data C. Test case C does not require data input, so test case C may not have corresponding input data.
[0061] Furthermore, after determining the target test case, the computer device can determine the target input data corresponding to the target test case according to the preset mapping relationship. Continuing with the above example, taking the target test case as test case A, the computer device determines the target input data as input data A and input data B.
[0062] S203, executing the target test case according to the target input data, and determining the test result of the target test case.
[0063] In this embodiment, the test result can characterize the execution of the target test case. The test result may include the success or failure of the target test case. If the target test case fails to execute, the test result may also include the abnormal target test operation, the abnormal reason, etc., which is not limited in this embodiment.
[0064] After the computer device determines the target test case and the target input data corresponding to the target test case, the target test case can be executed according to the target input data. Optionally, the computer device executes the target test operation in the interactive interface according to the target input data and the execution logic of the target test operation in the target test case. Furthermore, during the process of the computer device executing the target test operation in the interactive interface, the test result of the target test case can be determined by monitoring the interactive interface.
[0065] Exemplarily, during the process of the computer device executing the target test case according to the target input data, if an exception occurs in the target test case, the interactive page at the time of the exception can be obtained as the test result through the webpage screenshot function of puppeteer.
[0066] In some embodiments, the computer device outputs the test results in a preset format, where the preset format includes but is not limited to a portable document format (PDF).
[0067] In the above-mentioned test method, the target test case can be determined from the candidate test cases. Since the preset mapping relationship includes the corresponding relationship between the input data and the test case, the target input data corresponding to the target test case can be determined according to the preset mapping relationship. Furthermore, since the target test case includes at least one target test operation based on the interactive interface and the execution logic of the target test operation, after executing the target test case according to the target input data, the test result of the target test case can be determined efficiently and accurately. In this process, there is no need to write corresponding test scripts separately for different test situations, nor is there a need to execute test scripts. Instead, the target test case is executed automatically, thereby improving the test efficiency.
[0068] Figure 3 FIG. 1 is a flow chart of determining a test result in an embodiment. In an exemplary embodiment, as shown in FIG. Figure 3 As shown, S203 includes S301 to S303.
[0069] S301, executing a target test case corresponding to the current target input data according to the current target input data.
[0070] In this embodiment, the number of target input data is multiple. The computer device needs to determine the current target input data. Optionally, the computer device can determine the current target input data from each target input data in sequence, or randomly select one from untested target input data as the current target input data, or the user can specify the current target input data.
[0071] Then, the computer device will execute the target test case corresponding to the current target input data according to the current target input data. For example, the computer device executes the test operation in test case A in the interactive interface according to input data 1 and the execution logic of the test operation in test case A.
[0072] For example, taking the target test case as test case A, assuming that test case A corresponds to 20 input data, recorded as input data 1 to input data 20, the computer device can use input data 1 as the current target input data in the order of input data 1 to input data 20.
[0073] S302: If an unexpected error occurs in the target test case corresponding to the current target input data, the test is stopped to obtain the test result.
[0074] In this embodiment, the unexpected error refers to an error outside the preset error range, and the preset error range can be set in advance according to requirements. For example, the user can list in advance the errors that may occur during the execution of the target test case as the preset error range.
[0075] Further optionally, the computer device may determine whether an unexpected error occurs according to the element features of the interactive interface during the execution of the target test case. For example, the computer device may obtain the element features of the interactive interface page during the execution of the target test case through the API provided by puppeteer, and determine whether an unexpected error occurs in the target test case according to the element features.
[0076] In the process of executing the target test case corresponding to the current target input data according to the current target input data, if the target test case corresponding to the current target input data has an unexpected error, it means that there may be a problem with the configured target test case. In this case, the computer device will immediately stop the test and obtain the corresponding test result. Exemplarily, the test result may include the interactive page when the unexpected error occurs obtained through the webpage screenshot function of puppeteer.
[0077] S303, if the target test case corresponding to the current target input data does not have an unexpected error, the next target input data is used as the current target input data, and the step of executing the target test case corresponding to the current target input data is returned according to the current target input data, until all target test cases corresponding to the target input data are executed to obtain the test result.
[0078] In this embodiment, no unexpected error occurs, which may be that the target test case is executed normally, or that an expected error occurs in the target test case, wherein the expected error refers to an error within a preset error range.
[0079] If the target test case corresponding to the current target input data does not have an unexpected error, the computer device will continue to determine the next target input data. The process of determining the next target input data is similar to the process of determining the current target input data, and will not be repeated here.
[0080] Then, the computer device uses the next target input data as the current target input data, and returns to step S301 until all target test cases corresponding to the target input data are executed to obtain the test result. In other words, after the computer device uses the next target input data as the current target input data, it will continue to execute the target test case corresponding to the current target input data. If an unexpected error occurs in the target test case corresponding to the current target input data, the test will still be stopped to obtain the test result. If no unexpected error occurs in the target test case corresponding to the current target input data, the next target input data will continue to be determined, and the next target input data will be used as the current target input data to continue to execute the target test case corresponding to the current target input data. This process is repeated until all target test cases corresponding to the target input data are executed to obtain the test result.
[0081] Continuing with the above example, the computer device first executes test case A corresponding to input data 1 according to input data 1. If no unexpected error occurs during the execution of test case A corresponding to input data 1, the computer device will continue to execute test case A corresponding to input data 2 according to input data 2. If no unexpected error occurs during the execution of test case A corresponding to input data 2, the computer device will continue to execute test case A corresponding to input data 3 according to input data 3, and so on. As long as no unexpected error occurs during the execution process, the computer device will continue to use the next target input data as the current target input data until the test case A corresponding to input data 20 is executed according to the last input data 20 to obtain the test result.
[0082] If an unexpected error occurs during the execution, the computer device will immediately stop the test. Assuming that an unexpected error occurs during the execution of test case A corresponding to input data 3, the computer device will stop the test and obtain the test result.
[0083] In the above embodiment, since the target test case corresponding to the current target input data can be executed according to the current target input data, when an unexpected error occurs in the target test case corresponding to the current target input data, the test is stopped in time to obtain the test result; and when the target test case corresponding to the current target input data does not occur in the unexpected error, the next target input data is used as the current target input data, and the step of executing the target test case corresponding to the current target input data according to the current target input data is returned until the target test cases corresponding to all the target input data are executed to obtain the test result. Therefore, the target test case can be automatically executed according to the target input data to efficiently determine the test result of the target test case.
[0084] Figure 4FIG. 1 is a flow chart of determining a target test case in an embodiment. In an exemplary embodiment, as shown in FIG. Figure 4 As shown, the above test method also includes S401 to S402.
[0085] S401 , in response to a first editing operation based on a graphic editing interface, determining an editing test operation from a plurality of candidate test operations.
[0086] In this embodiment, the computer device can enter the graphic editing interface. For example, the computer device can enter the graphic editing interface through a preset website or through a preset program, but this embodiment is not limited thereto.
[0087] A plurality of candidate test operations may be displayed in the graphical editing interface. Exemplarily, the candidate test operations may be all or part of the test operations in the test engine module.
[0088] Then, the user can initiate a first editing operation based on the graphical editing interface. The first editing operation is to determine an editing test operation from multiple candidate test operations, which may include but is not limited to a mouse click operation, a keyboard selection operation, a gesture confirmation operation, and a voice selection operation.
[0089] Furthermore, the computer device can determine an edit test operation from a plurality of candidate test operations in response to the first edit operation. The edit test operation is a test operation that is currently required to be edited and is determined by the user from the candidate test operations.
[0090] For example, assuming that interaction operation A, interaction operation B, interaction operation C, verification operation A, verification operation B... and other test operations are displayed in the first area of the graphical editing interface, the user can drag interaction operation A to the second area to initiate a first editing operation. In this way, the computer device determines that interaction operation A is an editing test operation from multiple candidate test operations in response to the first editing operation.
[0091] It should be noted that, in the above, the editing test operation includes one test operation as an example, and the editing test operation may also include multiple test operations.
[0092] S402, in response to a second editing operation based on the editing test operation in the graphical editing interface, determining an execution logic of the editing test operation to obtain a candidate test case.
[0093] In this embodiment, the user can continue to initiate a second editing operation for the edit test operation, and the second editing operation is used to determine the execution logic of the edit test operation. This embodiment does not limit the form of the second editing operation. For example, the user can add conditional branches, loop control, exception handling and other execution logic to the edit test operation through a graphical second editing operation. In this way, the computer device can determine the execution logic of the edit test operation in response to the second editing operation for the edit test operation in the graphical editing interface.
[0094] Further, after determining the edit test operation and the execution logic of the edit test operation, a candidate test case is obtained. In this way, through the graphical editing interface, the user can customize at least one candidate test case.
[0095] In the above embodiment, since it is possible to determine an editing test operation from multiple candidate test operations in response to a first editing operation based on a graphical editing interface, and to determine the execution logic of the editing test operation in response to a second editing operation for the editing test operation in the graphical editing interface to obtain candidate test cases, users can define candidate test cases efficiently and flexibly.
[0096] Figure 5 FIG. 1 is a flow chart of another method for determining a test result in an embodiment. In an exemplary embodiment, as shown in FIG. Figure 5 As shown, S203 includes S501 to S502.
[0097] S501, determining performance parameters of a target test operation during execution of a target test case.
[0098] In this embodiment, the performance parameters include but are not limited to parameters characterizing the performance of the target test operation, such as the loading time, loading speed, resource request status, resource occupancy status, etc., of executing the target test operation in the interactive interface.
[0099] Optionally, the computer device may monitor the performance parameters of each target test operation during the execution of the target test case. Assuming that test case A includes interactive operation A and interactive operation B, during the execution of test case A, the computer device will monitor the performance parameters of interactive operation A and the performance parameters of interactive operation B.
[0100] S502: Determine the test result of the target test case according to the performance parameter.
[0101] Further, the computer device can determine the test result of the target test case according to the performance parameter. Optionally, the test result can include the performance parameter of the target test operation. In some embodiments, the computer device can also score or grade the performance of the target test case according to the performance parameter to reflect the score or grade in the test result.
[0102] Continuing with the above example, the test result of test case A may include whether test case A is executed successfully, the loading time and resource usage of interactive operation A in test case A, and the loading time and resource usage of interactive operation B in test case A.
[0103] In the above embodiment, since the performance parameters of the target test operation during the execution of the target test case can be determined and the test result of the target test case can be determined according to the performance parameters, the performance analysis of the target test case can be carried out based on the test result.
[0104] In some application scenarios, input data can be reused, so in an exemplary embodiment, optionally, the computer device can determine candidate input data. Exemplarily, the computer device can include a use case input management module, which is used to generate and store multiple candidate input data.
[0105] In an exemplary embodiment, optionally, the above test method may further include at least one of the following:
[0106] (1) According to a plurality of preset input rules, candidate input data corresponding to each preset input rule is generated.
[0107] In this embodiment, the preset input rule is a rule for limiting input data, which can be used to specify parameters such as the format, length, range, and type of the input data.
[0108] The preset input rule can be an input rule specified by the user, or an input rule determined by the computer device according to a test operation, or an input rule obtained by the computer device based on the separation of form input items. For example, if a form input item needs to be limited to a length of 1-10 and does not contain characters, the computer device can separate and obtain preset input rule 1 within a length of 1-10 and preset input rule 2 that does not contain characters. In this way, candidate input data corresponding to different preset input rules can form a form input. On the one hand, the uniformity of verification can be guaranteed based on the preset input rules, and on the other hand, the efficiency of generating candidate input data of the form can be improved.
[0109] Furthermore, the computer device can generate candidate input data corresponding to each preset input rule based on multiple preset input rules. Optionally, the computer device can traverse the candidate input data corresponding to each preset input rule according to the preset input rules. For example, for preset input rule 1 of length 1-10, the computer device can generate candidate input data of length 1, candidate input data of length 2, ... candidate input data of length 10, and so on.
[0110] (2) Generate candidate input data according to the preset generation algorithm.
[0111] In this embodiment, the preset generation algorithm includes but is not limited to a random generation algorithm, an arithmetic sequence algorithm, a Poisson distribution algorithm, a normal distribution algorithm, and a Fibonacci sequence algorithm. In this way, the computer device can generate candidate input data based on the preset generation algorithm.
[0112] (3) Determine candidate input data based on the type of preset test case, at least one item of preset input data, and the intelligent model.
[0113] In this embodiment, the computer device can determine the type of preset test case and / or preset input data. The preset test case can be understood as an existing test case. For example, the computer device can use the generated candidate test case as the preset test case and determine the type of the preset test case. Further optionally, the computer device can determine the type of the preset test case through a recognition algorithm, and the computer device can also receive the type of the preset test case input by the user. The preset input data can be understood as existing input data. For example, the computer device can use the generated candidate input data as the preset input data.
[0114] Furthermore, the computer device can determine the candidate input data according to the type of the preset test case, at least one of the preset input data and the intelligent model. Among them, the intelligent model can be a supervised learning model, a semi-supervised learning model, an unsupervised learning model, etc. Exemplarily, the intelligent model can include but is not limited to a convolutional neural network (CNN) model, a recurrent neural network (RNN), a fully convolutional neural network (FCN) model, a generative adversarial network (GAN) model, a back-propagation (BP) machine learning model, a radial basis function (RBF) model, a deep belief network (DBN) model, an Elman model, or at least one of their combined models.
[0115] Optionally, the computer device may input the type of a preset test case into the intelligent model to obtain candidate input data output by the intelligent model. In this case, the intelligent model may be trained based on the type sample of the test case and the corresponding input data label.
[0116] Optionally, the computer device may input preset input data into the intelligent model, and the intelligent model may perform reinforcement learning based on the preset input data to output candidate input data.
[0117] In some embodiments, the computer device may also input preset input data and preset test case types into the intelligent model, and the intelligent model outputs candidate input data.
[0118] In one embodiment, the intelligent model is used to generate candidate input data with a coverage greater than a preset coverage rate and / or a fault detection rate greater than a preset fault detection rate.
[0119] In the above embodiment, since the candidate input data can be determined by at least one of the above methods, the flexibility and generation efficiency of the candidate input data are improved.
[0120] In an exemplary embodiment, optionally, the above test method may further include the following steps:
[0121] In response to a mapping operation based on the candidate input data and the candidate test case, a preset mapping relationship is determined.
[0122] In this embodiment, the user can associate the candidate input data with the candidate test case through a mapping operation to determine the preset mapping relationship. Optionally, the mapping operation can be an operation based on a graphical editing interface. For example, the user can bind the test case A with the input data 1 to the input data 20 through the graphical editing interface to initiate a mapping operation, and then the computer device can respond to the mapping operation to determine that the test case A corresponds to the input data 1 to the input data 20, that is, to determine the preset mapping relationship.
[0123] In this way, the computer device selects one of the candidate test cases as the target test case, and uses the candidate input data corresponding to the selected candidate test case as the target input data according to the preset mapping relationship.
[0124] Figure 6 FIG. 1 is a schematic diagram of mapping in an embodiment, such as Figure 6 As shown, the computer device can map the input data with the fields in the test case through the process configuration module, so as to use the mapped target test case and target input data as the input of the test engine module, so that the test engine module executes the target test case according to the target input data and determines the test result of the target test case.
[0125] In the above embodiment, since the preset mapping relationship can be determined in response to the mapping operation based on the candidate input data and the candidate test cases, the user can flexibly bind the input data to the test cases.
[0126] In order to more clearly introduce the test method of this application, Figure 7 and Figure 8 Provide explanation. Figure 7 Schematic diagram of the process of the test method in one embodiment. Figure 7 As shown, the computer device can execute the test method according to the following process.
[0127] S701 , in response to a first editing operation based on a graphic editing interface, determining an editing test operation from a plurality of candidate test operations.
[0128] S702, in response to a second editing operation based on the editing test operation in the graphical editing interface, determining an execution logic of the editing test operation to obtain a candidate test case.
[0129] S703, determining candidate input data. The candidate input data may be determined according to at least one of the following: (1) generating candidate input data corresponding to each preset input rule according to a plurality of preset input rules; generating candidate input data according to a preset generation algorithm; determining candidate input data according to a type of a preset test case, at least one of the preset input data, and an intelligent model.
[0130] S704, in response to a mapping operation based on the candidate input data and the candidate test case, determining a preset mapping relationship.
[0131] S705, determining a target test case from the candidate test cases, wherein the target test case includes at least one target test operation based on an interactive interface and execution logic of the target test operation.
[0132] S706: Determine the target input data corresponding to the target test case according to the preset mapping relationship.
[0133] S707, executing the target test case corresponding to the current target input data according to the current target input data.
[0134] S708: If an unexpected error occurs in the target test case corresponding to the current target input data, the test is stopped to obtain the test result.
[0135] S709, if the target test case corresponding to the current target input data does not have an unexpected error, the next target input data is used as the current target input data, and the process returns to S707 until all target test cases corresponding to the target input data are executed to obtain a test result. The test result of the target test case can be determined based on the performance parameters of the target test operation during the execution of the target test case.
[0136] The processes of S701 to S709 may refer to the above-mentioned embodiment and will not be described in detail here.
[0137] Figure 8 is an execution flow chart of a test method in an embodiment, such as Figure 8 As shown, the target test case may include multiple interactive operations, multiple verification operations, and execution logic between each interactive operation and verification operation. For example, the target test case indicates that the interactive operation, ..., interactive operation, verification operation, ..., verification operation need to be executed based on the initial state of the interactive interface.
[0138] Please refer to Figure 8 It is understandable that multiple interactive operations can be configured in the target test case, followed by one or more verification operations to verify the correctness of the previous operations. After the verification operation, the interactive operation and the verification operation can be configured. This configuration repeatedly performs the interactive operation and the verification operation, which can simulate the process of manually executing the test case.
[0139] In one embodiment, if multiple input data need to be verified, the target test case may need to be executed multiple times. Therefore, the operation start state and the operation end state of the target test case need to be consistent for cyclic execution.
[0140] Please continue to refer to Figure 8 In one embodiment, first, the test engine module in the computer device opens the website and enters the initial state of the page of the interactive interface. Then, the test engine module determines the target test case from the candidate test cases, and determines a target input data corresponding to the target test case according to the preset mapping relationship to execute the target test case corresponding to the current target input data. If an unexpected error occurs in the target test case corresponding to the current target input data, the test is terminated directly to determine the test result. If no unexpected error occurs in the target test case corresponding to the current target input data, the next target input data corresponding to the target test case is used as the current target input data to execute the target test case corresponding to the current target input data, and so on.
[0141] Furthermore, since there may be multiple target input data, the test engine module will perform loop jumps in time during the execution of the target test case. For example, Figure 8 The initial state of the interactive interface will be returned from the interactive operation, and the interactive operation will be returned from the verification operation. It can be understood that when the target input data traversal is completed, the execution of the target test case is completed, and the loop jump of the target test case is ended.
[0142] It can be seen that in the test method provided by this application, first, it is possible to execute test cases for the front-end functions of Web applications through automated tools to replace the manual testing process, so as to significantly improve the test efficiency, reduce human errors, accelerate the iteration speed, and ensure the software quality. Second, the relevant interaction logic is abstracted, the test operation is divided into interactive operations and verification operations, and the atomization of the test operation is realized, which is conducive to configuration based on the test operation. Third, there is no need to write a separate test script every time. The target test case can be automatically executed through various operation configurations, which especially improves the test efficiency of Web single-page applications.
[0143] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0144] Based on the same inventive concept, the embodiment of the present application also provides a test device for implementing the test method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more test device embodiments provided below can refer to the limitations on the test method above, and will not be repeated here.
[0145] Fig. 9 FIG. 1 is a structural block diagram of a test device in an embodiment. In an exemplary embodiment, as shown in FIG. Fig. 9 As shown, a testing device 900 is provided, comprising: a first determining module 901, a second determining module 902 and a third determining module 903, wherein:
[0146] The first determination module 901 is used to determine a target test case from candidate test cases; the target test case includes at least one target test operation based on an interactive interface and execution logic of the target test operation.
[0147] The second determination module 902 is used to determine the target input data corresponding to the target test case according to a preset mapping relationship; the preset mapping relationship includes the correspondence between the input data and the test case.
[0148] The third determination module 903 is used to execute the target test case according to the target input data and determine the test result of the target test case.
[0149] In the above-mentioned test device, the target test case can be determined from the candidate test cases. Since the preset mapping relationship includes the corresponding relationship between the input data and the test case, the target input data corresponding to the target test case can be determined according to the preset mapping relationship. Furthermore, since the target test case includes at least one target test operation based on the interactive interface and the execution logic of the target test operation, after executing the target test case according to the target input data, the test result of the target test case can be determined efficiently and accurately. In this process, there is no need to write corresponding test scripts separately for different test situations, nor is there a need to execute test scripts. Instead, the target test case is executed automatically, thereby improving the test efficiency.
[0150] Optionally, the third determining module 903 includes:
[0151] The execution unit is used to execute the target test case corresponding to the current target input data according to the current target input data.
[0152] The stop unit is used to stop the test and obtain the test result if an unexpected error occurs in the target test case corresponding to the current target input data.
[0153] The loop unit is used to use the next target input data as the current target input data if no unexpected error occurs in the target test case corresponding to the current target input data, and return to the step of executing the target test case corresponding to the current target input data according to the current target input data until all the target test cases corresponding to the target input data are executed to obtain the test results.
[0154] Optionally, the testing device 900 further includes:
[0155] a fourth determination module, configured to determine an edit test operation from a plurality of candidate test operations in response to a first edit operation based on the graphical editing interface;
[0156] The fifth determination module is used to determine the execution logic of the edit test operation in response to the second edit operation based on the graphical editing interface for the edit test operation, so as to obtain a candidate test case.
[0157] Optionally, the third determining module 903 includes:
[0158] The first determining unit is used to determine the performance parameters of the target test operation during the execution of the target test case.
[0159] The second determining unit is used to determine the test result of the target test case according to the performance parameter.
[0160] Optionally, the testing device 900 is further used for at least one of the following:
[0161] According to a plurality of preset input rules, generating candidate input data corresponding to each preset input rule;
[0162] Generate candidate input data according to a preset generation algorithm;
[0163] Determine candidate input data according to the type of preset test case, at least one item of preset input data, and the intelligent model.
[0164] Optionally, the testing device 900 further includes:
[0165] The sixth determination module is used to determine a preset mapping relationship in response to a mapping operation based on candidate input data and candidate test cases.
[0166] Each module in the above-mentioned test device can be implemented in whole or in part by software, hardware and a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0167] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0168] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0169] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0170] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0171] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0172] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A testing method, characterized in that: The method comprises: Determine a target test case from the candidate test cases; the target test case includes at least one target test operation based on an interactive interface and execution logic of the target test operation; Determine the target input data corresponding to the target test case according to a preset mapping relationship; the preset mapping relationship includes a correspondence between input data and test cases; The target test case is executed according to the target input data to determine a test result of the target test case.
2. The method according to claim 1, characterized in that The executing the target test case according to the target input data to determine the test result of the target test case includes: According to the current target input data, execute the target test case corresponding to the current target input data; If an unexpected error occurs in the target test case corresponding to the current target input data, the test is stopped to obtain the test result; If the target test case corresponding to the current target input data does not have the unexpected error, the next target input data is used as the current target input data, and the step of executing the target test case corresponding to the current target input data according to the current target input data is returned until all the target test cases corresponding to the target input data are executed to obtain the test result.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: In response to a first editing operation based on the graphical editing interface, determining an editing test operation from a plurality of candidate test operations; In response to a second editing operation based on the editing test operation in the graphical editing interface, an execution logic of the editing test operation is determined to obtain the candidate test case.
4. The method according to claim 1 or 2, characterized in that: The executing the target test case according to the target input data to determine the test result of the target test case includes: Determining performance parameters of the target test operation during execution of the target test case; A test result of the target test case is determined according to the performance parameter.
5. The method according to claim 1 or 2, characterized in that: The method further comprises at least one of the following: According to a plurality of preset input rules, generating candidate input data corresponding to each of the preset input rules; Generate candidate input data according to a preset generation algorithm; Determine candidate input data according to the type of preset test case, at least one item of preset input data, and the intelligent model.
6. The method according to claim 1 or 2, characterized in that: The method further comprises: In response to a mapping operation based on the candidate input data and the candidate test case, the preset mapping relationship is determined.
7. A testing device, characterized in that: The device comprises: A first determination module is used to determine a target test case from candidate test cases; the target test case includes at least one target test operation based on an interactive interface and execution logic of the target test operation; A second determination module is used to determine the target input data corresponding to the target test case according to a preset mapping relationship; the preset mapping relationship includes a correspondence between input data and test cases; The third determination module is used to execute the target test case according to the target input data and determine the test result of the target test case.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.