Test methods, apparatus, equipment, media
By obtaining the delay execution duration through the main thread and handling the delay waiting through asynchronous threads, the test steps solve the inefficiency problem caused by delay waiting in traditional test environments, and achieve a more efficient test process and resource utilization.
Patent Information
- Application Number
- CN202210929617.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-03
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-08-03
AI Technical Summary
In traditional testing environments, the switching of backend systems or the intermittent periods of batch processing cause automated test scripts to be delayed, resulting in low testing efficiency.
The main thread obtains the delay duration information, the asynchronous thread executes the next test step during the delay waiting period, and the test data is processed through reflection to generate the final test result.
It improved testing efficiency, avoided delays in the main thread, and optimized resource utilization.
Smart Images

Figure CN115168238B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the fields of software testing technology and financial technology, and specifically to a testing method, apparatus, equipment, medium, and program product. Background Technology
[0002] In current business transaction scenarios, there are many situations where transaction data needs to be centrally processed by the back-end system.
[0003] In the process of realizing the inventive concept of this disclosure, the inventors discovered the following defects in the related technology: In traditional testing environments, due to the certain interval period of background system switching or batch processing, automated test scripts need to wait for a delay before they can continue to execute the test, resulting in low testing efficiency. Summary of the Invention
[0004] In view of the above problems, this disclosure provides a test method, apparatus, device, medium and program product.
[0005] According to one aspect of this disclosure, a testing method is provided, comprising:
[0006] In response to a test request from the client, the main thread uses the target function to obtain the first delay execution duration information from the target test script. The first delay execution duration information represents the first preset time interval information between the start time information of the nth test step and the end time information of the (n-1)th test step, where n is a positive integer greater than 1.
[0007] The main thread executes the (n-1)th test step to obtain the first test result information, which includes the first test data used to execute the nth test step and the execution end time information of the (n-1)th test step.
[0008] If the time interval between the first current time information and the execution end time information of the (n-1)th test step is greater than the first delay execution duration information, the first asynchronous thread executes the nth test step based on the first test data to obtain the second test result information; and
[0009] Based on the first test result information and the second test result information, the target test result information is generated.
[0010] According to embodiments of this disclosure, the nth test step includes m sub-test steps. The nth test step is executed using a first asynchronous thread based on the first test data to obtain second test result information. The method further includes:
[0011] The first asynchronous thread uses the target function to obtain the second delay execution duration information from the nth test step. The second delay execution duration information represents the second preset time interval information between the execution start time information of the mth sub-test step and the execution end time information of the (m-1)th sub-test step, where m is a positive integer greater than 1.
[0012] The first asynchronous thread executes the (m-1)th sub-test step based on the first test data to obtain the first sub-test result information. This first sub-test result information includes the second test data used to execute the m-th sub-test step and the execution end time information of the (m-1)th sub-test step.
[0013] If the time interval between the second current time information and the execution end time information of the (m-1)th sub-test step is greater than the second preset time interval information, the second asynchronous thread is used to execute the mth sub-test step according to the second test data to obtain the second sub-test result information;
[0014] Based on the first and second sub-test results, generate the second test result information.
[0015] According to embodiments of this disclosure, when the time interval between the first current time information and the execution end time information of the (n-1)th test step is greater than the first delay execution duration information, the first asynchronous thread executes the nth test step based on the first test data to obtain second test result information, including:
[0016] If the time interval between the first current moment information and the execution end moment information of the (n-1)th test step is greater than the first delay execution duration information, the first test data is obtained;
[0017] Send the first test data to the first asynchronous thread;
[0018] The first asynchronous thread executes the nth test step based on the first test data using a reflection mechanism to obtain the second test result information.
[0019] According to embodiments of this disclosure, a first asynchronous thread executes the nth test step based on the first test data using a reflection mechanism to obtain second test result information, including:
[0020] The first asynchronous thread is used to parse the first test data to obtain the test script parameter information used to execute the nth test step;
[0021] Based on the test script parameter information, the nth test step is executed through reflection mechanism to obtain the second test result information.
[0022] According to embodiments of this disclosure, in response to a test request from a client, the main thread uses a target function to obtain first delay execution duration information from the target test script, including:
[0023] In response to a test request from the client, a delayed execution pending data table is obtained. The delayed execution pending data table includes delayed execution duration information corresponding to different test scripts. Each delayed execution duration information is obtained from the test script by the main thread through calling the target function.
[0024] Based on the identification information of the target test script, obtain the first delay execution duration information from the delayed execution pending data table.
[0025] According to embodiments of this disclosure, the above-described test method further includes:
[0026] When the first asynchronous thread obtains the second delay execution duration information from the nth test step by calling the target function, the second delay execution duration information is recorded in the delayed execution pending data table.
[0027] According to embodiments of this disclosure, the above-described test method further includes:
[0028] In response to a test request from the client, a test case execution result registration table is created using the main thread. The test case execution result registration table includes test case execution information.
[0029] By scanning the delayed execution pending data table, and if it is determined that the amount of data in the delayed execution pending data table meets the preset conditions, the test case execution status information is determined as information used to characterize the completion of the test.
[0030] Given that the test case execution status is determined to be information used to characterize test completion, target test result information is generated based on the first test result information and the second test result information.
[0031] Another aspect of this disclosure provides a testing apparatus, comprising: a first acquisition module, a first execution module, a second execution module, and a first generation module. The first acquisition module, in response to a test request from a client, utilizes a main thread to call a target function to acquire first delayed execution duration information from a target test script. This first delayed execution duration information represents a first preset time interval between the start time of the nth test step and the end time of the (n-1)th test step, where n is a positive integer greater than 1. The first execution module, utilizing the main thread, executes the (n-1)th test step to obtain first test result information. This first test result information includes first test data for executing the nth test step and the end time information of the (n-1)th test step. The second execution module, when the time interval between the first current time information and the end time information of the (n-1)th test step is greater than the first delayed execution duration information, utilizes a first asynchronous thread to execute the nth test step based on the first test data to obtain second test result information. The first generation module, based on the first and second test result information, generates target test result information.
[0032] According to embodiments of this disclosure, the second execution module includes a first acquisition unit, a first execution unit, a second execution unit, and a generation unit. The first acquisition unit is used to acquire second delayed execution duration information from the nth test step by calling a target function using a first asynchronous thread. The second delayed execution duration information represents a second preset time interval between the start time information of the mth sub-test step and the end time information of the (m-1)th sub-test step, where m is a positive integer greater than 1. The first execution unit is used to execute the (m-1)th sub-test step based on the first test data using the first asynchronous thread to obtain first sub-test result information. The first sub-test result information includes second test data used to execute the mth sub-test step and the end time information of the (m-1)th sub-test step. The second execution unit is used to execute the mth sub-test step based on the second test data using the second asynchronous thread when the time interval between the second current time information and the end time information of the (m-1)th sub-test step is greater than the second preset time interval information, thereby obtaining second sub-test result information. The generation unit is used to generate second test result information based on the first sub-test result information and the second sub-test result information.
[0033] According to embodiments of this disclosure, the second execution module includes a second acquisition unit, a sending unit, and a third execution unit. The second acquisition unit is used to acquire first test data when the time interval between the first current time information and the execution end time information of the (n-1)th test step is greater than the first delay execution duration information. The sending unit sends the first test data to a first asynchronous thread. The third execution unit is used to utilize the first asynchronous thread to execute the nth test step through a reflection mechanism based on the first test data to obtain second test result information.
[0034] According to embodiments of this disclosure, the third execution unit includes a parsing subunit and an execution subunit. The parsing subunit is used to parse the first test data using a first asynchronous thread to obtain test script parameter information for executing the nth test step. The execution subunit is used to execute the nth test step using a reflection mechanism based on the test script parameter information to obtain second test result information.
[0035] According to embodiments of this disclosure, the first acquisition module includes a third acquisition unit and a fourth acquisition unit. The third acquisition unit is used to acquire a delayed execution pending data table in response to a test request from a client. The delayed execution pending data table includes delayed execution duration information corresponding to different test scripts, and each delayed execution duration information is obtained from the test script by the main thread calling a target function. The fourth acquisition module is used to acquire first delayed execution duration information from the delayed execution pending data table based on the identification information of the target test script.
[0036] According to embodiments of this disclosure, the testing apparatus further includes a second acquisition module. This second acquisition module is configured to record the second delay execution duration information in a delay execution pending processing data table when the second delay execution duration information is obtained from the nth test step by calling a target function using a first asynchronous thread.
[0037] According to embodiments of this disclosure, the testing apparatus further includes a creation module, a determination module, and a second generation module. The creation module, in response to a test request from a client, uses the main thread to create a test case execution result registration table, which includes test case execution status information. The determination module, by scanning a delayed execution pending data table, determines that the test case execution status information is information used to characterize test completion if the amount of data in the delayed execution pending data table meets preset conditions. The second generation module, upon determining that the test case execution status is information used to characterize test completion, generates target test result information based on the first test result information and the second test result information.
[0038] Another aspect of this disclosure provides an electronic device, including: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the above-described test method.
[0039] Another aspect of this disclosure provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the above-described test method.
[0040] Another aspect of this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the above-described test method.
[0041] According to embodiments of this disclosure, by utilizing the main thread to call a target function to obtain first delay execution duration information from the target test script, and when the time interval between the current time information and the end time information of the previous test step is greater than the first delay execution duration, an asynchronous thread executes the next test step based on the test data obtained by the main thread from the previous test step, and generates target test result information based on the test results of the main thread and the asynchronous thread. Since the delay execution duration information between two test steps can be directly obtained from the target test script by calling the target function, and the asynchronous thread handles the test steps that need to be delayed, the processing progress of the main thread's test steps is not delayed, and there is no need to pre-configure too many asynchronous threads waiting to execute test steps. This improves script testing efficiency and resource utilization. Attached Figure Description
[0042] The foregoing contents, as well as other objects, features, and advantages of this disclosure, will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0043] Figure 1 The illustration schematically depicts application scenarios of test methods, apparatus, devices, media, and program products according to embodiments of the present disclosure;
[0044] Figure 2 A flowchart illustrating a test method according to an embodiment of the present disclosure is shown schematically;
[0045] Figure 3 This schematically illustrates a flowchart of a process according to an embodiment of the present disclosure, in which a first asynchronous thread executes the nth test step based on first test data to obtain second test result information.
[0046] Figure 4 This illustration schematically shows a flowchart of a process according to an embodiment of the present disclosure, in which the main thread obtains first delay execution duration information from a target test script by calling a target function;
[0047] Figure 5 This schematically illustrates a flowchart of generating target test result information based on first test result information and second test result information according to an embodiment of the present disclosure;
[0048] Figure 6 A logic block diagram of a test method according to an embodiment of the present disclosure is illustrated schematically;
[0049] Figure 7 A schematic block diagram of a test apparatus according to an embodiment of the present disclosure is shown; and
[0050] Figure 8 A block diagram schematically illustrates an electronic device suitable for implementing a test method according to an embodiment of the present disclosure. Detailed Implementation
[0051] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0052] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0053] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0054] When using expressions such as "at least one of A, B, and C", they should generally be interpreted in accordance with the meaning that is commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B, and C, etc.).
[0055] It should be noted that the testing methods and apparatus disclosed herein can be used in the financial field and the software testing technology field, as well as in any field other than the financial field and the software testing technology field. The application areas of the testing methods and apparatus disclosed herein are not limited.
[0056] The embodiments of this disclosure provide a testing method. By utilizing the main thread to call a target function, the method obtains first delay execution duration information from the target test script. If the time interval between the current time information and the end time information of the previous test step is greater than the first delay execution duration, an asynchronous thread executes the next test step based on the test data obtained by the main thread from the previous test step. Target test result information is then generated based on the test results from both the main thread and the asynchronous thread. Since the delay execution duration information between two test steps can be directly obtained from the target test script by calling the target function, and the asynchronous thread handles the test steps that require delay, the processing progress of the main thread's test steps is not delayed. Furthermore, it eliminates the need to pre-configure too many asynchronous threads waiting to execute test steps, thus improving both script testing efficiency and resource utilization.
[0057] Figure 1 The diagram illustrates an application scenario of the testing method according to an embodiment of the present disclosure.
[0058] like Figure 1 As shown, application scenario 100 according to this embodiment may include terminal devices 101, 102, and 103, network 104, and server 105. Network 104 is used as a medium to provide a communication link between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0059] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0060] Terminal devices 101, 102, and 103 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0061] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using terminal devices 101, 102, and 103 (for example only). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0062] It should be noted that the testing methods provided in this disclosure embodiment can generally be executed by server 105. Correspondingly, the testing apparatus provided in this disclosure embodiment can generally be located in server 105. The testing methods provided in this disclosure embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the testing apparatus provided in this disclosure embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105.
[0063] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0064] The following will be based on Figure 1 The described scene, through Figures 2-6 The testing methods of the disclosed embodiments are described in detail.
[0065] Figure 2 A flowchart illustrating a test method according to an embodiment of the present disclosure is shown schematically.
[0066] like Figure 2 As shown, the test method of this embodiment includes operations S210 to S240.
[0067] In operation S210, in response to a test request from the client, the main thread uses the target function to obtain the first delay execution duration information from the target test script. The first delay execution duration information represents the first preset time interval information between the start time information of the nth test step and the end time information of the (n-1)th test step, where n is a positive integer greater than 1.
[0068] According to embodiments of this disclosure, the target function can be the delayOperation method function, and the main thread can identify the first delay execution duration information, the (n-1)th test step information, and the nth test step information, etc., from the target test script by calling the delayOperation method.
[0069] According to embodiments of this disclosure, the first preset time interval information can be the system intermittent waiting time interval between the nth test step and the (n-1)th test step involved in the data processing system. For example, if the (n-1)th test step is test step A and the nth test step is test step B, and after test step A is completed, the system used to execute test step B processes data every 3 minutes, then the first preset time interval information Δt can be set to 3 minutes.
[0070] In operation S220, the main thread executes the (n-1)th test step to obtain the first test result information, which includes the first test data used to execute the nth test step and the execution end time information of the (n-1)th test step.
[0071] According to an embodiment of this disclosure, taking a money transfer test script as an example, the first test step can be a transfer step, and the second test step can be a data verification step. Executing the first test step using the main thread, the resulting first test result information may include the new transfer amount, the balance information of account A, the balance information of account B, and the end time t1 of completing the transfer transaction test from account A to account B. The first test data may include the new transfer amount, the balance information of account A, and the balance information of account B.
[0072] In operation S230, if the time interval between the first current time information and the execution end time information of the (n-1)th test step is greater than the first delay execution duration information, the first asynchronous thread executes the nth test step based on the first test data to obtain the second test result information.
[0073] According to an embodiment of this disclosure, the first current time can be the time when the execution end time information of the (n-1)th test step is obtained. For example, after waiting for a certain period of time according to a preset time period, the execution end time information of the (n-1)th test step is obtained by scanning the database or data table of the main thread at time t0.
[0074] According to an embodiment of this disclosure, when t0-t1>Δt, a first asynchronous thread performs a data verification step based on the new transfer amount, the balance information of account A, and the balance information of account B to obtain second test result information. The second test result information can be either accurate or inaccurate.
[0075] In operation S240, target test result information is generated based on the first test result information and the second test result information.
[0076] According to embodiments of this disclosure, the target test result information can be a test report for a test case, which may include the test results for each step in the test case, so that testers can know in a timely manner whether there are any abnormalities in the test nodes.
[0077] According to embodiments of this disclosure, by utilizing the main thread to call a target function to obtain first delay execution duration information from the target test script, and when the time interval between the current time information and the end time information of the previous test step is greater than the first delay execution duration, an asynchronous thread executes the next test step based on the test data obtained by the main thread from the previous test step, and generates target test result information based on the test results of the main thread and the asynchronous thread. Since the delay execution duration information between two test steps can be directly obtained from the target test script by calling the target function, and the asynchronous thread handles the test steps that need to be delayed, the processing progress of the main thread's test steps is not delayed, and there is no need to pre-configure too many asynchronous threads waiting to execute test steps. This improves script testing efficiency and resource utilization.
[0078] Figure 3 The flowchart illustrates a process according to an embodiment of the present disclosure, in which a first asynchronous thread executes the nth test step based on first test data to obtain second test result information.
[0079] like Figure 3 As shown, the method for performing the nth test step and obtaining the second test result information in this embodiment includes operations S310 to S340.
[0080] In operation S310, the first asynchronous thread uses the target function to obtain the second delay execution duration information from the nth test step. The second delay execution duration information represents the second preset time interval information between the execution start time information of the mth sub-test step and the execution end time information of the (m-1)th sub-test step, where m is a positive integer greater than 1.
[0081] According to embodiments of this disclosure, the nth test step may include m test sub-steps. These m test sub-steps may also be part of the target test script, for example, target test script A includes test step 1, test step 2, test step 3, and test step 4. The first delay execution duration information obtained by the main thread through calling the target function can be the delay waiting time interval between test step 1 and test step 2. In this case, test steps 2 through 4 can be considered as the second test step, and test step 1 as the first test step. When processing the second test step using an asynchronous thread, if the second delay waiting duration information between test step 3 and test step 4 is obtained by calling the target function, test steps 2 and 3 can be considered as the first sub-test step, and test step 4 as the second sub-test step.
[0082] According to embodiments of this disclosure, for example, in a payment scenario on a third-party trading platform, account A needs to pay M yuan to account B. The transaction is completed through the following steps: Step A: Deduct M yuan from account A; Step B: Transfer M yuan from account A to the third-party trading platform; Step C: Verify the transaction data between the third-party trading platform and account A; Step D: Transfer M yuan from the third-party trading platform to account B; Step E: Verify the transaction data between the third-party trading platform and account B. The first delay execution duration information obtained by the main thread through calling the target function can be the preset time interval information between steps B and C. At this time, steps A and B can be used as the first test step executed by the main thread; steps C to E can be used as the second test steps processed by the first asynchronous thread.
[0083] According to an embodiment of this disclosure, the second delay execution duration information obtained by the first asynchronous thread through calling the target function can be the preset time interval information between step D and step E. Step C and step D can be used as the first test sub-step processed by the first asynchronous thread, and step E can be used as the second test sub-step processed by the second asynchronous thread.
[0084] In operation S320, the first asynchronous thread executes the (m-1)th sub-test step based on the first test data to obtain the first sub-test result information. The first sub-test result information includes the second test data used to execute the m-th sub-test step and the execution end time information of the (m-1)th sub-test step.
[0085] According to embodiments of this disclosure, the second test data can be the result data generated after step D is completed, such as: the account balance of the third-party trading platform, the amount to be transferred, the balance of account B, and the account information of the third-party trading platform and account B, etc.
[0086] In operation S330, if the time interval between the second current time information and the execution end time information of the (m-1)th sub-test step is greater than the second preset time interval information, the second asynchronous thread is used to execute the m-th sub-test step according to the second test data to obtain the second sub-test result information.
[0087] According to embodiments of this disclosure, the second current time can be the time when the execution end time information of the (m-1)th sub-test step is obtained. For example, after waiting for a certain period of time according to a preset time interval, the execution end time information of the (m-1)th test step is obtained by scanning the database or data table of the first asynchronous thread at time t. 0’ .
[0088] According to embodiments of this disclosure, for example, if the data processing system of a third-party trading platform processes data every 5 minutes, then the second delay execution duration information Δt' can be 5 minutes. When t 0’ When -t2>Δt', the second asynchronous thread can be used to execute step E based on the second test data to obtain the second sub-test result information, where t2 is the end time of step D.
[0089] In operation S340, the second test result information is generated based on the first sub-test result information and the second sub-test result information.
[0090] According to embodiments of this disclosure, for example, the first sub-test result information can be the completion of a transaction in which a third-party platform pays M yuan to account B, and the second sub-test result information can be the verification that the transfer transaction data from the third-party platform to account B is correct, thereby generating the second test result information.
[0091] According to embodiments of this disclosure, a first asynchronous thread is used to obtain second delay execution duration information from n test steps by calling a target function. Under the condition of limited asynchronous thread resources, flexible allocation of test steps that need to wait for execution is realized, which can reduce the idle waiting time of asynchronous threads and improve resource utilization.
[0092] Figure 4 The flowchart illustrates a process according to an embodiment of the present disclosure, in which the main thread obtains first delay execution duration information from a target test script by calling a target function.
[0093] like Figure 4 As shown, the method for obtaining the first delay execution duration information in this embodiment includes operations S410 to S420.
[0094] When operating the S410, in response to a test request from the client, a delayed execution pending data table is obtained. The delayed execution pending data table includes delayed execution duration information corresponding to different test scripts. Each delayed execution duration information is obtained from the test script by the main thread through calling the target function.
[0095] According to embodiments of this disclosure, the delayed execution pending data table may include delayed execution duration information corresponding to different test scripts. For example, the delayed execution pending data table may include the test script class name, script case name, delayed execution duration information, timestamp, test step to be executed, test data required by the test step to be executed, execution status, etc. The timestamp can represent the moment when the test data required by the test step to be executed is obtained. For example, if test step B is the test step to be executed, and test step A is the previous test step of test step B, the timestamp can be the moment when test step A completes execution and generates the test data required by test step B.
[0096] When operating S420, the first delay execution duration information is obtained from the delayed execution pending data table based on the identification information of the target test script.
[0097] According to embodiments of this disclosure, the identification information of the target test script may include the test script class name and the script case name. By querying the delayed execution pending data table, the first delayed execution duration information can be determined.
[0098] According to embodiments of this disclosure, by establishing a delayed execution pending data table, the delayed execution duration information can be determined by querying the delayed execution pending data table, and the test steps that need to be delayed can be sent to an asynchronous thread for processing, thereby improving test efficiency.
[0099] According to embodiments of this disclosure, the above-described test method further includes:
[0100] When the first asynchronous thread obtains the second delay execution duration information from the nth test step by calling the target function, the second delay execution duration information is recorded in the delayed execution pending data table.
[0101] According to the embodiments of this disclosure, when using an asynchronous thread to process the nth test step, when the second delay execution duration information is obtained, the corresponding information can be recorded in the format of the delayed execution pending data table, so that the test steps that need to be delayed can be sent to other asynchronous threads for processing when the conditions for execution are met, saving the waiting time in the single-thread processing process and improving the testing efficiency.
[0102] According to embodiments of this disclosure, when the time interval between the first current time information and the execution end time information of the (n-1)th test step is greater than the first delay execution duration information, the first asynchronous thread executes the nth test step based on the first test data to obtain second test result information, including:
[0103] If the time interval between the first current moment information and the execution end moment information of the (n-1)th test step is greater than the first delay execution duration information, the first test data is obtained;
[0104] Send the first test data to the first asynchronous thread;
[0105] The first asynchronous thread executes the nth test step based on the first test data using a reflection mechanism to obtain the second test result information.
[0106] According to embodiments of this disclosure, the first test data obtained can be recorded in the test steps corresponding to the delayed execution pending data table, and the time when the first test data was generated can be recorded in the delayed execution pending data table in the form of a timestamp.
[0107] According to embodiments of this disclosure, test steps and corresponding test data that can be sent to asynchronous threads for processing can be determined by scanning a delayed execution pending data table. For example, if the time of scanning the delayed execution pending data table is T1, the execution end time information (i.e., timestamp) of the (n-1)th test step recorded in the delayed execution pending data table is T2, and the first delayed execution duration information is ΔT, when T1 - T2 > ΔT, it indicates that the system used to execute the nth test step can perform data processing, and the first test data can be sent to the first asynchronous thread.
[0108] According to an embodiment of this disclosure, after receiving the first test data, the first asynchronous thread can use Java's reflection mechanism to execute the nth test step.
[0109] According to the embodiments of this disclosure, by sending the first test data to the first asynchronous thread only when the time interval between the first current time information and the execution end time information of the (n-1)th test step is greater than the first delay execution duration information, the problem of resource waste caused by occupying too many threads to wait for test data to execute test steps in the process of using parallel threads for testing in related technologies can be effectively solved, thereby improving resource utilization and testing efficiency.
[0110] According to embodiments of this disclosure, a first asynchronous thread executes the nth test step based on the first test data using a reflection mechanism to obtain second test result information, including:
[0111] The first asynchronous thread is used to parse the first test data to obtain the test script parameter information used to execute the nth test step;
[0112] Based on the test script parameter information, the nth test step is executed through reflection mechanism to obtain the second test result information.
[0113] According to embodiments of this disclosure, the first test data may include test data for executing the nth test step and the name of the nth test step. A first asynchronous thread can be used to resolve the name of the nth test step in the first test data, obtaining test script parameter information such as the script class name, test method, and test parameter data for the nth test step. The nth test step is then executed using Java reflection to obtain the second test result information.
[0114] According to embodiments of this disclosure, for example, the name of the nth test step can be xxx.com.PayService_check, the script class name of the nth test step can be parsed to be "xxx.com.PayService", the test method is "check", and the test parameter data can include the test result data of the (n-1)th test step.
[0115] According to embodiments of this disclosure, by parsing the first test data, the script parameter information required to execute the next step can be directly obtained, so that the asynchronous thread can perform the next test step in a timely manner, thereby improving test efficiency.
[0116] Figure 5 The flowchart illustrating the generation of target test result information based on first test result information and second test result information according to an embodiment of the present disclosure is shown in the illustration.
[0117] like Figure 5 As shown, this embodiment includes operations S510 to S530.
[0118] When operating the S510, in response to a test request from the client, a test case execution result registration table is created using the main thread. The test case execution result registration table includes test case execution information.
[0119] When operating S520, by scanning the delayed execution pending data table, and if it is determined that the amount of data in the delayed execution pending data table meets the preset conditions, the test case execution status information is determined as information used to characterize the completion of the test.
[0120] In operation S530, if the test case execution status is determined to be information used to characterize the test completion, target test result information is generated based on the first test result information and the second test result information.
[0121] According to embodiments of this disclosure, a test case execution result registration table is created using the main thread, as shown in Table 1:
[0122]
[0123] According to the embodiments of this disclosure, before the main thread starts executing the target test script, a test case execution result registration table can be created and the script class name and script case name can be recorded. After the main thread completes the (n-1)th test step, if the nth test step in the first asynchronous thread is still being executed, the test case execution status in the test case execution result registration table will be "in execution".
[0124] According to embodiments of this disclosure, the data table to be processed during delayed execution is shown in Table 2:
[0125]
[0126] According to embodiments of this disclosure, the main thread can determine whether there is still data to be executed delayed by scanning the data volume in the delayed execution pending data table. Since both the main thread and the asynchronous thread can determine whether there are delayed test steps from the test script or test steps by calling the target function, and if a delayed test step is found, it is recorded in the delayed execution pending data table. Therefore, when the main thread scans the delayed execution pending data table and finds no data or the execution status in the delayed execution pending data table is "processed completed," it can be determined that the test case execution is complete. At this time, the test case execution completion can be recorded in the test case execution status of the test case execution result registration table, and target test result information can be generated based on the test results of all threads.
[0127] According to embodiments of this disclosure, by scanning the pending data table during delayed execution and generating the target test result information only after confirming that all tests of other asynchronous threads have been completed, the efficiency of executing large batches of scripts can be improved while ensuring the accuracy of test results.
[0128] Figure 6 A logic block diagram of a test method according to an embodiment of the present disclosure is shown schematically.
[0129] like Figure 6 As shown, this embodiment includes operations S601 to S610.
[0130] When operating S601, in response to a test request from the client, a data table to be processed with a delay is obtained.
[0131] In operation S602, the first delay execution duration information is obtained from the delayed execution pending data table based on the identification information of the target test script.
[0132] When operating S603, the main thread executes the (n-1)th test step to obtain the first test result information.
[0133] In operation S604, determine whether the time interval between the current moment and the timestamp is greater than the first delay execution duration. If yes, then execute operation S605; otherwise, execute operation S606.
[0134] Using S605, obtain the first test data.
[0135] In operation S606, scan the next data in the pending data table with a delay.
[0136] In operation S607, the first test data is sent to the first asynchronous thread.
[0137] When operating S608, the first asynchronous thread executes the nth test step based on the first test data through reflection mechanism to obtain the second test result information.
[0138] In operation S609, determine whether the preset conditions are met in the data table to be processed after the delay. If yes, then execute operation S610; otherwise, execute operation S606.
[0139] In operation S610, target test result information is generated based on the first test result information and the second test result information.
[0140] Based on the above testing method, this disclosure also provides a testing apparatus. The following will be combined with... Figure 7 The device is described in detail.
[0141] Figure 7 A schematic block diagram of a test apparatus according to an embodiment of the present disclosure is shown.
[0142] like Figure 7 As shown, the test apparatus 700 of this embodiment includes a first acquisition module 710, a first execution module 720, a second execution module 730, and a first generation module 740.
[0143] The first acquisition module 710 is used to respond to a test request from the client and, using the main thread, obtain first delay execution duration information from the target test script by calling the target function. This first delay execution duration information represents a first preset time interval between the start time of the nth test step and the end time of the (n-1)th test step, where n is a positive integer greater than 1. In one embodiment, the first acquisition module 710 can be used to perform the operation S210 described above, which will not be repeated here.
[0144] The first execution module 720 is used to execute the (n-1)th test step using the main thread to obtain first test result information. The first test result information includes first test data used to execute the nth test step and the execution end time information of the (n-1)th test step. In one embodiment, the first execution module 720 can be used to execute the operation S220 described above, which will not be repeated here.
[0145] The second execution module 730 is used to execute the nth test step based on the first test data using the first asynchronous thread when the time interval between the first current time information and the execution end time information of the (n-1)th test step is greater than the first delay execution duration information, thereby obtaining the second test result information. In one embodiment, the second execution module 730 can be used to execute the operation S230 described above, which will not be repeated here.
[0146] The first generation module 740 is used to generate target test result information based on the first test result information and the second test result information. In one embodiment, the first generation module 740 can be used to perform the operation S240 described above, which will not be repeated here.
[0147] According to embodiments of this disclosure, the second execution module includes a first acquisition unit, a first execution unit, a second execution unit, and a generation unit. The first acquisition unit is used to acquire second delayed execution duration information from the nth test step by calling a target function using a first asynchronous thread. The second delayed execution duration information represents a second preset time interval between the start time information of the mth sub-test step and the end time information of the (m-1)th sub-test step, where m is a positive integer greater than 1. The first execution unit is used to execute the (m-1)th sub-test step based on the first test data using the first asynchronous thread to obtain first sub-test result information. The first sub-test result information includes second test data used to execute the mth sub-test step and the end time information of the (m-1)th sub-test step. The second execution unit is used to execute the mth sub-test step based on the second test data using the second asynchronous thread when the time interval between the second current time information and the end time information of the (m-1)th sub-test step is greater than the second preset time interval information, thereby obtaining second sub-test result information. The generation unit is used to generate second test result information based on the first sub-test result information and the second sub-test result information.
[0148] According to embodiments of this disclosure, the second execution module includes a second acquisition unit, a sending unit, and a third execution unit. The second acquisition unit is used to acquire first test data when the time interval between the first current time information and the execution end time information of the (n-1)th test step is greater than the first delay execution duration information. The sending unit sends the first test data to a first asynchronous thread. The third execution unit is used to utilize the first asynchronous thread to execute the nth test step through a reflection mechanism based on the first test data to obtain second test result information.
[0149] According to embodiments of this disclosure, the third execution unit includes a parsing subunit and an execution subunit. The parsing subunit is used to parse the first test data using a first asynchronous thread to obtain test script parameter information for executing the nth test step. The execution subunit is used to execute the nth test step using a reflection mechanism based on the test script parameter information to obtain second test result information.
[0150] According to embodiments of this disclosure, the first acquisition module includes a third acquisition unit and a fourth acquisition unit. The third acquisition unit is used to acquire a delayed execution pending data table in response to a test request from a client. The delayed execution pending data table includes delayed execution duration information corresponding to different test scripts, and each delayed execution duration information is obtained from the test script by the main thread calling a target function. The fourth acquisition module is used to acquire first delayed execution duration information from the delayed execution pending data table based on the identification information of the target test script.
[0151] According to embodiments of this disclosure, the testing apparatus further includes a second acquisition module. This second acquisition module is configured to record the second delay execution duration information in a delay execution pending processing data table when the second delay execution duration information is obtained from the nth test step by calling a target function using a first asynchronous thread.
[0152] According to embodiments of this disclosure, the testing apparatus further includes a creation module, a determination module, and a second generation module. The creation module, in response to a test request from a client, uses the main thread to create a test case execution result registration table, which includes test case execution status information. The determination module, by scanning a delayed execution pending data table, determines that the test case execution status information is information used to characterize test completion if the amount of data in the delayed execution pending data table meets preset conditions. The second generation module, upon determining that the test case execution status is information used to characterize test completion, generates target test result information based on the first test result information and the second test result information.
[0153] According to embodiments of this disclosure, any plurality of modules among the first acquisition module 710, the first execution module 720, the second execution module 730, and the first generation module 740 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least a portion of the functionality of one or more of these modules may be combined with at least a portion of the functionality of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the first acquisition module 710, the first execution module 720, the second execution module 730, and the first generation module 740 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in a suitable combination of any of these. Alternatively, at least one of the first acquisition module 710, the first execution module 720, the second execution module 730, and the first generation module 740 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.
[0154] Figure 8 A block diagram schematically illustrates an electronic device suitable for implementing a test method according to an embodiment of the present disclosure.
[0155] like Figure 8 As shown, an electronic device 800 according to an embodiment of this disclosure includes a processor 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage portion 808 into a random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this disclosure.
[0156] RAM 803 stores various programs and data required for the operation of electronic device 800. Processor 801, ROM 802, and RAM 803 are interconnected via bus 804. Processor 801 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 802 and / or RAM 803. It should be noted that the programs may also be stored in one or more memories other than ROM 802 and RAM 803. Processor 801 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.
[0157] According to embodiments of this disclosure, the electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to a bus 804. The electronic device 800 may also include one or more of the following components connected to the I / O interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 810 as needed so that computer programs read from it can be installed into the storage section 808 as needed.
[0158] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.
[0159] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include ROM 802 and / or RAM 803 and / or one or more memories other than ROM 802 and RAM 803 described above.
[0160] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to cause the computer system to implement the item recommendation method provided in the embodiments of this disclosure.
[0161] When the computer program is executed by the processor 801, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0162] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and may be downloaded and installed via the communication section 809, and / or installed from a removable medium 811. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0163] In such an embodiment, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by processor 801, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0164] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0165] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0166] Those skilled in the art will understand that the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0167] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.
Claims
1. A test method, comprising: obtaining, by a main thread, first time-delay execution duration information from a target test script by calling a target function in response to a test request from a client, wherein the first time-delay execution duration information represents first preset time interval information between execution start time information of an n th test step and execution end time information of an (n-1) th test step, wherein n is a positive integer greater than 1; executing the (n-1) th test step by the main thread to obtain first test result information, wherein the first test result information includes first test data for executing the n th test step and the execution end time information of the (n-1) th test step; in a case where a time interval between first current time information and the execution end time information of the (n-1) th test step is greater than the first time-delay execution duration information, executing the n th test step according to the first test data by a first asynchronous thread to obtain second test result information; and generating target test result information according to the first test result information and the second test result information; wherein the n th test step includes m sub-test steps, and the executing the n th test step according to the first test data by the first asynchronous thread to obtain the second test result information comprises: obtaining, by the first asynchronous thread, second time-delay execution duration information from the n th test step by calling the target function, wherein the second time-delay execution duration information represents second preset time interval information between execution start time information of an m th sub-test step and execution end time information of an (m-1) th sub-test step, wherein m is a positive integer greater than 1; executing the (m-1) th sub-test step according to the first test data by the first asynchronous thread to obtain first sub-test result information, wherein the first sub-test result information includes second test data for executing the m th sub-test step and the execution end time information of the (m-1) th sub-test step; in a case where a time interval between second current time information and the execution end time information of the (m-1) th sub-test step is greater than the second preset time interval information, executing the m th sub-test step according to the second test data by a second asynchronous thread to obtain second sub-test result information; and generating the second test result information according to the first sub-test result information and the second sub-test result information.
2. The method of claim 1, wherein, the executing the n th test step according to the first test data by the first asynchronous thread to obtain the second test result information in the case where the time interval between the first current time information and the execution end time information of the (n-1) th test step is greater than the first time-delay execution duration information comprises: in the case where the time interval between the first current time information and the execution end time information of the (n-1) th test step is greater than the first time-delay execution duration information, obtaining the first test data; sending the first test data to the first asynchronous thread; and The first asynchronous thread is used to execute the nth test step according to the first test data through a reflection mechanism to obtain the second test result information.
3. The method of claim 2, wherein, The first asynchronous thread is used to execute the nth test step according to the first test data through a reflection mechanism to obtain the second test result information. The first asynchronous thread is used to parse the first test data to obtain test script parameter information used for executing the nth test step. The nth test step is executed through a reflection mechanism according to the test script parameter information to obtain the second test result information.
4. The method of claim 1, wherein, The first delay execution time length information is obtained from the target test script by calling the target function through the main thread in response to the test request from the client. The delay execution pending data table is obtained in response to the test request from the client, and the delay execution pending data table includes delay execution time length information corresponding to different test scripts. The first delay execution time length information is obtained from the delay execution pending data table according to the identification information of the target test script.
5. The method of claim 4, further comprising: In the case of obtaining the second delay execution time length information from the nth test step by calling the target function through the first asynchronous thread, the second delay execution time length information is recorded in the delay execution pending data table.
6. The method of claim 4, further comprising: The test case execution result registration table is created by the main thread in response to the test request from the client, and the test case execution result registration table includes test case execution information. The test case execution information is determined to be information representing test completion by scanning the delay execution pending data table when the amount of data in the delay execution pending data table meets a preset condition. The target test result information is generated according to the first test result information and the second test result information when the test case execution information is determined to be information representing test completion.
7. A test device, comprising: The first acquisition module is configured to obtain the first delay execution time length information from the target test script by calling the target function through the main thread in response to the test request from the client, wherein the first delay execution time length information represents first preset time interval information between execution start time information of the nth test step and execution end time information of the (n-1)th test step, and n is a positive integer greater than 1. The first execution module is configured to execute the (n-1)th test step by the main thread to obtain the first test result information, wherein the first test result information includes first test data used for executing the nth test step and the execution end time information of the (n-1)th test step. The second execution module is configured to execute the nth test step according to the first test data by using the first asynchronous thread to obtain second test result information in a case where a time interval between first current time information and execution end time information of the (n-1)th test step is greater than the first delay execution duration information. The first generation module is configured to generate target test result information according to the first test result information and the second test result information. The second execution module includes: The first acquisition unit is configured to acquire second delay execution duration information from the nth test step by calling the target function by using the first asynchronous thread, where the second delay execution duration information represents second preset time interval information between execution start time information of an mth sub-test step and execution end time information of an (m-1)th sub-test step, where m is a positive integer greater than 1. The first execution unit is configured to execute the (m-1)th sub-test step according to the first test data by using the first asynchronous thread to obtain first sub-test result information, where the first sub-test result information includes second test data used for executing the mth sub-test step and the execution end time information of the (m-1)th sub-test step. The second execution unit is configured to execute the mth sub-test step according to the second test data by using a second asynchronous thread to obtain second sub-test result information in a case where a time interval between second current time information and the execution end time information of the (m-1)th sub-test step is greater than the second preset time interval information. The generation unit is configured to generate the second test result information according to the first sub-test result information and the second sub-test result information. 8.An electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the method according to any one of claims 1-6. 9.A computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the method according to any one of claims 1-6. 10.A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-6.
Citation Information
Patent Citations
Cloud connected automated testing
CA2990074A1
Test method and device based on asynchronous threads
CN105607991A