Test method and device and electronic equipment

Through the automated testing method based on data-driven and keyword-driven, the target file and variable mechanism are used to solve the problem of high threshold for existing automated testing, and the flexibility and efficiency are improved, adapting to different testing environments and improving testing stability is improved. .

CN119292932APending Publication Date: 2025-01-10CHINA CONSTRUCTION BANK +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411419889.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-12
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

Existing automated testing, especially UI automation testing, has a high threshold and requires testers to have the ability to master programming languages ​​and related tools. Most testers are not qualified to do large-scale coding.

Method used

A data-driven and keyword-driven automated testing method is proposed. It records the execution process of test cases through target files, analyzes and generates test data, drives the execution of test cases, supports predefined and customized variables, and improves the flexibility of tests and efficiency.

Benefits of technology

It lowers the threshold for testing, improves the flexibility and efficiency of testing, can adapt to changes in different testing environments, reduces test failures caused by temporary problems, and improves the stability of the test and the credibility of the report.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119292932A_ABST
    Figure CN119292932A_ABST
Patent Text Reader

Abstract

The invention provides a test method and device and electronic device.The method comprises the steps that a target file under a target path is read, the target file is used for recording the execution process of at least one test case under a target test environment, and the execution process of the at least one test case is executed; the parameter value of the operation method involved in any case step in the test case is at least one of a set value, a value of a predefined variable corresponding to the target test environment and a value of a user-defined variable set by a value obtained by any case step before the case step; analyzing each test case recorded in the target file to generate test data corresponding to each test case; and according to the operation method in the test data corresponding to each test case and the parameter value of the operation method, driving the execution of each test case. Therefore, the use threshold can be reduced, the test case can better adapt to different test requirements and environment changes due to the fact that the user predefined variables and the user-defined variables are supported, and the test flexibility is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a testing method, device and electronic equipment. Background Art

[0002] With the development of testing technology, automated testing plays an increasingly important role in the testing process, especially in regression testing. However, in related technologies, automated testing, especially UI (User Interface) automated testing, has a high technical threshold, requiring testers to not only be familiar with the testing process, but also master at least one programming language (such as Python, Java, C#, etc.) and related automated testing frameworks and tools (such as Selenium, Appium, etc.). However, most testers have relatively weak coding skills and are unable to complete automated testing tasks through large-scale coding. Summary of the invention

[0003] The present application aims to solve one of the technical problems in the related art at least to some extent.

[0004] To this end, the first purpose of this application is to propose a testing method to realize data-driven and keyword-driven automated testing, lower the usage threshold, and by supporting user-defined variables and custom variables, enable test cases to better adapt to different testing requirements and environmental changes, thereby improving the flexibility of testing.

[0005] The second objective of the present application is to provide a testing device.

[0006] The third objective of the present application is to provide an electronic device.

[0007] A fourth objective of the present application is to provide a computer-readable storage medium.

[0008] A fifth object of the present application is to provide a computer program product.

[0009] To achieve the above-mentioned purpose, the first aspect embodiment of the present application proposes a testing method, comprising: reading a target file under a target path, wherein the target file is used to record the execution process of at least one test case under a target test environment, and the parameter value of the operation method involved in any use case step in the test case is at least one of a set value, a value of a predefined variable corresponding to the target test environment, and a value of a custom variable set by a value obtained in any use case step before the use case step; parsing each of the test cases recorded in the target file to generate test data corresponding to each of the test cases, wherein the test data at least includes the operation method and the parameter value of the operation method involved in at least one of the use case steps in the corresponding test case; and driving the execution of each of the test cases according to the operation method and the parameter value of the operation method in the test data corresponding to each of the test cases.

[0010] To achieve the above-mentioned purpose, the second aspect embodiment of the present application proposes a testing device, including: a reading module, used to read a target file under a target path, wherein the target file is used to record the execution process of at least one test case under a target test environment, and the parameter value of the operation method involved in any use case step in the test case is at least one of a set value, a value of a predefined variable corresponding to the target test environment, and a value of a custom variable set by a value obtained in any use case step before the use case step; a first generating module, used to parse each of the test cases recorded in the target file to generate test data corresponding to each of the test cases, wherein the test data at least includes the operation method and parameter value of the operation method involved in at least one of the use case steps in the corresponding test case; an execution module, used to drive the execution of each of the test cases according to the operation method and parameter value of the operation method in the test data corresponding to each of the test cases.

[0011] To achieve the above-mentioned purpose, the third aspect embodiment of the present application proposes an electronic device, comprising: a processor; a memory for storing instructions executable by the processor, wherein the processor is configured to execute the instructions to implement the testing method as described in the above-mentioned embodiment of the present application.

[0012] To achieve the above objectives, the fourth aspect of the present application provides a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by the processor of an electronic device, the electronic device can execute the test method described in the above embodiment of the present application.

[0013] To achieve the above objectives, the fifth aspect of the present application provides a computer program product, a computer program, which implements the test method described in the above embodiments of the present application when executed by a processor.

[0014] The technical solution provided by the embodiments of the present application brings at least the following beneficial effects:

[0015] 1. Use a target file to record the execution process of at least one test case in the target test environment, and when executing the test case, drive the execution based on the operation method and parameter value of the operation method in the test data corresponding to the test case, thereby realizing data-driven and keyword-driven automated testing and lowering the threshold for use. Among them, the target file can introduce access addresses, test accounts and other data with different configurations in different test environments in the form of predefined variables, so that when the execution environment of the test case changes, it is only necessary to modify the predefined variables accordingly, and the target file can set the intermediate results generated during the execution of the test case as variables in the form of custom variables, so as to facilitate reference in subsequent steps, thereby enabling the test case to better adapt to different test requirements and environmental changes, and improve the flexibility of the test;

[0016] 2. Execute each test case concurrently according to the reading order of each test case and the preset maximum number of scheduling threads, which can make full use of test resources and improve execution efficiency. Among them, test cases with dependencies among test cases are executed in the same thread. If the test case on which any test case depends fails to execute, the execution of the test case can be skipped, saving execution time;

[0017] 3. By checking the log content (logs captured during the execution of each test case) and combining it with error screenshots (execution screens captured when a code execution error occurs during the execution of any test case), the problem can be quickly located, the cause of the error can be deeply analyzed, and the credibility of the test report (test report generated after the execution of each test case) can be increased;

[0018] 4. In the event that any step of a test case fails during the execution of any test case, a retry mechanism is added to reduce test failures caused by temporary problems and improve test stability.

[0019] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0021] Figure 1 It is a flow chart of a testing method provided in an embodiment of the present application.

[0022] Figure 2It is a flow chart of another testing method provided in an embodiment of the present application.

[0023] Figure 3 It is a flowchart of a concurrent execution of test cases provided in an embodiment of the present application.

[0024] Figure 4 It is a flowchart of another concurrent execution of test cases provided in an embodiment of the present application.

[0025] Figure 5 It is a flow chart of another testing method provided in an embodiment of the present application.

[0026] Figure 6 It is a flow chart of another testing method provided in an embodiment of the present application.

[0027] Figure 7 It is a structural schematic diagram of a testing device provided in an embodiment of the present application.

[0028] Figure 8 It is a schematic diagram of the structure of an electronic device 800 shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0029] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0030] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards.

[0031] Among them, it should be noted that the acquisition, transmission, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of relevant laws and regulations. In the embodiments of this application, certain software, components, models, and other existing solutions in the industry may be mentioned. They should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of this application, but it does not mean that the applicant has or will necessarily use the solution.

[0032] The testing method, device and electronic device of the embodiments of the present application are described below with reference to the accompanying drawings.

[0033] Figure 1It is a flow chart of a testing method provided in an embodiment of the present application.

[0034] It should be noted that the test method provided in the embodiment of the present application can be performed by a test device, wherein the test device can be implemented by software and / or hardware. The test device can be an electronic device, or can be configured in an electronic device to implement the test function. The embodiment of the present application is described by taking the test method configured in an electronic device as an example.

[0035] Among them, the electronic device can be any device with computing capabilities, such as a personal computer, a mobile terminal, a server, etc. The mobile terminal can be, for example, a vehicle-mounted device, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, and other hardware devices with various operating systems, touch screens and / or display screens.

[0036] like Figure 1 As shown, the test method may include the following:

[0037] Step 101, read the target file in the target path.

[0038] Among them, the target file is used to record the execution process of at least one test case in the target test environment, and the parameter value of the operation method involved in any use case step in the test case is at least one of the set value, the value of the predefined variable corresponding to the target test environment, and the value of the custom variable set by the value obtained in any use case step before the use case step.

[0039] Among them, predefined variables are generally system variables, such as access addresses, test accounts, etc. (which will change according to the test environment and have different configurations in different test environments).

[0040] Optionally, predefined variables can start with the symbol "$" and generally conform to the variable naming format (that is, starting with an English letter and supporting symbols such as numbers and underscores), such as: $LOGIN_URL, $CONFIG.env, etc.

[0041] As an example, when testing the login function of a web application, you need to define a predefined variable to store the access address (URL, Uniform Resource Location) of the login page. This predefined variable may have different values ​​in different test environments (such as development environment, test environment, and production environment):

[0042] example:

[0043] Variable name: $LOGIN_URL

[0044] Development environment value: http: / / dev.example.com / login

[0045] Test environment value: http: / / test.example.com / login

[0046] Production environment value: https: / / www.example.com / login

[0047] Therefore, access addresses, test accounts and other data with different configurations in different execution environments are introduced through predefined variables. Therefore, when the execution environment of the test case changes, it is only necessary to modify the predefined variables accordingly, thereby achieving zero modification execution in different environments and realizing strong decoupling of data and use cases.

[0048] Custom variables are variables defined by users. For example, after successful login, the real name of the current user is obtained, which may be used for assertions or other steps in the use case. In this case, the obtained real name can be set as a custom variable.

[0049] Unlike predefined variables, custom variables are variables used exclusively by the current use case, so there is no conflict when the same variable name is used between different use cases.

[0050] Different from the naming method of predefined variables, custom variables can be named arbitrarily. To avoid conflicts with predefined variables, it is recommended to use Chinese characters, such as: name. When calling subsequent use cases, use the symbol "%" at the beginning. Like the previous example, when referencing, use: "% name".

[0051] As a possible implementation method, custom variable information is used in any recorded test case to indicate that the value obtained by any test case step in the test case is set as a custom variable; if the target file is a table file, a worksheet in the target file records the execution process of a test case in the target test environment.

[0052] The target file may be in a variety of formats, such as XLS, XLSX, XML (eXtensible Markup Language), JSON (JavaScript Object Notation), YAML, etc.

[0053] As an example, the target file uses XLS or XLSX. The tester can write the test case in Excel and obtain the target file as shown in Table 1:

[0054] Table 1 Target file example table

[0055]

[0056] illustrate:

[0057] 1. The target file supports two formats: .xls and .xlsx. All Excel files in the target path will be executed as test cases. During execution, each sheet page in the table will be treated as an independent test case. Multiple test cases can be executed concurrently, so it is necessary to ensure that the test cases in different sheet pages are independent of each other.

[0058] 2. The table name + sheet page name is the unique identifier of the test case and cannot be repeated. Therefore, the table name and sheet page name should be named according to the actual function of the use case as much as possible, such as: Excel name: Caizi system enterprise end.xls, sheet page name: public transfer process, so that the corresponding test case can be uniquely identified using Caizi system enterprise end.xls-Public transfer process.

[0059] 3. A sheet page in the target file is a complete test case. The first line of each sheet page must be a header, such as the header shown in Table 1. The header shown in Table 1 is a required item and the name cannot be modified. However, the sorting order of each header can be adjusted, and a custom header can be added (optional and can be deleted).

[0060] 4. The [Use Case Step] in Table 1 that does not affect execution must be set to 0. The program will treat the use case from step 0 to the next step 0 as a separate step use case, that is, a step of a complete use case, where a sheet page is a complete use case. For example, a sheet page is used to record the complete use case of "Create an order and review". The [Use Case Name] in the sheet page is the step of this complete use case, such as "Login", "Fill in an application", and "Review". The [Use Case Step] corresponding to the row where the [Use Case Name] is "Login" is 0, the [Use Case Step] corresponding to the row where the [Use Case Name] is "Fill in an application" is also 0, and the [Use Case Step] corresponding to the row where the [Use Case Name] is "Review" is also 0.

[0061] 5. In Table 1, [Use Case Name] is the functional description of the separate step use case (if the corresponding row is used to describe the small steps of the corresponding step use case, it can be left blank), [Use Case Title] is the code identifier of the separate step use case (if the corresponding row is used to describe the small steps of the corresponding step use case, it can be left blank), [Dependent Use Case] ​​is used to indicate the dependent use cases of the complete use case (if there is no dependent use case, it can be left blank), [Use Case Step] is used to indicate the execution order of the steps of the complete use case (each separate step use case can be renumbered), [Step Name] is the name of each small step of each separate step use case (if the corresponding row is used to describe a separate step use case, it can be left blank), [Operation Method] is the operation method involved in the corresponding small step (the operation method is a pre-defined keyword [method] is the parameter involved in the corresponding operation method, using the format of key=value;. Multiple parameters are separated by ";" (all parameters are str type, so there is no need to add "", even if the parameter is int, the program will automatically process it. If the corresponding line is used to describe a separate step use case, or the corresponding line is used to describe the small steps of the corresponding step use case, the corresponding operation method does not involve parameters, so it can be left blank). [Set result to variable] is used to indicate that the value obtained in the corresponding step is set to a custom variable (if the corresponding line is used to describe a separate step use case, or the corresponding line is used to describe the small steps of the corresponding step use case, no custom variables need to be set, so it can be left blank).

[0062] 6. Predefined variables (generally system variables, which are pre-set variables, such as user addresses, login usernames and passwords, etc., which need to be read directly from the class or through methods) can be referenced in Table 1. The leading identifier $ is required, such as $CONFIG.user_name, where CONFIG is the object or class name (i.e., class name), and user_name is the variable name.

[0063] 7. Custom variables (variables set by [Set results as variables]) can be referenced in Table 1. Prefix identifier %, such as %name, should be used. To avoid duplication with instance names, do not set variables starting with an underscore. Chinese characters can be used, and it is recommended to use Chinese characters. It should be noted that if a variable name is set multiple times, the latter setting will replace the former one (setting the same variable name between different excels, i.e., separate test cases, will not affect each other).

[0064] As a possible implementation method, the target file suffix can be determined according to the file type of the target file; and the file with the file suffix of the target file under the target path can be read. For example, assuming that the file type of the target file is a spreadsheet file, the target file suffix can be determined to be .xls or .xlsx, and then all files with the file suffix of .xls or .xlsx under the target path can be read, and these read files are the target files.

[0065] Step 102: parse each test case recorded in the target file to generate test data corresponding to each test case.

[0066] The test data at least includes the operation method and parameter values ​​of the operation method involved in at least one use case step in the corresponding test case.

[0067] As a possible implementation method, any test case recorded in the target file can be parsed into a corresponding use case dictionary list, wherein the use case dictionary list includes a use case name and a use case content, and the use case content includes at least an operation method and a parameter value of the operation method involved in at least one use case step in the corresponding test case, and the parameter value is in a key-value pair format, the key in the key-value pair is the parameter name, and the value in the key-value pair is the corresponding parameter value; the use case dictionary list corresponding to each test case is used as the test data corresponding to each test case.

[0068] As an example, the test data is in a list format, and the list contains a dictionary in the format of "use case name: use case content". The use case content is the serial number, use case name, use case title, dependent use case, use case step, step name, operation method, parameter, result setting as variable and remarks. Among them, the operation method and parameter are required. The operation method is a pre-defined keyword method for keyword-driven. The parameter is in the format of key=value;, where ";" is a separator to split one or more parameters (read the parameters, split them with the separator, and save them in the dictionary for keyword-driven parameter use). Others are optional and can be used to record the use case content or other custom content, so that testers can view the use case conveniently. The converted test case is a list with a built-in dictionary. For example, the sheet page testcase1 in the excel.xls file (target file) is a complete test case. The unique identifier of the test case is: excel.xls-testcase1. The test case can be converted into the following test data:

[0069] [[{'excel.xls-testcase1':[[{'Serial number':1,'Use case name':'XX system login','Use case title':'XX_002','Dependency case':",'Use case steps':0,'Step name':",'Operation method':",'Parameters':",'Set result as variable':",'Remarks':"},{'Serial number':2,'Use case name':",'Use case title':",'Dependency case':",'Use Example step':1,'Step name':'Login','Operation method':'login','Parameters':','Result is set as variable':','Remarks':'},{'Serial number':3,'Use case name':','Use case title':','Dependent use case':','Use case step':3,'Step name':'Log out','Operation method':'logout','Parameters':','Result is set as variable':','Remarks':'}]]}]].

[0070] The sequence number is used to indicate the execution order of each test case step in the test case. The sequence can be customized as needed without affecting the execution of the test case.

[0071] Step 103: driving the execution of each test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case.

[0072] In the embodiment of the present application, for any test case, the test data corresponding to the test case can be traversed to obtain the operation method and parameter value of the operation method involved in at least one test case step in the test case, and then, according to the execution order of each test case step in the test case, the target method in the target class is called in turn according to the operation method and parameter value of the operation method involved in each test case step in the test case to complete the execution of the test case. In this way, data-driven and keyword-driven automated testing can be realized, and the use threshold can be lowered.

[0073] As an example, methods and variables can be dynamically called through the Python reflection mechanism according to the operation methods and parameter values ​​of the operation methods in the test data corresponding to each test case. For example, the method getattr (method name, such as the operation method in Table 1) (**parameters, such as the parameters in Table 1) built into Python can be used to dynamically call methods and variables. This process is based on the corresponding relationship between the methods and parameters in the operation class operation and the operation methods and parameter values ​​of the operation methods in the test data.

[0074] It should be noted that if the variable name of a custom variable in a test case is repeated with an existing keyword, the test case will be set to execution failure based on the protection mechanism and a prompt will be given to inform that the custom variable cannot be set to the same name as the keyword to avoid overwriting the original method and causing the method to fail. Among them, keywords can be expanded when they need to be expanded.

[0075] In order to make full use of test resources and improve execution efficiency, as a possible implementation method, the concurrent execution of each test case can be driven according to the reading order of each test case and the pre-set maximum number of scheduling threads, according to the operation method and parameter value of the operation method in the test data corresponding to each test case, wherein the test cases with dependencies among the test cases are executed in the same thread.

[0076] It should be noted that test cases with dependencies among the test cases are executed in the same thread. When any test case fails to execute, the test cases that depend on this test case will be skipped to avoid the situation where the test cases that depend on this test case will fail even if they are executed, thus saving execution time.

[0077] The test method of the embodiment of the present application reads the target file under the target path, wherein the target file is used to record the execution process of at least one test case under the target test environment, and the parameter value of the operation method involved in any use case step in the test case is at least one of the set value, the value of the predefined variable corresponding to the target test environment, and the value of the custom variable set by the value obtained by any use case step before the use case step; parse each test case recorded in the target file to generate test data corresponding to each test case; drive the execution of each test case according to the operation method and the parameter value of the operation method in the test data corresponding to each test case. Thus, the target file is used to record the execution process of at least one test case under the target test environment, and when executing the test case, the execution is driven based on the operation method and the parameter value of the operation method in the test data corresponding to the test case, which can realize data-driven and keyword-driven automated testing and reduce the threshold for use. Among them, the target file can introduce access addresses, test accounts and other data with different configurations in different execution environments through predefined variables, so that when the execution environment of the test case changes, it is only necessary to modify the predefined variables accordingly. In addition, the target file can set the intermediate results generated during the execution of the test case as variables through custom variables to facilitate reference in subsequent steps. In this way, the test case can better adapt to different test requirements and environmental changes, thereby improving the flexibility of the test.

[0078] In order to clearly illustrate how the present application drives the concurrent execution of each test case according to the reading order of each test case and the preset maximum number of scheduling threads, according to the operation method and parameter value of the operation method in the test data corresponding to each test case, the embodiment of the present application provides another testing method. Figure 2 It is a flow chart of another testing method provided in an embodiment of the present application.

[0079] like Figure 2 As shown, the test method may include the following steps:

[0080] Step 201, read the target file in the target path.

[0081] The target file is used to record the execution process of at least one test case in the target test environment, and in any recorded test case, dependent case information is used to indicate the target test case that the test case depends on.

[0082] It should be noted that if any test case does not have a target test case on which it depends, the dependent test case information is empty.

[0083] Step 202: parse each test case recorded in the target file to generate test data corresponding to each test case.

[0084] Step 203: Obtain a target thread for executing each test case.

[0085] The number of target threads is the maximum number of scheduled threads. For example, if the maximum number of scheduled threads is preset to 2, then 2 threads are obtained to execute the test case.

[0086] Step 204: Determine whether there is a dependency relationship between the test cases based on the dependent case information of each test case.

[0087] Since when a test case does not have a target test case it depends on, the dependent case information of the test case is empty, it is possible to determine whether each test case has a target test case it depends on based on whether the dependent case information of each test case is empty, and then determine whether there is a dependency relationship between the test cases.

[0088] Step 205, if there is a dependency relationship between the test cases, then according to the reading order and the dependency relationship between the test cases, the target thread is called according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case to drive the concurrent execution of each test case.

[0089] In a possible implementation, according to the reading order and the dependency relationship between the test cases, the target thread is called to drive the concurrent execution of the test cases according to the operation method and the parameter value of the operation method in the test data corresponding to the test case. Specifically, the following can be used: Figure 4 The steps shown are performed:

[0090] Step 2051: Determine whether the first number of the first test case is less than the maximum number of calling threads based on the dependency relationship between the test cases.

[0091] The first test case is a test case that does not have a target test case on which it depends among all the test cases.

[0092] Step 2052, if the first number is not less than the maximum number of calling threads, determine the second test cases with the maximum number of scheduled threads in the front reading order from each first test case according to the reading order, and call the target threads with the maximum number of scheduled threads according to the operation method and parameter values ​​of the operation method in the test data corresponding to the second test cases with the maximum number of scheduled threads, to drive the concurrent execution of the second test cases with the maximum number of scheduled threads.

[0093] Wherein, a target thread executes a second test case.

[0094] As a possible implementation method, the target threads of the maximum number of scheduled threads are sequentially arranged threads, so that the correspondence between each target thread and each second test case can be determined according to the arrangement order of the target threads of the maximum number of scheduled threads and the reading order of the second test cases of the maximum number of scheduled threads; according to the correspondence between each target thread and each second test case, the target thread corresponding to each second test case is called to drive the concurrent execution of each second test case according to the operation method and the parameter values ​​of the operation method in the test data corresponding to each second test case.

[0095] As a possible implementation method, for any second test case, the target thread corresponding to the second test case can be called to traverse the test data corresponding to the second test case to obtain the operation method and parameter value of the operation method involved in at least one use case step in the second test case; in the target thread corresponding to the second test case, in accordance with the execution order of each use case step in the second test case, the target method in the target class is called in sequence according to the operation method and parameter value of the operation method involved in each use case step in the second test case to complete the execution of the second test case.

[0096] Step 2053: For any second test case having a dependency relationship, add a third test case having a direct dependency relationship and / or an indirect dependency relationship with the second test case to the target thread corresponding to the second test case.

[0097] As a possible implementation method, for any second test case with a dependency relationship, according to the dependency relationship between the test cases, a third test case that has a direct dependency relationship and / or an indirect dependency relationship with the second test case is determined from at least one test case other than the first test case in the test cases; the third test case is added to the target thread corresponding to the second test case, so that if the second test case is executed successfully, the target thread corresponding to the second test case is called to execute the third test case, or, if the second test case fails to execute, the execution of the third test case is skipped.

[0098] As an example, suppose there are 4 test cases: test case 1, test case 2, test case 3, and test case 4. Test case 2 depends on test case 1, test case 3 depends on test case 1, and test case 4 depends on test case 3. Then test case 2 and test case 3 are test cases that have a direct dependency on test case 1, and test case 4 is a test case that has an indirect dependency on test case 1.

[0099] It should be noted that when there are multiple third test cases, each third test case needs to be added to the target thread corresponding to the second test case according to the reading order of each third test case, wherein the order in which each third test case is added to the target thread corresponding to the second test case is the execution order of each third test case. Moreover, when each third test case is executed in the execution order of each third test case, if any of the third test cases fails to execute, the execution of all third test cases whose execution order is after the third test case that failed to execute will be skipped, thereby greatly saving execution time.

[0100] Step 2054, when any target thread completes executing the corresponding second test case and / or third test case, determine the fourth test case to be executed from at least one first test case other than the second test case in the first test cases according to the reading order, and call the target thread corresponding to the second test case to drive the execution of the fourth test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to the fourth test case.

[0101] As an example, assume that test case 1, test case 2, test case 3, test case 4, and test case 5 need to be executed, among which test case 2 depends on test case 1, test case 4 depends on test case 2, and there is no dependency between test case 3 and test case 5. The maximum number of scheduling threads is 2, and the reading order is test case 1, test case 2, test case 3, test case 4, and test case 5. The first number (the number of first test cases (test cases in which the target test cases on which they depend do not exist, i.e., test case 1, test case 3, and test case 5)) is not less than the maximum number of calling threads, then the two test cases (test case 1, test case 3, and test case 5) with the first two test cases in the reading order can be determined according to the reading order. 1, test case 3), call two target threads to execute test case 1 and test case 3 concurrently, then, for test case 1 with a dependency relationship, add the test cases (test case 2, test case 4) that have a direct dependency and / or indirect dependency relationship with test case 1 to the target thread corresponding to test case 1 (the target thread that executes test case 1), (test case 3 has no dependency relationship, so there is no need to execute this step), then, after any target thread executes the corresponding test case, determine the test case to be executed (test case 5) from at least one test case in each first test case except test case 1 and test case 3 according to the reading order, call the aforementioned target thread to execute test case 5, and after all five test cases are executed, this execution ends.

[0102] In simple terms, the above process is to first schedule two target threads to concurrently execute test case 1 and test case 3, add test case 2 and test case 4 that have a dependency relationship with test case 1 to the target thread corresponding to test case 1, and then execute test case 5 after the target thread that executes the corresponding test case first. After all five test cases are executed, this execution ends.

[0103] Among them, for the target thread corresponding to test case 1, the execution of the corresponding test case includes the following situations: 1. The execution of test case 1 is successful, the execution of test case 2 is successful, and the execution of test case 4 is successful; 2. The execution of test case 1 is successful, the execution of test case 2 is successful, and the execution of test case 4 fails; 3. The execution of test case 1 is successful, the execution of test case 2 fails, and the execution of test case 4 is skipped; 4. The execution of test case 1 fails, and the execution of test case 2 and test case 4 are skipped.

[0104] Step 2055: If the first number is less than the maximum number of calling threads, the first number of target threads are called to drive the concurrent execution of each first test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to each first test case.

[0105] Wherein, a target thread executes a first test case.

[0106] If the first number is less than the maximum number of calling threads, multiple target threads are called to execute the first test cases according to the number of first test cases. The process of calling the target threads to drive the concurrent execution of each first test case according to the operation method and the parameter value of the operation method in the test data corresponding to each first test case is shown in step 2052, and the principle is the same, which will not be repeated here.

[0107] Step 2056: For any first test case with a dependency relationship, add a fifth test case that has a direct dependency relationship and / or an indirect dependency relationship with the first test case to the target thread corresponding to the first test case.

[0108] The process of this step refers to step 2053, the principle is the same, and it will not be repeated here.

[0109] As an example, assume that test case 1, test case 2, and test case 3 need to be executed, where test case 2 depends on test case 1, and test case 3 has no dependency relationship, the maximum number of scheduled threads is 3, and the reading order is test case 1, test case 2, and the first number (the number of first test cases (test cases that do not have the target test cases they depend on in each test case, that is, test case 1 and test case 3)) is less than the maximum number of calling threads, then any two target threads can be selected from the three target threads, and these two target threads can be scheduled to execute test case 1 and test case 3 concurrently. Afterwards, for test case 1 that has a dependency relationship, the test case (test case 2) that has a direct dependency and / or indirect dependency relationship with test case 1 is added to the target thread corresponding to test case 1 (the target thread executing test case 1), (test case 3 has no dependency relationship, so this step does not need to be executed). After all three test cases are executed, this execution ends.

[0110] That is to say, even if there are three target threads, two of which execute test case 1 and test case 3, and there is an idle target thread, since test case 2 depends on test case 1, the idle target thread will not be called to execute test case 2. Test case 2 will wait for test case 1 to be completed before executing on the target thread corresponding to test case 1. Moreover, if test case 1 fails to execute, test case 2, which depends on test case 1, will skip execution, avoiding the situation where the precondition has failed and the execution will fail, thus saving execution time.

[0111] In summary, in this application, test cases with dependencies will be scheduled to the same target thread and executed in sequence. Even if a target thread is idle, for any test case, if the test case it depends on has not been executed, the idle target thread will not be called to execute the test case.

[0112] Step 206: If there is no dependency between the test cases, the target thread is called in the reading order to drive the concurrent execution of the test cases according to the operation method and parameter values ​​of the operation method in the test data corresponding to the test cases.

[0113] In a possible implementation, in the reading order, the target thread is called according to the operation method and parameter value of the operation method in the test data corresponding to each test case, and the concurrent execution of each test case is driven. Specifically, the following can be performed: Figure 3 The steps shown are performed:

[0114] Step 2061, determine whether the number of each test case is less than the maximum number of calling threads.

[0115] Step 2062, if the number of each test case is not less than the maximum number of calling threads, then determine the sixth test case with the maximum number of scheduled threads in the front reading order from each test case according to the reading order, and call the target thread with the maximum number of scheduled threads to drive the concurrent execution of the sixth test case with the maximum number of scheduled threads according to the operation method and parameter values ​​of the operation method in the test data corresponding to the sixth test case with the maximum number of scheduled threads.

[0116] Among them, a target thread executes a sixth test case.

[0117] The process of this step refers to step 2052, the principle is the same, and it will not be repeated here.

[0118] Step 2063, when any target thread completes executing the corresponding sixth test case, determine the seventh test case to be executed from at least one test case other than the sixth test case in the test cases according to the reading order, and call the target thread to drive the execution of the seventh test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to the seventh test case.

[0119] As an example, assuming that test case 1, test case 2, and test case 3 need to be executed, and there is no dependency between the three test cases, the maximum number of scheduled threads is 2, the reading order is test case 1, test case 2, and test case 3, and the number of each test case is not less than the maximum number of calling threads, then the two test cases (test case 1 and test case 2) with the first reading order can be determined from the three test cases according to the reading order, and two target threads are called to execute test case 1 and test case 2 concurrently. After that, any target thread executes the corresponding test case, and according to the reading order, the test case to be executed (test case 3) is determined from at least one test case other than test case 1 and test case 2 among the three test cases, and the aforementioned target thread is called to execute test case 3. After all three test cases are executed, this execution ends.

[0120] In simple terms, the above process is to first schedule two target threads to concurrently execute test case 1 and test case 2, and then the target thread that has completed the corresponding test case executes test case 3. After all three test cases are completed, this execution ends.

[0121] Step 2064, if the number of test cases is less than the maximum number of calling threads, the calling number of target threads drives the concurrent execution of each test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case.

[0122] Among them, one target thread executes one test case.

[0123] If the number of test cases is less than the maximum number of calling threads, multiple target threads are called to execute the test cases according to the number of test cases. The process of calling the target threads to drive the concurrent execution of the test cases according to the operation methods and parameter values ​​of the operation methods in the test data corresponding to the test cases is shown in step 2052, and the principle is the same, which will not be repeated here.

[0124] As an example, assuming that test case 1, test case 2, and test case 3 need to be executed, and there is no dependency between these three test cases, the maximum number of scheduled threads is 4, and the number of each test case is less than the maximum number of calling threads, then any 3 target threads can be selected from the 4 target threads, and these 3 target threads can be scheduled to execute test case 1, test case 2, and test case 3 concurrently. After all these three test cases are executed, this execution ends.

[0125] It should be noted that the execution process of steps 201 to 202 can be implemented in any of the embodiments of the present application. The embodiments of the present application do not limit this and will not be described in detail.

[0126] The test method of the embodiment of the present application obtains the target thread for executing each test case, wherein the number of target threads is the maximum number of scheduled threads; determines whether there is a dependency relationship between each test case according to the dependent case information of each test case; if there is no dependency relationship between each test case, then the target thread is called in the reading order according to the operation method and parameter value of the operation method in the test data corresponding to each test case to drive the concurrent execution of each test case; if there is a dependency relationship between each test case, then the target thread is called in the reading order and the dependency relationship between each test case according to the operation method and parameter value of the operation method in the test data corresponding to each test case to drive the concurrent execution of each test case. Thus, each test case is executed concurrently according to the reading order of each test case and the preset maximum number of scheduled threads, which can make full use of test resources and improve execution efficiency, wherein the test cases with dependencies in each test case are executed in the same thread, and when the test case on which any test case depends fails to execute, the execution of the test case can be skipped, saving execution time.

[0127] It should be noted that in this application, logs can also be captured during the execution of each test case and a test report can be generated after each test case is executed. Figure 5 , which explains this process.

[0128] Figure 5 It is a flow chart of another testing method provided in an embodiment of the present application.

[0129] like Figure 5 As shown, the test method may include the following steps:

[0130] Step 501, read the target file in the target path.

[0131] Step 502: parse each test case recorded in the target file to generate test data corresponding to each test case.

[0132] Step 503: driving the execution of each test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case.

[0133] Step 504: During the execution of each test case, a log recording method is called to capture logs according to a preset log level, and the captured logs are stored in the first path.

[0134] The first path is a storage path corresponding to a preset log level to which the captured log belongs.

[0135] Among them, the preset log levels may include: debug, info, warn, error, critical, etc.

[0136] During the execution of each test case, the execution logs are collected and classified by level. If there are logs with error level or above, special attention should be paid, as there may be problems. Implementation method: define the logger method, capture the logs by level, and store them in the directory defined in the configuration file. Among them, error and critical type logs will be stored separately in the error.log file to check the errors that occur in the system. Other types of logs are stored in the log file log.log. After the test is executed, the log path will be returned. Users can view the log content of error and above levels by accessing the path, and combine it with the error screenshot (for example, when a defined error or unknown error occurs, call the custom screenshot function based on WebDriver to generate a screenshot file of the browser page when the error occurs at that time), analyze the cause of the error, and feedback the results to facilitate R&D personnel to solve it.

[0137] Step 505, when a code execution error occurs during the execution of any test case, the execution result of the test case is determined to be execution failure, and the execution screen is captured by using a saving screen method, and the captured execution screen is stored in the second path.

[0138] During the execution of each test case, if a defined error or an unknown error occurs, a screenshot will be automatically saved, and the path and name of the image will be returned, which is convenient for analyzing the problem after the subsequent execution is completed. It is only applicable to web mode. Implementation method: define the save_screen method. If an Exception occurs during the execution, this method will be automatically called to capture the image and return the path + image name of the current image, such as: D:\20240515131206.235997.png. The image name can be customized. If it is not defined, it will be returned according to the microsecond timestamp at that time to avoid duplication.

[0139] Step 506: After each test case is executed, a test report is generated.

[0140] After each test case is executed, a test report is generated. Implementation method: Read the configuration in the report configuration file, such as test environment, test address, report name, etc., and generate a test report in the corresponding format (xml or html). Users can analyze the problem and submit bugs after viewing the report.

[0141] It should be noted that the execution process of steps 501 to 503 can be implemented in any way in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be repeated.

[0142] The test method of the embodiment of the present application, during the execution of each test case, calls the log recording method to capture the log according to the preset log level, and stores the captured log to the first path, wherein the first path is the storage path corresponding to the preset log level to which the captured log belongs; in the case of a code execution error during the execution of any test case, determines that the execution result of the test case is an execution failure, and uses the save screen method to intercept the execution screen, and stores the intercepted execution screen to the second path; after each test case is executed, a test report is generated. Thus, by viewing the log content and combining the error screenshot, the problem can be quickly located, the cause of the error can be deeply analyzed, and the credibility of the test report can be increased.

[0143] It should be noted that a retry mechanism is also added in this application to improve the stability of the test. Figure 6 , which explains this process.

[0144] Figure 6 It is a flow chart of another testing method provided in an embodiment of the present application.

[0145] like Figure 6 As shown, the test method may include the following steps:

[0146] Step 601, read the target file in the target path.

[0147] Step 602: parse each test case recorded in the target file to generate test data corresponding to each test case.

[0148] Step 603: driving the execution of each test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case.

[0149] Step 604: When any test case step fails during the execution of any test case, determine whether the number of retries of the test case exceeds a preset retry number threshold.

[0150] Among them, the preset retry number threshold can be any value, such as 3, 5, 8, 10, etc.

[0151] The initial value of the number of retries for any test case is 0. Each time the test case is re-executed, the number of retries for the test case increases by 1.

[0152] Step 605: If the number of retries of the test case does not exceed the preset retry number threshold, the test case is re-executed until the test case is successfully executed or the number of retries of the test case exceeds the preset retry number threshold.

[0153] Step 606: If the number of retries of the test case exceeds a preset retry number threshold, the execution result of the test case is determined to be execution failure.

[0154] In summary, according to the preset retry count threshold, if the use case step fails, it will be repeated. If it exceeds the preset retry count threshold, it will fail and return. If it succeeds within the retry count, the test case is executed successfully.

[0155] As an example, assuming that the preset retry threshold is 2, after the current test case test01 fails to execute a case step, it will be repeated twice. If one of the two executions is successful, the current case will be returned as successful and the execution will end. If both executions fail, the execution result of the test case will be set to execution failure.

[0156] It should be noted that the execution process of steps 601 to 603 can be implemented in any of the embodiments of the present application. The embodiments of the present application do not limit this and will not be described in detail.

[0157] The test method of the embodiment of the present application determines whether the number of retries of the test case exceeds the preset retry threshold when any test case step fails to execute during the execution of any test case; if the number of retries of the test case does not exceed the preset retry threshold, the test case is re-executed until the test case is successfully executed or the number of retries of the test case exceeds the preset retry threshold; if the number of retries of the test case exceeds the preset retry threshold, the execution result of the test case is determined to be an execution failure. Therefore, in the case where any test case step fails to execute during the execution of any test case, adding a retry mechanism can reduce test failures caused by temporary problems and improve the stability of the test.

[0158] In order to implement the above embodiments, the present application also proposes a testing device.

[0159] Figure 7 It is a structural schematic diagram of a testing device provided in an embodiment of the present application.

[0160] like Figure 7 As shown, the testing device 700 includes: a reading module 710 , a first generating module 720 and an executing module 730 .

[0161] A reading module 710 is used to read a target file under a target path, wherein the target file is used to record the execution process of at least one test case in a target test environment, and the parameter value of the operation method involved in any test case step in the test case is at least one of a set value, a value of a predefined variable corresponding to the target test environment, and a value of a custom variable set by a value obtained in any test case step before the test case step;

[0162] A first generating module 720 is used to parse each test case recorded in the target file to generate test data corresponding to each test case, wherein the test data at least includes an operation method and a parameter value of the operation method involved in at least one case step in the corresponding test case;

[0163] The execution module 730 is used to drive the execution of each test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case.

[0164] In one embodiment of the present application, in any test case recorded, custom variable information is used to indicate that a value obtained by any test case step in the test case is set as a custom variable;

[0165] If the target file is a table file, a worksheet in the target file records the execution process of a test case in the target test environment.

[0166] In one embodiment of the present application, the execution module 730 is further configured to:

[0167] According to the reading order of each test case and the pre-set maximum number of scheduling threads, the concurrent execution of each test case is driven according to the operation method and parameter value of the operation method in the test data corresponding to each test case, wherein the test cases with dependencies among the test cases are executed in the same thread.

[0168] In one embodiment of the present application, the execution module 730 includes:

[0169] An acquisition unit, used for acquiring target threads for executing each test case, wherein the number of target threads is the maximum number of scheduled threads;

[0170] A determination unit, used to determine whether there is a dependency relationship between the test cases according to the dependent case information of each test case;

[0171] A first execution unit is used to, if there is a dependency relationship between the test cases, call the target thread according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case according to the reading order and the dependency relationship between the test cases, so as to drive the concurrent execution of the test cases;

[0172] The second execution unit is used to drive the concurrent execution of each test case by calling the target thread according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case in the reading order if there is no dependency relationship between the test cases.

[0173] In one embodiment of the present application, the first execution unit is further configured to:

[0174] Determine whether the first number of first test cases is less than the maximum number of calling threads according to the dependency relationship between the test cases; wherein the first test case is a test case on which there is no target test case on which it depends among the test cases;

[0175] If the first number is not less than the maximum number of calling threads, then according to the reading order, determine the second test cases with the maximum number of scheduled threads in the front reading order from each first test case, and call the target threads with the maximum number of scheduled threads to drive the concurrent execution of the second test cases with the maximum number of scheduled threads according to the operation method and the parameter value of the operation method in the test data corresponding to the second test cases with the maximum number of scheduled threads, wherein one target thread executes one second test case;

[0176] For any second test case having a dependency relationship, add a third test case having a direct dependency relationship and / or an indirect dependency relationship with the second test case to a target thread corresponding to the second test case;

[0177] When any target thread has completed executing the corresponding second test case and / or third test case, a fourth test case to be executed is determined from at least one first test case other than the second test case in each first test case according to the reading order, and the target thread corresponding to the second test case is called to drive the execution of the fourth test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to the fourth test case;

[0178] If the first number is less than the maximum number of calling threads, calling the first number of target threads to drive the concurrent execution of each first test case according to the operation method and the parameter value of the operation method in the test data corresponding to each first test case, wherein one target thread executes one first test case;

[0179] For any first test case having a dependency relationship, a fifth test case having a direct dependency relationship and / or an indirect dependency relationship with the first test case is added to a target thread corresponding to the first test case.

[0180] In one embodiment of the present application, the target threads of the maximum number of scheduling threads are threads arranged in sequence; the first execution unit is further used to:

[0181] Determine the correspondence between each target thread and each second test case according to the arrangement order of the target threads of the maximum number of scheduled threads and the reading order of the second test cases of the maximum number of scheduled threads;

[0182] According to the correspondence between each target thread and each second test case, the target thread corresponding to each second test case is called to drive the concurrent execution of each second test case according to the operation method and parameter value of the operation method in the test data corresponding to each second test case.

[0183] In one embodiment of the present application, the first execution unit is further configured to:

[0184] For any second test case, call the target thread corresponding to the second test case to traverse the test data corresponding to the second test case to obtain the operation method and parameter value of the operation method involved in at least one case step in the second test case;

[0185] In the target thread corresponding to the second test case, in accordance with the execution order of each use case step in the second test case, and in sequence according to the operation methods and parameter values ​​of the operation methods involved in each use case step in the second test case, the target method in the target class is called to complete the execution of the second test case.

[0186] In one embodiment of the present application, the first execution unit is further configured to:

[0187] For any second test case with a dependency relationship, determine, according to the dependency relationship between the test cases, a third test case that has a direct dependency relationship and / or an indirect dependency relationship with the second test case from at least one test case among the test cases except the first test case;

[0188] The third test case is added to the target thread corresponding to the second test case, so that if the second test case is executed successfully, the target thread corresponding to the second test case is called to execute the third test case, or if the second test case fails to execute, the execution of the third test case is skipped.

[0189] In one embodiment of the present application, the second execution unit is further configured to:

[0190] Determine whether the number of each test case is less than the maximum number of calling threads;

[0191] If the number of each test case is not less than the maximum number of calling threads, then according to the reading order, the sixth test case with the maximum number of scheduled threads in the front reading order is determined from each test case, and the target thread with the maximum number of scheduled threads is called to drive the concurrent execution of the sixth test case with the maximum number of scheduled threads according to the operation method and the parameter value of the operation method in the test data corresponding to the sixth test case with the maximum number of scheduled threads, wherein one target thread executes one sixth test case;

[0192] When any target thread has completed executing the corresponding sixth test case, determine the seventh test case to be executed from at least one test case other than the sixth test case in the test cases according to the reading order, and call the target thread to drive the execution of the seventh test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to the seventh test case;

[0193] If the number of test cases is less than the maximum number of calling threads, the calling target threads drive the concurrent execution of each test case according to the operation method and parameter value of the operation method in the test data corresponding to each test case, where one target thread executes one test case.

[0194] In one embodiment of the present application, the first generating module 720 is further configured to:

[0195] Parse any test case recorded in the target file into a corresponding test case dictionary list, wherein the test case dictionary list includes a test case name and a test case content, and the test case content includes at least an operation method and a parameter value of the operation method involved in at least one test case step in the corresponding test case, and the parameter value adopts a key-value pair format, wherein the key in the key-value pair is the parameter name, and the value in the key-value pair is the corresponding parameter value;

[0196] The use case dictionary list corresponding to each test case is used as the test data corresponding to each test case.

[0197] In one embodiment of the present application, the reading module 710 is further configured to:

[0198] Determine the target file suffix according to the file type of the target file;

[0199] Read the file with the same suffix as the target file in the target path.

[0200] In one embodiment of the present application, the above device further includes:

[0201] A capture module, used to call a log recording method to capture logs according to a preset log level during the execution of each test case, and store the captured logs in a first path, wherein the first path is a storage path corresponding to the preset log level to which the captured logs belong;

[0202] A processing module, used for determining that the execution result of the test case is an execution failure when a code execution error occurs during the execution of any test case, and intercepting the execution screen by using a saving screen method, and storing the intercepted execution screen in a second path;

[0203] The second generating module is used to generate a test report after each test case is executed.

[0204] In one embodiment of the present application, the above device further includes:

[0205] A first determination module is used to determine whether the number of retries of the test case exceeds a preset retry number threshold when any test case step fails to execute during the execution of any test case;

[0206] A re-execution module, for re-executing the test case if the number of retries of the test case does not exceed a preset retry number threshold, until the test case is successfully executed or the number of retries of the test case exceeds a preset retry number threshold;

[0207] The second determination module is used to determine that the execution result of the test case is an execution failure if the retry times of the test case exceeds a preset retry times threshold.

[0208] It should be noted that the above explanations of the test method embodiment are also applicable to the test device of this embodiment and will not be repeated here.

[0209] The test device provided by the present application reads the first address information in the address information database in response to the user inputting the second address information to be queried, wherein the first address information is generated based on a preset standard address description; according to the similarity between the multiple first substrings obtained by cutting the first address information and the second address information, multiple second substrings similar to the second address information are determined from the multiple first substrings; a trained characterization vector calculation model is used to generate a characterization vector of the second address information and a characterization vector of each second substring; according to the cosine similarity between the characterization vector of the second address information and the characterization vector of each second substring in the feature space, it is determined whether to use the trained generation model to correct the second address information. Thus, by preliminarily screening the multiple first substrings based on the similarity between the multiple first substrings obtained by cutting the first address information in the address information database and the second address information input by the user, the target range can be quickly narrowed down in large-scale data, the amount of data that needs to be processed by the deep learning model can be reduced, the computational complexity can be reduced, and the processing efficiency and user experience can be improved.

[0210] In an exemplary embodiment, an electronic device is also provided.

[0211] Among them, electronic equipment includes:

[0212] processor;

[0213] a memory for storing processor-executable instructions;

[0214] The processor is configured to execute instructions to implement the testing method proposed in any of the aforementioned embodiments.

[0215] As an example, Figure 8is a schematic diagram of the structure of an electronic device 800 shown in an exemplary embodiment of the present application. Figure 8 As shown, the electronic device 800 may further include:

[0216] The memory 810 and the processor 820, a bus 830 connecting different components (including the memory 810 and the processor 820), the memory 810 stores a computer program, and when the processor 820 executes the program, the test method described in the embodiment of the present application is implemented.

[0217] Bus 830 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.

[0218] The electronic device 800 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by the electronic device 800, including volatile and non-volatile media, removable and non-removable media.

[0219] The memory 810 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 840 and / or cache memory 850. The server 800 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 880 may be used to read and write non-removable, non-volatile magnetic media ( Figure 8 not shown, often referred to as a "hard drive packager"). Although Figure 8 Not shown, a disk driver package for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk driver package for reading and writing a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical medium) may be provided. In these cases, each driver package can be connected to the bus 830 via one or more data medium interfaces. The memory 810 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.

[0220] A program / utility 880 having a set (at least one) of program modules 870 may be stored, for example, in the memory 810, such program modules 870 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 870 generally perform the functions and / or methods of the embodiments described herein.

[0221] The electronic device 800 may also communicate with one or more external devices 880 (e.g., keyboard, pointing device, display 891, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 800, and / or communicate with any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 892. In addition, the electronic device 800 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 893. As shown, the network adapter 893 communicates with other modules of the electronic device 800 through a bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device driver package, redundant processing unit, external disk driver package array, RAID system, tape driver package, and data backup storage system, etc.

[0222] The processor 820 executes various functional applications and data processing by running the programs stored in the memory 810 .

[0223] It should be noted that the implementation process and technical principles of the electronic device of this embodiment refer to the aforementioned explanation of the testing method of the embodiment of the present application, and will not be repeated here.

[0224] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, and the instructions can be executed by a processor of an electronic device to complete the test method provided in any of the above embodiments. Alternatively, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0225] In an exemplary embodiment, a computer program product is also proposed, including a computer program / instruction, and when the computer program / instruction is executed by a processor, the test method proposed in any of the above embodiments is implemented.

[0226] The collection, storage, access, processing, transmission, provision and disclosure of user personal information involved in this application are in compliance with relevant laws and regulations and do not violate public order and good morals.

[0227] It should be noted that personal information from users should be collected for legitimate and reasonable purposes and not shared or sold outside of these legitimate accesses. In addition, such collection / sharing should be carried out after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice before the user accesses the function, and signing the agreement / authorization including authorization of relevant user information. In addition, any necessary steps should be taken to protect and safeguard access to such personal information data and ensure that others who have access to personal information data comply with its privacy policy and procedures.

[0228] This application is expected to provide an implementation scheme for users to selectively block access to or access to personal information data. That is, this application is expected to provide hardware and / or software to prevent or block access to such personal information data. Once the personal information data is no longer needed, risks can be minimized by limiting data collection and deleting data. In addition, when applicable, personal identifiers are removed from such personal information to protect the privacy of users.

[0229] In the description of the aforementioned embodiments, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0230] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0231] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0232] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0233] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or accessed as an independent product, it may also be stored in a computer-readable storage medium.

[0234] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A testing method, characterized in that: include: Reading a target file under a target path, wherein the target file is used to record the execution process of at least one test case in a target test environment, and a parameter value of an operation method involved in any test case step in the test case is at least one of a set value, a value of a predefined variable corresponding to the target test environment, and a value of a custom variable set by a value obtained in any test case step before the test case step; Parsing each of the test cases recorded in the target file to generate test data corresponding to each of the test cases, wherein the test data at least includes an operation method and a parameter value of the operation method involved in at least one of the test case steps in the corresponding test case; The execution of each of the test cases is driven according to the operation method and the parameter value of the operation method in the test data corresponding to each of the test cases.

2. The method according to claim 1, characterized in that In any of the test cases recorded, the custom variable information is used to indicate that a value obtained by any test case step in the test case is set as a custom variable; If the target file is a table file, a worksheet in the target file records the execution process of a test case in the target test environment.

3. The method according to claim 1, characterized in that The step of driving the execution of each test case according to the operation method and the parameter value of the operation method in the test data corresponding to each test case includes: According to the reading order of each test case and the pre-set maximum number of scheduling threads, and based on the operation method and parameter value of the operation method in the test data corresponding to each test case, the concurrent execution of each test case is driven, wherein the test cases with dependencies among the test cases are executed in the same thread.

4. The method according to claim 3, characterized in that: In any of the test cases recorded, dependent case information is used to indicate a target test case on which the test case depends; and according to the reading order and the maximum number of scheduled threads, and according to the operation method and parameter values ​​of the operation method in the test data corresponding to each of the test cases, the concurrent execution of each of the test cases is driven, including: Obtaining target threads for executing each of the test cases, wherein the number of the target threads is the maximum number of scheduled threads; Determine whether there is a dependency relationship between the test cases according to the dependent test case information of the test cases; If there is a dependency relationship between the test cases, calling the target thread according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case according to the reading order and the dependency relationship between the test cases, to drive the concurrent execution of each test case; If there is no dependency between the test cases, the target thread is called in the reading order to drive the concurrent execution of the test cases according to the operation method and parameter values ​​of the operation method in the test data corresponding to the test cases.

5. The method according to claim 4, characterized in that The method of calling the target thread according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case according to the reading order and the dependency relationship between the test cases, and driving the concurrent execution of each test case includes: Determine whether the first number of the first test case is less than the maximum number of calling threads according to the dependency relationship between the test cases; wherein the first test case is a test case on which there is no target test case on which it depends among the test cases; If the first number is not less than the maximum number of calling threads, then according to the reading order, determine the second test cases with the maximum number of scheduled threads in the front reading order from each of the first test cases, and call the target threads with the maximum number of scheduled threads to drive the concurrent execution of the second test cases with the maximum number of scheduled threads according to the operation method and the parameter value of the operation method in the test data corresponding to the second test cases with the maximum number of scheduled threads, wherein one target thread executes one second test case; For any of the second test cases having a dependency relationship, adding a third test case having a direct dependency relationship and / or an indirect dependency relationship with the second test case to a target thread corresponding to the second test case; In the case that any of the target threads completes execution of the corresponding second test case and / or third test case, a fourth test case to be executed is determined from at least one of the first test cases except the second test case in the first test cases according to the reading order, and the target thread corresponding to the second test case is called to drive execution of the fourth test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to the fourth test case; If the first number is less than the maximum number of calling threads, calling the first number of target threads to drive the concurrent execution of each of the first test cases according to the operation method and the parameter value of the operation method in the test data corresponding to each of the first test cases, wherein one of the target threads executes one of the first test cases; For any of the first test cases having a dependency relationship, a fifth test case having a direct dependency relationship and / or an indirect dependency relationship with the first test case is added to a target thread corresponding to the first test case.

6. The method according to claim 5, characterized in that The target threads of the maximum number of scheduled threads are sequentially arranged threads; the calling of the target threads of the maximum number of scheduled threads drives the concurrent execution of the second test case of the maximum number of scheduled threads according to the operation method and the parameter value of the operation method in the test data corresponding to the second test case of the maximum number of scheduled threads, including: Determine the correspondence between each of the target threads and each of the second test cases according to the arrangement order of the target threads of the maximum number of scheduled threads and the reading order of the second test cases of the maximum number of scheduled threads; According to the correspondence between each target thread and each second test case, the target thread corresponding to each second test case is called to drive the concurrent execution of each second test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to each second test case.

7. The method according to claim 6, characterized in that The calling of the target thread corresponding to each of the second test cases drives the concurrent execution of each of the second test cases according to the operation method and the parameter value of the operation method in the test data corresponding to each of the second test cases, including: For any of the second test cases, calling the target thread corresponding to the second test case to traverse the test data corresponding to the second test case to obtain the operation method and parameter value of the operation method involved in at least one of the case steps in the second test case; In the target thread corresponding to the second test case, in the order of executing the use case steps in the second test case, the target method in the target class is called in sequence according to the operation methods and parameter values ​​of the operation methods involved in each use case step in the second test case to complete the execution of the second test case.

8. The method according to claim 5, characterized in that The adding, for any second test case having a dependency relationship, a third test case having a direct dependency relationship and / or an indirect dependency relationship with the second test case to a target thread corresponding to the second test case includes: For any of the second test cases having a dependency relationship, according to the dependency relationship between the test cases, determine a third test case having a direct dependency relationship and / or an indirect dependency relationship with the second test case from at least one of the test cases except the first test case; The third test case is added to the target thread corresponding to the second test case, so that if the second test case is executed successfully, the target thread corresponding to the second test case is called to execute the third test case, or, if the second test case fails to execute, the execution of the third test case is skipped.

9. The method according to claim 4, characterized in that The calling of the target thread according to the reading order drives the concurrent execution of each of the test cases according to the operation method and the parameter value of the operation method in the test data corresponding to each of the test cases, including: Determine whether the number of each of the test cases is less than the maximum number of calling threads; If the number of each of the test cases is not less than the maximum number of calling threads, then according to the reading order, determine the sixth test case with the maximum number of scheduled threads that is in the front of the reading order from each of the test cases, and call the target thread with the maximum number of scheduled threads to drive the concurrent execution of the sixth test case with the maximum number of scheduled threads according to the operation method and the parameter value of the operation method in the test data corresponding to the sixth test case with the maximum number of scheduled threads, wherein one target thread executes one sixth test case; In the case that any of the target threads has completed executing the corresponding sixth test case, according to the reading order, a seventh test case to be executed is determined from at least one of the test cases except the sixth test case, and the target thread is called to drive the execution of the seventh test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to the seventh test case; If the number of each test case is less than the maximum number of calling threads, the target threads are called to drive the concurrent execution of each test case according to the operation method and parameter values ​​of the operation method in the test data corresponding to each test case, wherein one target thread executes one test case.

10. The method according to claim 1, characterized in that The parsing of each of the test cases recorded in the target file to generate test data corresponding to each of the test cases includes: Parse any of the test cases recorded in the target file into a corresponding use case dictionary list, wherein the use case dictionary list includes a use case name and a use case content, and the use case content includes at least an operation method and a parameter value of the operation method involved in at least one of the use case steps in the corresponding test case, and the parameter value is in a key-value pair format, wherein the key in the key-value pair is the parameter name, and the value in the key-value pair is the corresponding parameter value; The use case dictionary list corresponding to each of the test cases is used as the test data corresponding to each of the test cases.

11. The method according to claim 1, characterized in that: The step of reading the target file under the target path includes: Determine the target file suffix according to the file type of the target file; Read the file whose file suffix is ​​the target file suffix under the target path.

12. The method according to any one of claims 1 to 11, characterized in that The method further comprises: During the execution of each of the test cases, a log recording method is called to capture logs according to a preset log level, and the captured logs are stored in a first path, wherein the first path is a storage path corresponding to the preset log level to which the captured logs belong; In the event that a code execution error occurs during the execution of any of the test cases, determining that the execution result of the test case is an execution failure, and using a method for saving a screen to intercept an execution screen, and storing the intercepted execution screen in a second path; After each of the test cases is executed, a test report is generated.

13. The method according to any one of claims 1 to 11, characterized in that The method further comprises: In the event that any of the steps of the test case fails to execute during the execution of any of the test cases, determining whether the number of retries of the test case exceeds a preset retry number threshold; If the number of retries of the test case does not exceed the preset retry number threshold, re-execute the test case until the test case is successfully executed or the number of retries of the test case exceeds the preset retry number threshold; If the number of retries of the test case exceeds a preset retry number threshold, the execution result of the test case is determined to be execution failure.

14. A testing device, characterized in that: include: A reading module, used for reading a target file under a target path, wherein the target file is used for recording the execution process of at least one test case under a target test environment, and a parameter value of an operation method involved in any test case step in the test case is at least one of a set value, a value of a predefined variable corresponding to the target test environment, and a value of a custom variable set by a value obtained in any test case step before the test case step; A first generating module, used for parsing each of the test cases recorded in the target file to generate test data corresponding to each of the test cases, wherein the test data at least includes an operation method and a parameter value of the operation method involved in at least one of the case steps in the corresponding test case; The execution module is used to drive the execution of each of the test cases according to the operation method and parameter values ​​of the operation method in the test data corresponding to each of the test cases.

15. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 13.

16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 13 when executed by a processor.

17. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 13 when being executed by a processor.