Automatic testing method and computing device
By allocating test cases to the test environment and redistributing them when the status changes, the problem of waiting for the test environment in automated testing is solved, and testing efficiency and environment utilization are improved.
Patent Information
- Application Number
- CN202410877369.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-15
AI Technical Summary
In existing automated testing methods, the test time of each test case is different, causing the test environment to wait for other environments to complete the test, thereby reducing the efficiency of automated testing.
By assigning test cases to each test environment so that the difference between the total test duration and the preset target duration is less than or equal to the threshold, and redistributing when the test environment status changes, ensuring that each test environment is completed within a similar time Test and improve the efficiency of automated testing.
It realizes the release of each test environment in a similar time, improves the efficiency of automated testing, shortens the test cycle, and improves the utilization of the test environment.
Smart Images

Figure CN118779231A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of software testing, and in particular to an automated testing method and computing device. Background Art
[0002] Software automation testing refers to verifying the functionality, performance, and stability of a software system by writing scripts or using automated testing tools to simulate user operations.
[0003] In the related art, test cases are manually assigned to corresponding test environments for automated testing. However, the test time of each test case is different. After some test environments complete the test, they need to wait for other test environments to complete the test and jointly release the test environment for the next round of automated testing, which leads to relatively low efficiency of automated testing. Summary of the invention
[0004] The embodiments of the present application provide an automated testing method and a computing device to improve the efficiency of automated testing.
[0005] In a first aspect, an embodiment of the present application provides an automated testing method, which obtains multiple test cases and multiple test environments to be tested; assigns test cases to each test environment based on the test duration of each test case and the target preset duration of multiple test environments; wherein the difference between the total test duration of the test cases assigned to each test environment and the target preset duration is less than or equal to a preset first preset threshold; the test cases assigned in each test environment are automatically tested one by one, and the total test duration is the sum of the test time for a single test environment to complete the assigned test cases.
[0006] In this embodiment, when assigning test cases to the test environments, test cases with equal or similar total test time are assigned to each test environment, so that each test environment is released at a similar time to start the next round of automated testing, thereby improving the efficiency of automated testing.
[0007] In a possible implementation, the test cases are grouped according to the test environment and the test environment information of each test case; in each group, the test cases are allocated to the test environment according to the test duration of each test case and the target preset duration of the test environment.
[0008] In one possible implementation, the first state and the second state of each test environment are obtained according to the test progress of the test cases in each test environment. The first state indicates that all the test cases in the test environment have been tested, and the second state indicates that some test cases in the test environment have not been tested. The test environment in the first state is used as the first test environment, and the test environment in the second state is used as the second test environment. The test cases that have not been tested in the second test environment and are compatible with the first test environment are allocated to the corresponding first test environment for testing.
[0009] In an embodiment of the present application, taking into account the uncontrollable actual test time of each test case, after allocating test cases with equal total test time to the test environment, the status of each test environment is monitored, and the test cases in the test environment that have not completed the test are reallocated, so as to further shorten the time for each test environment to complete the test and improve the efficiency of automated testing.
[0010] In a possible implementation, a matching degree between the second test environment and the first test environment is obtained; when the matching degree is greater than or equal to a second preset threshold, some untested test cases in the second test environment are allocated to the first test environment for testing.
[0011] In one possible implementation, the test cases in the first test environment include test cases assigned at the first moment or test cases assigned at the second moment, and the test cases in the second test environment include test cases assigned at the second moment; the first moment is earlier than the second moment, and the state of the first test environment corresponding to the test cases assigned at the first moment at the second moment is the second state.
[0012] In one possible implementation, when the degree of match is greater than or equal to a second preset threshold, the remaining test time of the second test environment is obtained; when the remaining test time is greater than or equal to a third preset threshold, some untested test cases in the second test environment are allocated to the first test environment for testing.
[0013] In this embodiment, considering that it takes time to obtain the test cases that have not been tested and reallocate the test cases, for the test cases with a shorter remaining test time, the computing device leaves them in the original test environment to continue testing; for the test cases with a longer remaining test time, the computing device reallocates the test cases that have not been tested, thereby improving the efficiency of automated testing.
[0014] In one possible implementation, when the degree of match is greater than or equal to a second preset threshold, untested test cases in the second test environment are obtained; and untested test cases are allocated to the first test environment and the second test environment according to the test duration of each untested test case; wherein the difference between the total test duration of the untested test cases allocated to the first test environment and the total test duration of the untested test cases allocated to the second test environment is less than or equal to a fourth preset threshold.
[0015] In this embodiment, when the test cases that have not been tested are reallocated, the test cases with the same total test time are allocated to different test environments, so as to further shorten the time for each test environment to complete the test and improve the efficiency of the automated test.
[0016] In a possible implementation, after all test cases are tested, a test report is output; the test report includes the test time of the test case; and the information of the test case is updated according to the test report.
[0017] In a possible implementation, the test cases in each test environment and the execution order of each test case are obtained; and the status of the corresponding test environment is determined according to the status of the test case tested last.
[0018] In a second aspect, an embodiment of the present application provides an automation platform, which includes a management module and a scheduling module. The management module includes a first acquisition unit and a first allocation unit; the scheduling module includes a second acquisition unit and a second allocation unit; the first acquisition unit is used to obtain multiple test cases and multiple test environments to be tested. A first allocation unit is used to allocate test cases to each test environment according to the test time of each test case and the target preset time of multiple test environments; wherein the difference between the total test time of the test cases allocated to each test environment and the target preset time is less than or equal to a preset first preset threshold; each test environment performs automated testing on the allocated test cases one by one, and the total test time is the sum of the test time for a single test environment to complete the allocated test cases; a second acquisition unit is used to acquire the first state and the second state of each test environment according to the test progress of the test cases in each test environment, the first state indicating that the test cases in the test environment have been tested, and the second state indicating that the test cases in the test environment have not been tested; a second allocation unit is used to use the test environment in the first state as the first test environment and the test environment in the second state as the second test environment, and allocate the test cases that have not been tested in the second test environment and are adapted to the first test environment to the corresponding first test environment for testing.
[0019] In a third aspect, an embodiment of the present application provides a computing device, comprising: at least one memory for storing programs; and at least one processor for executing programs stored in the memory; wherein, when the program stored in the memory is executed, the processor is used to execute the automated testing method as described in any one of the first aspects.
[0020] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed on a computing device, the computing device executes any of the methods described in the first aspect above.
[0021] In a fifth aspect, an embodiment of the present application further provides a computer program product which, when executed on a computing device, executes the method as described in any one of the first aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 A schematic diagram of an application scenario of an embodiment of the present application;
[0024] Figure 2 A process of an automated testing method provided in an embodiment of the present application;
[0025] Figure 3 A flowchart of another automated testing method provided in an embodiment of the present application;
[0026] Figure 4 A schematic diagram of a test environment matching relationship provided in an embodiment of the present application;
[0027] Figure 5 A schematic diagram of another test environment matching relationship provided in an embodiment of the present application;
[0028] Figure 6 A schematic diagram of another test environment matching relationship provided in an embodiment of the present application;
[0029] Figure 7 A schematic diagram of the structure of an automation platform provided in an embodiment of the present application;
[0030] Figure 8 A schematic diagram of an automated testing method performed by an automated platform provided in an embodiment of the present application;
[0031] Fig. 9A schematic diagram of the structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] It should be noted that the embodiments described in this application are only part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0033] The terms "first" and "second" in the specification and claims of this application are used to distinguish different objects rather than to describe a specific order of objects. For example, first data and second data are used to distinguish different data rather than to describe a specific order of data.
[0034] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0035] In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more than two. For example, multiple processing units refer to two or more processing units, etc.; multiple elements refer to two or more elements, etc.
[0036] In order to make the following embodiments clear, the technical terms involved in this application are first introduced.
[0037] A test case (TC) is a part of software automation testing, which describes in detail how to perform a specific test, including preconditions, input data, test steps, expected results, and actual results.
[0038] Automation scripts are script programs written to automatically perform a series of tasks or tests.
[0039] The automation platform is a comprehensive system that integrates multiple automation testing tools and technologies to provide a testing environment for automation testing.
[0040] The execution machine is the device or system that runs the automated test scripts.
[0041] The system under test (SUT) is the core object of the testing activity, that is, the system being tested.
[0042] Testing Environment (TE) is a description of the software and hardware environment in which the test is run, including the operating system, database, network configuration, and other software components that interact with the software under test.
[0043] The embodiment of the present application provides an automated testing method and computing device. One or more test cases with equal total test time are allocated to different test environments, so that the time for each test environment to complete the test case is basically the same, each test environment can be released at the same time, the test environment is fully utilized, and the efficiency of automated testing is improved.
[0044] To facilitate understanding of the technical solution of the present application, the application scenarios of the embodiments of the present application are introduced below.
[0045] For example, Figure 1 A schematic diagram of an application scenario of an embodiment of the present application is shown in FIG. Figure 1 As shown, each time a software program (such as firmware, driver, etc.) in the server 10 is updated, it is necessary to test the function, serviceability, reliability, etc. of the server 10. During the test, the management device or automation platform of the server 10, for example Figure 1 The computing device 20 shown in the figure distributes the test cases with the same total test time to different test environments to perform automated testing on the test cases.
[0046] The test cases include TC1, TC2, TC3, TC4, TC5, TC6, TC7 and TC8. The test durations corresponding to the test cases TC1, TC2, TC3, TC4, TC5, TC6, TC7 and TC8 are 10s, 25s, 10s, 30s, 25s, 10s, 35s and 10s respectively. The test environments corresponding to the test cases TC1, TC2, TC3, TC4, TC5, TC6, TC7 and TC8 are TE1, TE1, TE1, TE2, TE2, TE3 and TE3 respectively. If the preset duration corresponding to the test environment is 35s, TC1 and TC2 are allocated to the test environment TE1, TC5 and TC6 are allocated to the test ring TE2, and TE7 is allocated to the test environment TE3. If the total test duration of the test cases in the test environments TE1, TE2, and TE3 is inconsistent, for example, the test cases in the test environment TE1 are tested first, and the test environments TE2 and TE3 are still in the testing stage, the test environment TE1 will wait for the test environments TE2 and TE3 to complete the test and be released together. If the total test time of the test cases in the test environments TE1, TE2, and TE3 in the embodiment of the present application is consistent, the test environments TE1, TE2, and TE3 will be released at the same time and quickly enter the next round of automated testing, thereby improving the efficiency of automated testing.
[0047] It can be understood that the computing device 20 can be a personal computer (PC), a physical server, a cloud server, or a virtual device (such as a virtual machine), etc., but is not limited thereto.
[0048] Next, based on the above description, an automated testing method provided by an embodiment of the present application is introduced. It can be understood that the method is proposed based on the above description, and part or all of the contents of the method can be referred to the above description.
[0049] See also Figure 2 , Figure 2 It is a flowchart of an automated testing method provided in an embodiment of the present application. It is understood that the method can be executed by any device, equipment, platform, or device cluster with computing and processing capabilities, for example, Figure 1 The above example is also used as an example to illustrate the above. Figure 2 As shown, the method may include:
[0050] S210: The computing device obtains multiple test cases and multiple test environments to be tested.
[0051] In one possible implementation, the test case and the test environment are respectively stored in a use case information repository and a test environment information repository. The computing device obtains the test case from the use case information repository based on the identification information of the test case and stores the obtained test case in a corresponding storage area, and obtains the test environment from the test environment information repository based on the identification information of the test environment.
[0052] Exemplarily, the test case information library and the test environment information library described in the embodiments of the present application can be a relational database or a non-relational database. Among them, relational databases include MySQL, Oracle, SQLServer, PostgreSQL and SQLite; non-relational databases include MongoDB and Redis. It should be understood that the relational database and non-relational database described in the embodiments of the present application are merely exemplary.
[0053] S220: The computing device allocates test cases to each test environment according to the test duration of each test case and the target preset duration of multiple test environments; wherein the difference between the total test duration of the test cases allocated to each test environment and the target preset duration is less than or equal to a preset first preset threshold; the test cases allocated to each test environment are automatically tested one by one, and the total test duration is the sum of the test time for a single test environment to complete the allocated test cases.
[0054] Among them, the target preset duration of the test environment is the expected duration of each test environment for the total test duration of the test cases in this round of automated testing. For the same round of automated testing, the expected durations set for each test environment are consistent, that is, the target preset durations of each test environment are the same or similar. It should be understood that the target preset duration of the test environment in the embodiment of the present application can be set or adjusted according to the needs of the user.
[0055] The first preset threshold may represent the error value between the total test duration of the test case and the target preset duration, and ideally the first preset threshold may be 0. Considering the existence of the error, the first preset threshold in the embodiment of the present application may be set or adjusted according to user needs.
[0056] In a possible implementation, the test cases are grouped according to the test environment and the test environment information of each test case; in each group, the test cases are allocated to the test environment according to the test duration of each test case and the target preset duration of the test environment.
[0057] The test environment information includes the resources required for the test case, such as hardware devices and software platforms. The hardware devices include servers, storage devices or network devices, and the software platforms include operating systems, databases, middleware and tested software. The test environment information can be stored in the test case information library in the form of fields. The computing device obtains the test time of the test case and the test environment information of the test case through the fields corresponding to the test time and the fields corresponding to the test environment.
[0058] Next, the present application embodiment will explain S220 through the following two steps:
[0059] The first step is to match the test environment information with the test environment. If the test environment matches the test environment information, the corresponding test cases are divided into the groups corresponding to the test environment. Then, all test cases in the corresponding groups can be automatically tested in the corresponding test environment.
[0060] In a possible implementation, the matching degree between the test environment information and the test environment can be determined based on one or more of the configuration matching degree MD1, the network environment matching degree MD2, and the tool and framework matching degree MD3 between the test environment information and the test environment.
[0061] Configuration matching degree MD1 is used to describe the matching degree between the test environment information and the hardware configuration, operating system version, software dependencies, etc. of the test environment. A higher configuration matching degree MD1 can eliminate the deviation of test results caused by configuration differences in the test environment and ensure the comparability and repeatability of the test.
[0062] The network environment matching degree MD2 is used to describe the matching degree between distributed systems or network applications. The network environment between the test environment information and the test environment should be as similar as possible, including parameters such as bandwidth, delay, and packet loss rate. A higher network environment matching degree MD2 can simulate the usage scenarios of real users and ensure the accuracy of the test results.
[0063] The tool and architecture matching degree MD3 is used to describe the matching degree between the tools and frameworks used in the test environment. A higher tool and architecture matching degree MD3 can ensure the compatibility of test scripts and test cases in different environments and reduce test problems caused by tool or framework differences.
[0064] Exemplarily, if any one of the configuration matching degree MD1, the network environment matching degree MD2, and the tool and framework matching degree MD3 is greater than or equal to a preset threshold, it means that the test environment matches the test environment information.
[0065] Exemplarily, if the average or weighted average of any two or three of the configuration matching degree MD1, the network environment matching degree MD2, and the tool and framework matching degree MD3 is greater than or equal to a preset threshold, it means that the test environment matches the test environment information.
[0066] In the second step, in each group, test cases are assigned to the test environments according to the test duration of each test case and the target preset duration of the test environment.
[0067] For example, in the test case group corresponding to TE1, the preset duration of test environment TE1 is 25s, and the test durations of test cases TC1, TC2, and TC3 are 10s, 25s, and 10s, respectively. Then, test cases TC1 and TC2 are assigned to test environment TE1 for the next round of automated testing, or test cases TC2 and TC3 are assigned to test environment TE1 for the next round of automated testing.
[0068] In an embodiment of the present application, by allocating test case combinations with equal total test time to corresponding test environments for automated testing, the test environment can complete the testing of the test cases and release the test environment within a similar or identical time, so that the test environment can quickly enter the next round of automated testing, thereby improving the efficiency of automated testing.
[0069] In order to avoid the difference in the actual test time of the test cases in the test environment, the embodiment of the present application provides another automated testing method, and the corresponding flowchart is shown in FIG. Figure 3 .
[0070] like Figure 3 As shown, the method includes:
[0071] S310: The computing device obtains multiple test cases and multiple test environments to be tested.
[0072] S320: The computing device allocates a test case to each test environment according to the test duration of each test case and the target preset durations of the multiple test environments.
[0073] S330: The computing device obtains the status of each test environment, and determines the first test environment and the second test environment according to the status of the test environment.
[0074] The state of the test environment includes a first state and a second state, wherein the first state indicates that all test cases in the test environment have been tested, and the second state indicates that some test cases in the test environment have not been tested. Correspondingly, the test environment in the first state is determined as the first test environment, and the test environment in the second state is determined as the second test environment.
[0075] In a possible implementation, the computing device determines the state of the test environment according to the test state of the test case. First, the computing device obtains the test cases in the test environment and the test order of each test case; then the computing device determines the state of the test environment according to the state of the last test case.
[0076] The test cases can be tracked by using test case management tools, such as TestRail, Jira, and ALM, etc. The status of the test case includes not started, in progress, and passed, etc. These statuses are recorded in the test case management tool.
[0077] Exemplarily, the test cases tested in the test environment TE1 include test cases TC1, TC2 and TC3, and the test sequence is TC1-TC2-TC3. When the status of TC3 is that the test has not started, the status of the test environment TE1 is the second status; when the status of TC3 is that the test has passed, the status of the test environment TE1 is the first status.
[0078] The time point when the computing device allocates the test case this time is taken as the second time point tp2, and the time point when the test case was allocated last time is taken as the first time point tp1. Considering that the test environment will be used repeatedly in automated testing, and the actual test time of the test case is uncontrollable, some test environments test the test cases allocated at the first time point tp1, and some test environments test the test cases allocated at the second time point tp2.
[0079] For ease of understanding, for example, all test environments include: TE1, TE2, TE3, TE4 and TE5, and the test environments that are not assigned test cases at the second time point tp2 include TE1, TE2 and TE3, while the test cases in TE4 and TE5 are assigned at the first time point tp1, and have not been tested at the second time point tp2. In order to maximize the use of all test environments, in an embodiment of the present application, the computing device obtains the status of all test environments, and once the test case is tested, the corresponding test environment is released and used as the first test environment to share the test of the test case in the second test environment, so as to improve the efficiency of automated testing.
[0080] It should be noted that the computing device in the embodiment of the present application may obtain the status of each test environment periodically or in real time.
[0081] S340: The computing device obtains a matching degree between the second test environment and the first test environment.
[0082] In a possible implementation, the matching degree between the second test environment and the first test environment may be determined based on one or more of a configuration matching degree MD1, a network environment matching degree MD2, and a tool and framework matching degree MD3 between the second test environment and the first test environment.
[0083] Exemplarily, any one of the configuration matching degree MD1, the network environment matching degree MD2, and the tool and framework matching degree MD3 is greater than or equal to the second preset threshold, which means that some test cases that have not been tested in the second test environment can be allocated to the first test environment for testing.
[0084] Exemplarily, the average value or weighted average value of any two or three of the configuration matching degree MD1, the network environment matching degree MD2, and the tool and framework matching degree MD3 is greater than or equal to the second preset threshold, which means that some test cases that have not been tested in the second test environment can be allocated to the first test environment for testing.
[0085] S350: The computing device determines test cases that have not been tested in the second test environment, and reallocates the test cases that have not been tested.
[0086] Since the number of first test environments and the number of second test environments whose matching degree is greater than or equal to the preset second threshold value are uncertain, the embodiments of the present application will be described respectively through the following possible implementation methods:
[0087] (1) The number of the first test environment is one, and the number of the second test environment is one. Figure 4As shown, the first test environment is TE1 and the second test environment is TE2. The total test duration of TC1 and TC2 is consistent with the total test duration of TC3 and TC4.
[0088] Exemplarily, after testing of TC1 and TC2 in the first test environment is completed, the computing device may reallocate the test cases that have not been tested in the second test environment TE2; if TC3 in the second test environment TE2 is being tested and TC4 has not been tested, TC4 will be allocated to the first test environment TE1 for testing.
[0089] It should be understood that when there are multiple test cases that have not been tested in the second test environment TE2, the untested test cases are reallocated according to their test time, so that the test time of the untested test cases allocated to the first test environment TE1 and the test time of the untested test cases remaining in the second test environment TE2 are basically the same, which can shorten the time for the first test environment TE1 and the second test environment TE2 to complete the test cases, thereby improving the efficiency of automated testing.
[0090] (2) The number of the first test environment is one, and the number of the second test environment is multiple. Figure 5 As shown, the first test environment is TE1, and the second test environment includes test environments TE2, TE3, and TE4, that is, the matching degree between TE1 and TE2, TE3, and TE4 is greater than the second preset threshold. Among them, the total test duration of TC1 and TC2, the total test duration of TC5 and TC6, the total test duration of TC3, and the total test duration of TC7, TC8, and TC9 are all the same.
[0091] Exemplarily, TC1 and TC2 in the first test environment TE1 are both tested, and the computing device selects the test environment with the highest match with TE1, such as TE2 (TC5 in TE2 is being tested, and TC6 has not been tested); the computing device allocates the test case TC6 that has not been tested in TE2 to the first test environment TE1 for testing.
[0092] In addition, all untested test cases in the second test environment TE2, TE3 and TE4 can be reallocated so that TE1, TE2, TE3 and TE4 complete the test at the same time and are released at the same time, thereby improving the utilization of the test environment.
[0093] (3) There are multiple first test environments and multiple second test environments. Figure 6As shown, the first test environment includes TE1 and TE2, and the second test environment includes TE3 and TE4. The total test duration of TC1 and TC2, the total test duration of TC5 and TC6, the total test duration of TC3, and the total test duration of TC7, TC8, and TC9 are all the same.
[0094] The matching degree between TE1 and TE3 is greater than the second preset threshold, and the matching degrees between TE3 and TE4 are both greater than the second preset threshold.
[0095] Exemplarily, in the second test environment TE4, TC7 completes the test, but TC8 and TC9 do not complete the test, and the test cases of TC8 and TC9 are reallocated.
[0096] In order to release all test environments at similar time points to test subsequent test cases, the computing device in the embodiment of the present application allocates test cases with the same or similar test times to the first test environment and the second test environment.
[0097] Exemplarily, the state of the first test environment TE1 is the first state (all test cases in the test environment have been tested), and the state of the second test environment TE2 is the second state (there are test cases in the test environment that have not been tested). For example, the test cases that have not been tested include test cases TC1, TC2 and TC3, the test time of TC1 is t1, the test time of TC2 is t2, the test time of TC3 is t3, t1+t2=t3, then the test cases TC1 and TC2 are assigned to the first test environment TE1 for testing, and the test case TC3 is left in the second test environment TE2 for testing (the difference between the total test time t1+t2 of the untested test cases assigned by the first test environment and the total test time t3 of the untested test cases assigned by the second test environment is less than or equal to the fourth preset threshold, wherein the fourth preset threshold can be set or modified according to the needs of the user); or the test cases TC1 and TC2 are left in the second test environment TE2 for testing, and the test case TC3 is assigned to the first test environment TE1 for testing.
[0098] It should be understood that the test time of the test case is not available in the information of all test cases. Therefore, when the test time of the test case is not available, the number of test cases allocated in each test environment can be made consistent.
[0099] Exemplarily, the test cases that are not tested in the second test environment TE2 include TC1, TC2, TC3 and TC4. When the test time of the test cases is not available, the computing device may allocate any two test cases from TC1, TC2, TC3 and TC4 to the first test environment TE1 for testing, and the other two test cases remain in the second test environment for testing.
[0100] Because some test cases are related to each other, for example, test case TC2 is tested only after TC1 is completed, it is necessary to consider allocating TC1 and TC2 to the same test environment.
[0101] In addition, considering that it takes time to obtain untested test cases and to redistribute test cases, for test cases with a shorter remaining test time, the computing device leaves them in the original test environment for continued testing; for test cases with a longer remaining test time, the computing device redistributes the untested test cases, thereby improving the efficiency of automated testing. It should be noted that the embodiment of the present application does not limit the step of determining the remaining test time of the test case, that is, this step can be located before or after the determination of the matching degree.
[0102] It should be understood that the remaining test time of the test environment can be obtained according to the test time of the test cases that have not been tested.
[0103] Exemplarily, the remaining test time of the test environment TE1 is t1, and the third preset threshold is t2. If t1≥t2, the computing device reallocates the test cases that have not been tested in TE1 and allocates them to the corresponding first test environment and second test environment for testing; if t1<t2, the computing device allows the test cases that have not been tested in TE1 to continue to be tested in TE1. The third preset threshold can be set or modified according to user needs.
[0104] S360: The computing device allocates each untested test case to the first test environment and the second test environment for testing.
[0105] In a possible implementation, the untested test cases include TC1 and TC2, and there is only one second test environment matching the first test environment TE1, for example, TE2. The computing device assigns TC1 to the first test environment TE1 for testing, and assigns TC2 to the second test environment TE2 for testing.
[0106] In a possible implementation, the test cases that are not tested include TC1, TC2, TC3, and TC4, and there are multiple second test environments matching the first test environment TE1, such as TE2, TE3, and TE4. The computing device assigns TC1 to the first test environment TE1 for testing, assigns TC2 to the second test environment TE2 for testing, assigns TC3 to the first test environment TE3 for testing, and assigns TC4 to the second test environment TE4 for testing.
[0107] In the embodiment of the present application, once the test cases in the test environment are tested, the computing device can use them to share some of the test cases that have not been tested in other test environments, thereby improving the utilization rate of the test environment and thus improving the efficiency of automated testing. In addition, in the embodiment of the present application, based on the information of the test cases (adapted test environment, preset conditions of the test environment) and the test environment to which the test cases are not assigned, the automatic allocation between the test cases and the test environment is realized without intervention, thereby improving the efficiency of automated testing.
[0108] S370: The computing device outputs a test report, and updates information of the test case based on the test report.
[0109] A test report usually includes test plan, test requirements, test cases, test environment, test execution, test results, and problem analysis. A test report generally lists in detail the problems found during the test, including a description of the problem, steps to reproduce the problem, expected results, and actual results. At the same time, the report will also classify and count the problems so that the development team can understand the distribution of the problems and develop targeted repair plans.
[0110] In the above embodiment, a corresponding description is made by taking testing one test case in each test environment as an example, but the test environment in the embodiment of the present application can be assigned multiple test cases. When the test environment is assigned multiple test cases, the corresponding automated tests are the same as those in the above embodiment, and will not be repeated here.
[0111] In addition, the test report also includes the test time of each test case, and the information of the test case is updated based on the test time, so that the next time the test case is used, a test case with basically the same test time can be obtained according to the time of the corresponding test case.
[0112] In addition, an embodiment of the present application also provides an automation platform.
[0113] See also Figure 7 , Figure 7 A schematic diagram of the structure of an automation platform provided in an embodiment of the present application.
[0114] like Figure 7As shown, the automation platform includes a management module 710 and a scheduling module 720. The management module includes a first acquisition unit 711 and a first allocation unit 712; the scheduling module 720 includes a second acquisition unit 721 and a second allocation unit 722.
[0115] The first acquisition unit 711 is used to obtain multiple test cases and multiple test environments to be tested.
[0116] The first allocation unit 712 is used to allocate test cases to each test environment according to the test time of each test case and the target preset time of multiple test environments; wherein the difference between the total test time of the test cases allocated to each test environment and the target preset time is less than or equal to a preset first preset threshold; each test environment performs automated testing on the allocated test cases one by one, and the total test time is the sum of the test time for a single test environment to complete the allocated test cases.
[0117] A second acquisition unit 721 is used to acquire a first state and a second state of each test environment according to the test progress of the test case in each test environment, wherein the first state indicates that the test case in the test environment has been tested, and the second state indicates that the test case in the test environment has not been tested;
[0118] The second allocation unit 722 is used to use the test environment in the first state as the first test environment and the test environment in the second state as the second test environment, and allocate the test cases that have not been tested in the second test environment and are adapted to the first test environment to the corresponding first test environment for testing.
[0119] It should be noted that the information of the test case (adapted test environment, preset conditions for the test environment) can be obtained from the test case information library according to the field information corresponding to the test case; similarly, the relevant information of the test environment can be obtained from the test environment information library according to the corresponding fields.
[0120] Optionally, the second allocation unit 722 is specifically used to obtain the matching degree between the second test environment and the first test environment; when the matching degree is greater than or equal to a second preset threshold, some untested test cases in the second test environment are allocated to the first test environment for testing.
[0121] Optionally, the test cases tested in the first test environment include test cases assigned at the first moment or test cases assigned at the second moment, and the test cases tested in the second test environment include test cases assigned at the second moment; the first moment is earlier than the second moment, and the state of the first test environment corresponding to the test cases assigned at the first moment at the second moment is the second state.
[0122] Optionally, the second allocation unit 722 is specifically used to obtain the remaining test time of the second test environment; when the remaining test time is greater than a third preset threshold, allocate some untested test cases in the second test environment to the first test environment for testing.
[0123] Optionally, the second allocating unit 722 is specifically configured to obtain test cases in the second test environment; and allocate untested test cases to the first test environment and the second test environment for testing.
[0124] Optionally, the scheduling module 720 is further used to output a test report after all test cases are tested; the test report includes the test time of the test case; and the information of the test case is updated according to the test report.
[0125] Optionally, the second acquisition unit 721 is specifically configured to acquire the test cases in each test environment and the test order of each test case; and determine the status of the corresponding test environment according to the status of the test case tested last.
[0126] For ease of understanding, the present application embodiment provides a schematic diagram of an automated platform executing an automated testing method, such as Figure 8 shown.
[0127] like Figure 8 As shown, the management module 710 obtains TC1, TC2, TC3, TC4, TC5, TC6, TC7 and TC8, and allocates TC1 and TC2 to the test environment TE1, allocates TC6, TC7 and TC8 to the test environment TE2, and allocates TC3 and TC4 to TE3 for testing; the scheduling module 720 obtains the status of each test environment, matches the test environments TE1 and TE3 in the first state, and TE3 with the test environment TE2 in the second state, and if the match is successful, the untested test cases (TC7 and TC8) in the test environment TE2 are reallocated; finally, TC7 is allocated to the test environment TE1, and TC8 is left in the test environment TE3 for testing.
[0128] See also Fig. 9 , which is a schematic diagram of the structure of a computing device provided in an embodiment of the present application.
[0129] like Fig. 9 As shown, the computing device includes:
[0130] At least one memory 910, used to store programs;
[0131] At least one processor 920 is used to execute the program stored in the memory 910; wherein, when the program stored in the memory 910 is executed, the processor 910 is used to execute the automated testing method as described in any of the aforementioned embodiments.
[0132] In addition, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed on a computing device, the computing device executes the automated testing method described in any of the aforementioned embodiments.
[0133] In addition, an embodiment of the present application also provides a computer program product, which, when running on a computing device, executes the automated testing method described in any of the aforementioned embodiments.
[0134] Through the description of the above implementation methods, it can be known that those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment method can be implemented by means of software plus a general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM) / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment of the present application or some parts of the embodiments.
[0135] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.
[0136] The above description is merely an exemplary embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. An automated testing method, characterized in that: The method comprises: Obtain multiple test cases and multiple test environments to be tested; Allocate a test case to each test environment according to the test duration of each of the test cases and the target preset durations of the multiple test environments; wherein the difference between the total test duration of the test case allocated to each test environment and the target preset duration is less than or equal to a preset first preset threshold; Perform automated testing on the test cases assigned to each test environment.
2. The method according to claim 1, characterized in that The allocating a test case to each test environment according to the test duration of each test case and the target preset duration of the multiple test environments specifically includes: Grouping the test cases according to the test environment and the test environment information of the test cases; In each group, test cases are allocated to the test environment according to the test duration of each of the test cases and the target preset duration of the test environment.
3. The method according to claim 1, characterized in that The method further comprises: Acquire a first state and a second state of each of the test environments according to the test progress of the test cases in each of the test environments, wherein the first state indicates that all of the test cases in the test environment have been tested, and the second state indicates that some of the test cases in the test environment have not been tested; The test environment in the first state is used as the first test environment, and the test environment in the second state is used as the second test environment. Test cases that have not been tested in the second test environment and are adapted to the first test environment are allocated to the corresponding first test environment for testing.
4. The method according to claim 3, characterized in that The allocating the test cases that have not been tested in the second test environment and are adapted to the first test environment to the corresponding first test environment for testing includes: Obtaining a degree of matching between the second test environment and the first test environment; When the matching degree is greater than or equal to a second preset threshold, some of the test cases that have not been tested in the second test environment are allocated to the first test environment for testing.
5. The method according to claim 3, characterized in that: The test cases in the first test environment include test cases assigned at a first moment or test cases assigned at a second moment, and the test cases in the second test environment include test cases assigned at the second moment; The first moment is earlier than the second moment, and the state of the first test environment corresponding to the test case allocated at the first moment at the second moment is the second state.
6. The method according to claim 4, characterized in that When the matching degree is greater than or equal to a second preset threshold, allocating some untested test cases in the second test environment to the first test environment for testing includes: When the matching degree is greater than or equal to a second preset threshold, obtaining the remaining test time of the second test environment; When the remaining test time is greater than or equal to a third preset threshold, some of the test cases that have not been tested in the second test environment are allocated to the first test environment for testing.
7. The method according to claim 4, characterized in that When the matching degree is greater than or equal to a second preset threshold, allocating some untested test cases in the second test environment to the first test environment for testing includes: When the matching degree is greater than or equal to a second preset threshold, obtaining test cases that have not been tested in the second test environment; Allocate the untested test cases to the first test environment and the second test environment according to the test duration of each of the untested test cases; wherein the difference between the total test duration of the untested test cases allocated to the first test environment and the total test duration of the untested test cases allocated to the second test environment is less than or equal to a fourth preset threshold.
8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: After all the test cases are tested, a test report is output; the test report includes the test time of the test cases; The test time of the test case is updated according to the test report.
9. The method according to claim 3, characterized in that: The obtaining the first state and the second state of each of the test environments according to the test progress of the test case in each of the test environments includes: Obtaining the test cases in each of the test environments and the test order of each of the test cases; According to the state of the test case tested last, the first state and the second state of the corresponding test environment are obtained.
10. A computing device, characterized in that include: at least one memory for storing a program; At least one processor is used to execute the program stored in the memory; wherein, when the program stored in the memory is executed, the processor is used to execute the automated testing method as described in any one of claims 1-9.
