CN114911714A - Method, device, electronic equipment and medium for calculating test resources - Google Patents

Method, device, electronic equipment and medium for calculating test resources Download PDF

Info

Publication number
CN114911714A
CN114911714A CN202210681484.5A CN202210681484A CN114911714A CN 114911714 A CN114911714 A CN 114911714A CN 202210681484 A CN202210681484 A CN 202210681484A CN 114911714 A CN114911714 A CN 114911714A
Authority
CN
China
Prior art keywords
test
task
time
case
test case
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210681484.5A
Other languages
Chinese (zh)
Inventor
林之舜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sangfor Technologies Co Ltd
Original Assignee
Sangfor Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sangfor Technologies Co Ltd filed Critical Sangfor Technologies Co Ltd
Priority to CN202210681484.5A priority Critical patent/CN114911714A/en
Publication of CN114911714A publication Critical patent/CN114911714A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Tests Of Electronic Circuits (AREA)

Abstract

The application discloses a method, a device, electronic equipment and a medium for calculating test resources, and relates to the field of automatic testing. The method comprises the steps of obtaining a first test task corresponding to each test module when each test module depends on each test environment; merging the test cases in the first test task depending on the same test environment to obtain a second test task; acquiring the number of test cases in the first test task which is not merged and the number of second test tasks; the sum of the number of test cases in the first test task that are not merged and the number of second test tasks is taken as the number of test environments required to execute the test cases. In the method, the execution time of each test task is less than or equal to the preset time; considering that the test cases may share the same test background and test environment, the minimum test environment resource required for completing the test case execution within the preset time is calculated, so that the waste of the resource is reduced, and the expected execution efficiency of the user is achieved.

Description

Method, device, electronic equipment and medium for calculating test resources
Technical Field
The present application relates to the field of automated testing, and in particular, to a method, an apparatus, an electronic device, and a medium for calculating a test resource.
Background
With the increase of the number of automated test cases, the requirements for the time and efficiency for executing the automated test cases are higher and higher. The execution of the automated test cases is typically required to be completed within a user-specified length of time.
A plurality of automatic test cases are contained in one test module, and usually, in order to meet the requirement of automatic tests required by release of versions within a specified time, the test cases can be distributed to as many test environments as possible to be executed without cost. Because information association may exist among the test cases in the test module, such as the same or similar execution steps or shared resources, if the information association among the test cases is ignored, the configuration reusability of the test environment may be low, the operation is redundant, and further, the resource waste may exist; in addition, when the test environment is concurrently established in a plurality of test environments, the number of the whole automatic test resources is increased due to the establishment of the test environments, and the resource waste is caused.
Therefore, it is an urgent problem to be solved by those skilled in the art how to reduce the waste of resources as much as possible and achieve the execution efficiency expected by the user.
Disclosure of Invention
The application aims to provide a method, a device, electronic equipment and a medium for calculating test resources, which are used for ensuring that the execution of a test case is completed within specified time as much as possible, maximizing the utilization rate of a test environment and avoiding resource waste.
In order to solve the above technical problem, the present application provides a method for reckoning test resources, including:
obtaining each test module and a test environment which is depended by each test case in the test module;
acquiring a first test task corresponding to each test module when the test module depends on each test environment according to a first preset rule; the first preset rule is that the same first test task shares the same test background, and the execution time of each first test task is less than or equal to a preset time length;
merging the test cases in the first test task depending on the same test environment according to a second preset rule so as to obtain a second test task; the second preset rule is that the execution time of each second test task is less than or equal to the preset time length;
acquiring the number of the test cases in the first test task which are not merged and the number of the second test tasks;
and taking the sum of the number of the test cases in the first test task and the number of the second test tasks which are not merged as the number of the test environments required for executing the test cases to perform resource allocation according to the number of the test environments.
Preferably, the obtaining a first test task corresponding to each test module when depending on each test environment includes:
extracting each test case of the current test module, the test environment on which each test case depends and the time consumption for executing each test case;
adding the test case to be added next time to the current test case set under the condition that the sum of the total time consumption of the current test case in the current test case set and the time consumption of the test case to be added next time to the test case set is less than or equal to the preset time length;
otherwise, stopping adding the test case to be added next time to the current test case set, and creating a new test case set so as to add the test case to be added next time to the test case set until the test case to be added next time does not exist;
and taking each test case set as the first test task corresponding to the current test module when the test module depends on each test environment, and returning to the steps of extracting each test case of the current test module, the test environment on which each test case depends and consuming time for executing each test case.
Preferably, acquiring the test case to be added to the test case set next time includes:
sequencing the test cases to be added according to the test environment on which the test cases depend and the time consumption for executing the test cases;
and taking the test case which takes the longest time one by one as the test case to be added to the test case set next time.
Preferably, the merging the test cases in the first test task that depend on the same test environment to obtain a second test task includes:
obtaining the test cases and the test case switching time in the first test task depending on the same current test environment;
merging the test case to be merged next time into the current second test task under the conditions that the total time consumption of the current test case and the test case to be merged next time is less than or equal to the preset time length and the sum of the switching time of the test cases is less than or equal to the preset time length;
otherwise, stopping merging the test case to be merged next time into the current second test task, and creating a new second test task until the test case to be merged next time does not exist;
and returning to the step of obtaining the test cases and the test case switching time in the first test task depending on the same current test environment.
Preferably, acquiring the test case to be merged next includes:
sequencing the test cases according to the time consumption of the test cases;
and taking the test case with the shortest time consumption as the test case to be merged next time one by one.
Preferably, the time consumed for executing the first test task is less than or equal to the difference between the preset time and the time consumed for preparing the test environment and the time consumed for disassembling the test background in the first test task;
and the time consumed for executing the second test task is less than or equal to the difference between the preset time length and the test environment preparation time, the test background preparation removal time and the test case switching time in the second test task.
Preferably, before the obtaining of the first test task corresponding to each test module when depending on each test environment, the method further includes:
obtaining the test cases with the time consumption larger than the preset time length in each test module;
and removing the test case.
In order to solve the above technical problem, the present application further provides an apparatus for calculating a test resource, including:
the first acquisition module is used for acquiring each test module and the test environment depended by each test case in the test module;
the second acquisition module is used for acquiring a first test task corresponding to each test module when the test module depends on each test environment according to a first preset rule; the first preset rule is that the same first test task shares the same test background, and the execution time of each first test task is less than or equal to a preset time;
the merging module is used for merging the test cases in the first test task depending on the same test environment according to a second preset rule so as to obtain a second test task; the second preset rule is that the execution time of each second test task is less than or equal to the preset time;
a third obtaining module, configured to obtain the number of the test cases in the first test task and the number of the second test tasks that are not merged;
and the module is used for taking the sum of the number of the test cases in the first test task and the number of the second test tasks which are not merged as the number of the test environments required for executing the test cases so as to allocate resources according to the number of the test environments.
In order to solve the above technical problem, the present application further provides an electronic device, including:
a memory for storing a computer program;
a processor for implementing the steps of the method for estimating a test resource when executing the computer program.
In order to solve the above technical problem, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the method for calculating a test resource described above.
The method for calculating the test resources comprises the steps of obtaining a first test task corresponding to each test module when each test module depends on each test environment; merging the test cases in the first test task depending on the same test environment to obtain a second test task; acquiring the number of test cases in the first test task which is not merged and the number of second test tasks; and taking the sum of the number of the test cases in the first test task which are not merged and the number of the second test tasks as the number of the test environments required for executing the test cases so as to allocate the resources according to the number of the test environments. In the method, the execution time consumption of each first test task and the execution time consumption of each second test task are both less than or equal to a preset time length; in addition, the method considers that the test cases share the same test background and the same test environment, and calculates the minimum test environment resource required for completing the test case execution within the preset time length, thereby reducing the waste of the resource and achieving the expected execution efficiency of the user.
In addition, the application also provides a device for calculating the test resource, an electronic device and a computer readable storage medium, which correspond to the above mentioned method for calculating the test resource, and the effects are the same as above.
Drawings
In order to more clearly illustrate the embodiments of the present application, the drawings needed for the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
FIG. 1 is a diagram illustrating a hardware architecture for computing test resources according to the present application;
FIG. 2 is a flowchart of a method for calculating a test resource according to an embodiment of the present disclosure;
FIG. 3 is a flowchart of obtaining a first test task according to an embodiment of the present disclosure;
FIG. 4 is a flowchart of obtaining a second test task according to an embodiment of the present disclosure;
FIG. 5 is a block diagram of an apparatus for calculating a test resource according to an embodiment of the present disclosure;
fig. 6 is a block diagram of an electronic device according to another embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without any creative effort belong to the protection scope of the present application.
The core of the application is to provide a method, a device, electronic equipment and a medium for calculating test resources, which are used for ensuring that the execution of a test case is completed within a specified time as much as possible, maximizing the utilization rate of a test environment and avoiding resource waste.
For ease of understanding, the hardware structure used in the technical solution of the present application is described below. Fig. 1 is a schematic diagram of a hardware architecture for calculating test resources according to the present disclosure. As shown in fig. 1, the monitoring device is connected to a plurality of devices to collect time consumption of test cases executed by each device, time consumption of building a test environment, and the like. Automated test cases convert test cases into code for execution by a computer. In this application, a device is understood to be a test environment for executing automated test cases. Concurrent execution of test cases may be understood as simultaneous execution of automated test cases over multiple sets of test environments.
In order that those skilled in the art will better understand the disclosure, the following detailed description will be given with reference to the accompanying drawings. Fig. 2 is a flowchart of a method for calculating a test resource according to an embodiment of the present disclosure. As shown in fig. 2, the method includes:
s10: and acquiring each test module and the test environment depended by each test case in the test module.
When an automated testing task is executed, a plurality of testing cases may use the same testing environment, and the preparation and the establishment of one testing environment may consume a lot of time, so that the efficiency of executing the testing cases can be improved by reducing the time consumption of preparing and establishing the same testing environment for a plurality of times.
Each test module typically contains one or more test cases, each test case being executed in a corresponding test environment. Therefore, in order to calculate the testing resources required for the execution of the automated testing, the testing modules are obtained first, and the testing environments of the testing cases in the testing modules are obtained. It should be noted that, acquiring each test module may be acquiring all test modules or acquiring only the test modules to be tested, and in implementation, acquiring each test module herein refers to acquiring each test module to be tested in order to reduce the time for calculating the test resources required during the execution of the automated test.
S11: acquiring a first test task corresponding to each test module when each test module depends on each test environment according to a first preset rule; the first preset rule is that the same first test task shares the same test background, and the execution time of each first test task is less than or equal to the preset time.
In order to complete the execution of the test case within the time length specified by the user as much as possible, when the test case is divided into a plurality of test tasks to be executed, it is necessary to ensure that the time taken to execute each test task is less than or equal to the preset time length as much as possible. It should be noted that the preset time duration herein refers to the time duration specified by the user for executing the test case. Preferably, the time taken to perform each test task is equal to the user specified time period, thereby maximizing the utilization of the test environment. The first test task includes one or more test cases, and the number of the first test tasks may be one or more. The number of test cases included in the first test task and the number of first test tasks are both determined by the time taken to execute each test case. And when the time consumed for executing one test case is less than or equal to the time length specified by the user, the test case is taken as a first test task, or when the time consumed for executing one test case plus the time consumed for executing other test cases is less than or equal to the time length specified by the user, the test case and other test cases are taken as the first test task together. In implementation, the first test task corresponding to each test module when depending on each test environment is analyzed.
In addition, in consideration of information correlation among test cases of a test module, such as the same or similar execution steps or shared resources, when the number of automated test cases of a test module reaches the scale of concurrent execution, the test general configuration required by the test cases is extracted in the design of the automated test cases to become the test background. Finally, the information integrity of a test case is composed of the module test background and the inherent information of the test case, so that the structural content of the test case is more compact, redundant steps in a plurality of test cases are eliminated, and the number of steps required to be executed by the automatic test is reduced. Therefore, it is preferred that the same test task shares the same test background. And finally, the same test background is shared by the same first test task, and the execution time consumption of each first test task is less than or equal to the preset time length to serve as a first test rule to obtain the corresponding first test task of each test module when each test module depends on each test environment.
S12: merging the test cases in the first test task depending on the same test environment according to a second preset rule so as to obtain a second test task; and the second preset rule is that the execution time of each second test task is less than or equal to the preset time.
In the steps, the repeated steps among the test cases are reduced by means of testing the background, and the execution efficiency of the test cases is improved. But also introduces new efficiency related problems: under the condition that the preparation and the establishment of a test environment are time-consuming, when the number of test cases in a test task is small, resource waste still occurs, and the preparation cost of the test environment is too high. In practice, the individual test tasks may come from different test modules, with different test contexts, but they may require the same kind of test environment. In order to solve the problem of high environment construction cost when the automated testing is executed in a plurality of environments simultaneously, the influence of the test environment construction on the number of the whole automated testing resources can be effectively reduced by scheduling the test tasks depending on the same type of test environment to one test environment.
Specifically, in the above step, the first test task corresponding to each test module depending on each test environment is obtained according to the first preset rule, so in this step, the first test tasks depending on the same test environment in different test modules may be merged to obtain the second test task. It should be noted that, in order to ensure that the execution of the test case can be completed within the preset time length, that is, the time length for executing each second test task is less than or equal to the preset time length according to the second test rule. Preferably, the time taken to perform the second testing task is equal to the user-specified time period, so that the testing environment can be maximally utilized.
In the process of merging the test cases in the first test task depending on the same test environment, a case that the test cases in the first test task are merged or not merged may occur. When the execution time consumption of one test case in the first test task is less than or equal to the preset time length, if the execution time consumption of the test case and the execution time consumption of another test case exceed the preset time length, the test case is the test case in the first test task which is not merged; if the execution time of the test case plus the execution time of another test case is less than or equal to the preset time length, and if the execution time of one test case plus the execution time of the other test case is greater than the preset time length, the test case and the other test case are merged to obtain a second test task. The completion time of a second test task is equal to the sum of the execution time of each test case, the deployment time of the test background and the clearing time.
S13: the number of test cases in the first test task which are not merged and the number of second test tasks are obtained.
In order to assign a reasonable test environment to the test case specified by the user, the embodiment calculates the test environment required for executing the test case. The first test task is merged through the steps to obtain the test cases and the second test tasks in the first test task which are not merged, and the number of the test cases and the number of the second test tasks in the first test task which are not merged are respectively obtained.
S14: and taking the sum of the number of the test cases in the first test task which are not merged and the number of the second test tasks as the number of the test environments required for executing the test cases so as to allocate the resources according to the number of the test environments.
Finally, the number of test environments required to execute the test cases is equal to the sum of the number of test cases in the first test task that are not merged and the number of second test tasks. The corresponding execution strategy is to respectively allocate independent test environments for the test case in the first test task and the second test task which are not merged, so as to realize the allocation of resources.
It should be noted that, in the above steps, the time consumed by each test case, the time consumed by the test environment preparation, the time consumed by the test background preparation of the test task, and the like can be obtained in a simple manner, and only the acquisition needs to be performed in the automatic test process.
The method for calculating the test resources provided by the embodiment comprises the steps of obtaining a first test task corresponding to each test module when each test module depends on each test environment; merging the test cases in the first test task depending on the same test environment to obtain a second test task; acquiring the number of test cases in the first test task which is not merged and the number of second test tasks; and taking the sum of the number of the test cases in the first test task which are not merged and the number of the second test tasks as the number of the test environments required for executing the test cases so as to allocate the resources according to the number of the test environments. In the method, the execution time consumption of each first test task and the execution time consumption of each second test task are both less than or equal to a preset time length; in addition, the same test background and the same test environment are shared among the test cases, so that the minimum test environment resource required for completing the execution of the test cases within the preset time is calculated, the waste of the resource is reduced, and the expected execution efficiency of the user is achieved.
Because different test modules do not share the test background, even under one test module, different types of test environments are often required, and therefore, test cases of different or the same module cannot be directly combined. Therefore, in order to calculate the test resources more accurately, the test task is firstly split inside the test module. As a preferred embodiment, the obtaining of the first test task corresponding to each test module when depending on each test environment includes:
extracting each test case of the current test module, the test environment depended by each test case and the time consumed for executing each test case;
adding the next test case to be added to the current test case set under the condition that the sum of the total time consumption of the current test case in the current test case set and the time consumption of the next test case to be added to the test case set is less than or equal to the preset time length;
otherwise, stopping adding the test case to be added next time to the current test case set, and creating a new test case set so as to add the test case to be added next time to the test case set until no test case to be added next time exists;
and taking each test case set as a corresponding first test task when the current test module depends on each test environment, and returning to the steps of extracting each test case of the current test module, the test environment on which each test case depends and consuming time for executing each test case.
In this embodiment the test modules are analyzed one by one. And gathering the test cases which depend on the same test environment together to create a test case set, wherein the test case set is the first test task. When the test case set is created, the total time consumed for executing each test case in the test case set is less than or equal to the preset time length. Preferably, the total time taken to execute each test case is equal to the preset time period. It should be noted that, the manner of creating the test case set is not limited. In this embodiment, the test case set is created by adding test cases one by one in the test case set, so that the total time consumption of the test cases in the test case set is within a preset time duration. In the implementation, the test case set may also be created by other methods, such as storing a plurality of test cases in the test case set in advance, and removing the test cases from the test case set when the total time consumption of the test cases is greater than the preset time length, so that the total time consumption of the test cases in the test case set is less than or equal to the preset time length.
And adding the test cases one by one in the test case set, and judging whether the test case to be added next needs to be added in the test case set according to the total time consumption of the test cases in the test case set and the relation between the time consumption of the test case to be added next and the preset environment. When the sum is less than or equal to the preset time length, adding a test case to be added next time to the test case set; and when the sum is longer than the preset time length, stopping adding the test case to be added next time to the test case set. When a test case set is just created, no test case exists in the test case set, at this time, the total time consumption of the test cases in the test case set is 0s, the next test case to be added is the first test case in the test case set, after the first test case is added to the test case set, the total time consumption of the test cases in the test case set is the time consumption of the first test case, the next test case to be added is added to the test case set, and the like, and the next test case to be added is stopped from being added to the test case set until the sum of the total time consumption of the test cases in the test case set and the time consumption of the next test case to be added is greater than the preset time. It should be clear that the test case to be added next is not added to the test case set before the determination is made, but it is determined whether the test case to be added next is to be added to the test case set after the determination is made.
The method provided by the embodiment adds the test cases to the test case set, and takes the test case set as a first test task. Compared with the method that test cases of different or the same test module are directly combined, the method that the test tasks are split inside the test module according to the dependent test environment can calculate the test resources more accurately.
On the basis of the above embodiment, in order to reduce the influence of the convoy effect of the cases and facilitate the creation of the test case set, as a preferred embodiment, acquiring the test case to be added to the test case set next time includes:
sequencing the test cases to be added according to the test environment on which each test case depends and the time consumed for executing each test case;
and taking the test case which consumes the longest time one by one as the test case to be added to the test case set next time.
In implementation, in order to reduce the influence of the case convoy effect and facilitate the creation of the test case set, for each test module, the test cases are sorted in each test environment according to the execution time consumption of the test cases. And each test case in each test module is a test case to be added. The test cases may be arranged in the order of time consumption from long to short or from short to long in the sorting, and is not limited herein. After the test cases to be added of each test module are sorted, the test cases to be added to the test case set are taken one by one from the test case which takes the longest time.
Fig. 3 is a flowchart for acquiring a first test task according to an embodiment of the present disclosure. As shown in fig. 3, the process includes the following steps:
s15: judging whether the time consumed for executing the slowest case is greater than the user requirement; if yes, the process proceeds to step S16, otherwise, the process proceeds to step S17;
s16: ending the test case with the longest time consumption;
s17: acquiring each test module and starting to create a first test task according to each test module;
s18: extracting all test cases of the current module, and sequencing according to the dependent test environment and time consumption;
s19: the following processes are executed for each test environment;
s20: creating a test case set, and adding the test case which consumes the longest time under the test environment;
s21: calculating the total time consumption allowance of the test case set, wherein the total time consumption allowance is equal to the difference between the preset time length and the current time consumption;
s22: starting from the test case with the longest time consumption, judging whether the time consumption of the test case is less than or equal to the allowance; if not, returning to S20, if yes, proceeding to step S23;
s23: adding the test case to a set of test cases;
s24: judging whether a test case still exists; if yes, returning to S21; if not, go to step S25;
s25: judging whether a test module still exists; if yes, return to step S18; if not, the process is ended.
According to the above process, it is assumed that the test module to be executed by the user has a first test module and a second test module, the preset time is 15s, the first test module includes 3 test cases, namely a test case 1, a test case 2 and a test case 3, wherein the test case 1 depends on the test environment 1, and the time for executing the test case 1 is 10 s; the test case 2 depends on the test environment 2, and the time taken to execute the test case 2 is 5s, the test case 3 depends on the test environment 1, and the time taken to execute the test case 3 is 4 s. The second test module includes 2 test cases, which are respectively a test case 4 and a test case 5, wherein the test case 4 depends on the test environment 1, the time consumed for executing the test case 4 is 2s, the test case 5 depends on the test environment 2, and the time consumed for executing the test case 5 is 7 s. And analyzing the first test module and the second test module respectively. In the first test module, according to the test environment and the time-consuming sequence of the test cases, the obtained time-consuming sequence is as follows: test case 1, test case 3, corresponding to 10s, 4s time respectively. Adding a test case 1 which is the test case with the longest time consumption into a test case set, and obtaining the total time consumption allowance of the test case set which is equal to 15s-10 s-5 s according to the difference between the time required by a user and the current time consumption of the test case set; the next test case to be added is test case 3, and the time consumed for test case 3 is 4s less than 5s, so that test case 3 can be added to the test case set. Since only the test case 1 and the test case 3 are the test cases depending on the test environment 1 in the first test module, after the test case 1 and the test case 3 are added to the test case set, no test case exists in the first test module, and thus the test task set of the first test module in the test environment 1 is completed. The set of test tasks is also the first test task. Likewise, a set of test tasks for a first test module in test environment 2, a set of test tasks for a second test module in test environment 1 and test environment 2 may be created. The final created test task set is: in a test environment 1 of a first test module, a test task set comprises a test case 1 and a test case 3; in the test environment 2 of the first test module, the test task set comprises a test case 2; in the test environment 1 of the second test module, the test task set comprises test cases 4; in the test environment 2 of the second test module, the set of test tasks comprises test cases 5. At this point, a test task set, i.e., a first test task, of each test module in each test environment is obtained.
The test cases are sequenced in the test environments according to the execution time consumption of the test cases, and after the sequencing, the test cases with the longest time consumption are used as the test cases to be added to the test case set one by one, so that the influence of the case convoy effect can be reduced, the test case set can be conveniently created, and the first test task can be obtained.
In order to reduce the time consumption of building the test environment, in implementation, as a preferred embodiment, merging the test cases in the first test task that depends on the same test environment so as to obtain the second test task includes:
obtaining test cases in a first test task depending on the same current test environment and test case switching time;
merging the test case to be merged next time into the current second test task under the conditions that the total time consumption of the current test case and the test case to be merged next time is less than or equal to the preset time length and the sum of the test case switching time is less than or equal to the preset time length;
otherwise, stopping merging the test case to be merged next time into the current second test task, and creating a new second test task until no test case to be merged next time exists;
and returning to the step of acquiring the test cases in the first test task depending on the same current test environment and the test case switching time.
In the embodiment, the test cases in the first test task which depend on the same test environment are merged to obtain the second test task. The consumed time of the second test task is less than or equal to the preset time length, and preferably, the consumed time of the second test task is equal to the preset time length. The manner of obtaining the second test task is not limited. In this embodiment, the manner of obtaining the second test tasks is to determine whether the test cases are merged in the second test tasks one by one, and the merging here may also be understood as adding. In the implementation, the second test task may also be obtained in other manners, for example, a plurality of test cases are stored in the second test task in advance, and when the total time consumption of the test cases is greater than the preset time length, the test cases are removed from the second test task, so that the time consumption of the second test task is less than or equal to the preset time length.
And merging the test cases in the first test task depending on the same test environment to obtain a second test task. Compared with the method for acquiring the first test task, the method for acquiring the second test task has the switching time of the test cases. And judging whether the test case to be merged next time is merged in the current second test task or not according to the total time consumption of the current test case and the test case to be merged next time and the relation between the sum of the test case switching time and the preset time length. When the sum is less than or equal to the preset time length, merging the test case to be merged next time into the current second test task; and when the sum is larger than the preset duration, stopping merging the test case to be merged next time into the current second test task. When the second test task is just started to be acquired, no test case exists in the second test task. At this time, the time consumed by the current test case is 0s, and the switching time of the test case is 0 s. Judging the relation between the consumed time of the next test case to be merged and the preset time length, merging the test case to be merged into the current second test task when the consumed time of the next test case to be merged is less than or equal to the preset time length, and returning again to judge whether to merge the next test case to be merged into the current second test task according to the total consumed time of the current test case and the next test case to be merged and the relation between the switching time of the test cases and the preset time length. It should be clear that the test case to be merged next is not merged in the second test task before merging, but after the determination, it is determined whether the test case to be merged next is to be merged in the second test task. The switching time for a test case is typically determined based on a priori knowledge.
According to the embodiment, the test cases in the first test task depending on the same test environment are classified to obtain the second test task, so that time consumption in preparation and building of the test environment can be reduced, and the efficiency of automatic testing is improved.
In the implementation, if merging is performed from the test task which consumes the longest time, the short time-consuming task and the long time-consuming task are easily merged in the same second test task, so that a phenomenon that more short time-consuming tasks are concentrated to wait for the completion of the long time-consuming task, namely a case convoy phenomenon, occurs. As a preferred embodiment, acquiring the next test case to be merged includes:
sequencing the test cases according to the time consumption of the test cases;
and taking the test case with the shortest time consumption as the test case to be merged next time one by one.
In order to reduce the influence of the case convoying effect and facilitate the acquisition of the second test task, the test cases are sorted according to the time consumption of the test cases. The test cases may be arranged in time-consuming order from long to short or from short to long, and are not limited herein. Starting from the test case with the shortest time consumption, the test cases are used as the test cases to be merged next time one by one.
Fig. 4 is a flowchart of acquiring a second test task according to an embodiment of the present disclosure. As shown in fig. 4, the process includes the following steps:
s26: classifying all test tasks according to the types of the dependent test environments;
s27: sequencing the first test tasks according to the time consumption of the test cases under each test environment category;
s28: acquiring the test cases with the shortest time consumption one by one;
s29: judging whether the sum of the total time consumption of the current test case and the next test case to be merged and the switching time of the test cases is less than or equal to a preset time length or not; if yes, returning to the step S28, otherwise, entering the step S30;
s30: completing the generation of a second test task under the test environment;
s31: judging whether other types of test environments need to be processed or not; if so, the process returns to step S27, and if not, the process ends.
According to the above flow, on the basis of the examples listed in the above embodiments, it is assumed that the switching time of one test case is 2 s. The test case in the first test task in the test environment 1 includes case 1, which takes 10 s; case 3, time taken 4 s; case 4, take 2 s. Firstly, adding the test case 4 which is the shortest time-consuming test case into the second test task, wherein the time-consuming test case is 0s since the second test task just starts and the test case is not included, the time-consuming test case 4 is the next time-consuming test case to be merged, the time-consuming test case is 2s, and the switching time of the test cases is 0 s. Therefore, the sum of the total time consumption of the current test case and the next test case to be merged and the switching time of the test cases is 2s, and the preset time length is 15s, so that the next test case to be merged can be judged again. At this time, the time consumed by the current test case is 2s, the time consumed by the next test case to be merged is 3, the time consumed by the test case is 4s, the switching time of the test case for one time is 2s, the sum of the total time consumed by the current test case and the next test case to be merged and the switching time of the test cases can be calculated according to each time length and is 8s, and the sum is still less than the preset time length, so that the next test case to be merged can be judged again. At this time, the total time consumption of the current test case is 6s, the time consumption of the next test case to be merged is the test case 1, the time consumption is 10s, the switching time of the two test cases is 4s, the sum of the total time consumption of the current test case and the next test case to be merged and the switching time of the test cases is calculated according to each time length and is 20s, and the sum is greater than the preset time length, so that the test case 1 cannot be merged in the second test task. By analogy, a merging result of the test cases in the first test task in the test environment 2 is obtained. The second testing task obtained after the merging is as follows: test cases 3, 4 are a second test task, and test cases 2, 5 are a second test task. Test case 1 is a test case in the first test task that is not merged. The number of finally obtained test cases in the first test task which is not merged is 1, namely the test case 1, and the number of obtained second test tasks is 2. The number of allocated test environments is equal to the number of test cases in the first test task and the number of second test tasks that are not merged, i.e. 3 separate test environments need to be allocated. If the conventional method is adopted, one test environment may be allocated to each test case, and finally 5 test environments may be required, whereas by adopting the method of the embodiment of the present application, the execution of the test case can be completed only by 3 test environments. Therefore, the method provided by the embodiment calculates the minimum testing environment resources required for completing the execution of the testing case within the preset time length, reduces the waste of the resources, and achieves the execution efficiency expected by the user.
The merging is started from the test task with the shortest time consumption, and the phenomenon of case convoy can be avoided as much as possible, so that the efficiency of automatic testing is improved.
In order to accurately determine the time consumed for executing the first test task and the second test task, the time consumed for building the test environment, preparing the test background to be removed, and the like need to be taken into consideration. In the implementation, as a preferred implementation manner, the time taken for executing the first test task is less than or equal to the difference between the preset time length and the time taken for preparing the test environment and the time taken for removing the test background in the first test task;
the time consumed for executing the second test task is less than or equal to the difference between the preset time length and the test environment preparation time, the test background preparation removal time and the test case switching time in the second test task.
The test case switching time needs to be taken into account when the second test task is acquired, compared to the time taken to acquire the first test task.
Compared with the method for calculating the execution time consumption of the first test task and the second test task, which is provided by the embodiment of the invention, the method for calculating the execution time consumption of the first test task and the second test task can more accurately estimate the execution time consumption of the first test task and the second test task compared with the method for directly making the execution time consumption of the first test task and the execution time consumption of the second test task smaller than the preset time length, so that the automatic test case can be completed within the time length specified by a user.
In order to improve the efficiency of the automated testing, in a preferred embodiment, before acquiring the first test task corresponding to each test module when relying on each test environment, the method further includes:
obtaining a test case with the time consumption larger than a preset time length in each test module;
and removing the test cases.
The automatic test cases are completed within a preset time length, so that the time consumption of each test case does not exceed the preset time length, and the test cases with the time consumption larger than the preset time length need to be processed; secondly, when the first test task is obtained, whether a next test case to be added needs to be added in the test case set is judged according to the total time consumption of the test cases and the relation between the time consumption sum of the next test case to be added and a preset environment, if the time consumption of the current test case exceeds the preset time length, when the time consumption sum of the next test case to be added exceeds the preset time length, the total time consumption is inevitably larger than the preset time length, and therefore, in order to simplify the calculated test cases, the test cases with the time consumption exceeding the preset time length can be directly removed.
The method for eliminating the test cases with the time consumption exceeding the preset time before the first test task is obtained according to the embodiment can ensure that each test task is completed within the preset time as much as possible.
In the above embodiments, the method for estimating the test resource is described in detail, and the present application also provides embodiments corresponding to the apparatus for estimating the test resource and the electronic device. It should be noted that the present application describes the embodiments of the apparatus portion from two perspectives, one from the perspective of the function module and the other from the perspective of the hardware.
Fig. 5 is a block diagram of an apparatus for estimating a test resource according to an embodiment of the present disclosure. The present embodiment is based on the angle of the function module, and includes:
the first obtaining module 10 is configured to obtain each test module and a test environment that each test case in the test module depends on;
the second obtaining module 11 is configured to obtain, according to a first preset rule, a first test task corresponding to each test module when the test module depends on each test environment; the first preset rule is that the same first test task shares the same test background, and the execution time of each first test task is less than or equal to the preset time;
the merging module 12 is configured to merge the test cases in the first test task that depend on the same test environment according to a second preset rule so as to obtain a second test task; the second preset rule is that the execution time of each second test task is less than or equal to the preset time;
a third obtaining module 13, configured to obtain the number of test cases in the first test task and the number of second test tasks that are not merged;
as a module 14, the sum of the number of test cases in the first test task and the number of second test tasks that are not merged is used as the number of test environments required for executing the test cases to perform resource allocation according to the number of test environments.
Since the embodiments of the apparatus portion and the method portion correspond to each other, please refer to the description of the embodiments of the method portion for the embodiments of the apparatus portion, which is not repeated here.
The device for reckoning test resources provided by this embodiment implements calculation of the number of test environments required for executing a test case by using the first obtaining module, the second obtaining module, the merging module, and the third obtaining module as modules. In the device, the execution time consumption of each first test task and the execution time consumption of each second test task are both less than or equal to a preset time length; in addition, the method considers that the test cases share the same test background and the same test environment, and calculates the minimum test environment resource required for completing the test case execution within the preset time length, thereby reducing the waste of the resource and achieving the expected execution efficiency of the user.
Fig. 6 is a block diagram of an electronic device according to another embodiment of the present application. This embodiment is based on a hardware perspective, and as shown in fig. 6, the electronic device includes:
a memory 20 for storing a computer program;
a processor 21 for implementing the steps of the method for estimating a test resource as mentioned in the above embodiments when executing the computer program.
The electronic device provided by the embodiment may include, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, or the like.
The processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The Processor 21 may be implemented in hardware using at least one of a Digital Signal Processor (DSP), a Field-Programmable Gate Array (FPGA), and a Programmable Logic Array (PLA). The processor 21 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a Graphics Processing Unit (GPU) which is responsible for rendering and drawing the content required to be displayed by the display screen. In some embodiments, the processor 21 may further include an Artificial Intelligence (AI) processor for processing computational operations related to machine learning.
The memory 20 may include one or more computer-readable storage media, which may be non-transitory. Memory 20 may also include high speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used for storing a computer program 201, wherein after being loaded and executed by the processor 21, the computer program can implement the relevant steps of the method for estimating a test resource disclosed in any one of the foregoing embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202, data 203, and the like, and the storage manner may be a transient storage manner or a permanent storage manner. Operating system 202 may include, among others, Windows, Unix, Linux, and the like. Data 203 may include, but is not limited to, data related to the above-mentioned methods of dead reckoning test resources, and the like.
In some embodiments, the electronic device may further include a display 22, an input/output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.
Those skilled in the art will appreciate that the configuration shown in fig. 6 does not constitute a limitation of the electronic device and may include more or fewer components than those shown.
The electronic device provided by the embodiment of the application comprises a memory and a processor, and when the processor executes a program stored in the memory, the following method can be realized: the effect of the method for calculating the testing resources is the same as that of the method.
Finally, the application also provides a corresponding embodiment of the computer readable storage medium. The computer-readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps as set forth in the above-mentioned method embodiments.
It is to be understood that if the method in the above embodiments is implemented in the form of software functional units and sold or used as a stand-alone product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium and executes all or part of the steps of the methods described in the embodiments of the present application, or all or part of the technical solutions. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The computer-readable storage medium provided by the application comprises the above-mentioned method for calculating the test resource, and the effects are the same as above.
The method, the apparatus, the electronic device, and the medium for calculating the test resource provided by the present application are described in detail above. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A method for computing a test resource, comprising:
obtaining each test module and a test environment which each test case in the test module depends on;
acquiring a first test task corresponding to each test module when the test module depends on each test environment according to a first preset rule; the first preset rule is that the same first test task shares the same test background, and the execution time of each first test task is less than or equal to a preset time length;
merging the test cases in the first test task depending on the same test environment according to a second preset rule so as to obtain a second test task; the second preset rule is that the execution time of each second test task is less than or equal to the preset time;
acquiring the number of the test cases in the first test task which are not merged and the number of the second test tasks;
and taking the sum of the number of the test cases in the first test task and the number of the second test tasks which are not merged as the number of the test environments required for executing the test cases to perform resource allocation according to the number of the test environments.
2. The method for calculating test resources according to claim 1, wherein the obtaining of the first test task corresponding to each test module when depending on each test environment comprises:
extracting each test case of the current test module, the test environment on which each test case depends and the time consumption for executing each test case;
adding the test case to be added next time to the current test case set under the condition that the sum of the total time consumption of the current test case in the current test case set and the time consumption of the test case to be added next time to the test case set is less than or equal to the preset time length;
otherwise, stopping adding the test case to be added next time to the current test case set, and creating a new test case set so as to add the test case to be added next time to the test case set until the test case to be added next time does not exist;
and taking each test case set as the first test task corresponding to the current test module when the test module depends on each test environment, and returning to the steps of extracting each test case of the current test module, the test environment on which each test case depends and consuming time for executing each test case.
3. The method for calculating test resources according to claim 2, wherein obtaining the test case to be added to the test case set next comprises:
sequencing the test cases to be added according to the test environment on which the test cases depend and the time consumption for executing the test cases;
and taking the test case which takes the longest time one by one as the test case to be added to the test case set next time.
4. The method for calculating test resources according to any one of claims 1 to 3, wherein the merging the test cases in the first test task depending on the same test environment to obtain a second test task comprises:
obtaining the test cases and the test case switching time in the first test task depending on the same current test environment;
merging the test case to be merged next time into the current second test task under the conditions that the total time consumption of the current test case and the test case to be merged next time is less than or equal to the preset time length and the sum of the test case switching time is less than or equal to the preset time length;
otherwise, stopping merging the test case to be merged next time into the current second test task, and creating a new second test task until the test case to be merged next time does not exist;
and returning to the step of obtaining the test cases and the test case switching time in the first test task depending on the same current test environment.
5. The method for calculating test resources according to claim 4, wherein obtaining the test case to be merged next comprises:
sequencing the test cases according to the time consumption of the test cases;
and taking the test case with the shortest time consumption as the test case to be merged next time one by one.
6. The method for calculating the test resource according to claim 5, wherein the time taken for executing the first test task is less than or equal to the difference between the preset time length and the time taken for preparing the test environment and the time taken for removing the test background in the first test task;
and the time consumed for executing the second test task is less than or equal to the difference between the preset time length and the test environment preparation time, the test background preparation removal time and the test case switching time in the second test task.
7. The method for calculating test resources according to claim 1, further comprising, before the obtaining a first test task corresponding to each test module when depending on each test environment:
obtaining the test cases with the time consumption larger than the preset time length in each test module;
and removing the test case.
8. An apparatus for computing a test resource, comprising:
the first acquisition module is used for acquiring each test module and the test environment depended by each test case in the test module;
the second obtaining module is used for obtaining a first test task corresponding to each test module when the test module depends on each test environment according to a first preset rule; the first preset rule is that the same first test task shares the same test background, and the execution time of each first test task is less than or equal to a preset time length;
the merging module is used for merging the test cases in the first test task depending on the same test environment according to a second preset rule so as to obtain a second test task; the second preset rule is that the execution time of each second test task is less than or equal to the preset time;
a third obtaining module, configured to obtain the number of the test cases in the first test task and the number of the second test tasks that are not merged;
and the module is used for taking the sum of the number of the test cases in the first test task and the number of the second test tasks which are not merged as the number of the test environments required for executing the test cases so as to allocate resources according to the number of the test environments.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the method of estimating a test resource according to any one of claims 1 to 7 when executing said computer program.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the method of reckoning a test resource according to any one of claims 1 to 7.
CN202210681484.5A 2022-06-16 2022-06-16 Method, device, electronic equipment and medium for calculating test resources Pending CN114911714A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210681484.5A CN114911714A (en) 2022-06-16 2022-06-16 Method, device, electronic equipment and medium for calculating test resources

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210681484.5A CN114911714A (en) 2022-06-16 2022-06-16 Method, device, electronic equipment and medium for calculating test resources

Publications (1)

Publication Number Publication Date
CN114911714A true CN114911714A (en) 2022-08-16

Family

ID=82770621

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210681484.5A Pending CN114911714A (en) 2022-06-16 2022-06-16 Method, device, electronic equipment and medium for calculating test resources

Country Status (1)

Country Link
CN (1) CN114911714A (en)

Similar Documents

Publication Publication Date Title
CN110704173A (en) Task scheduling method, scheduling system, electronic device and computer storage medium
CN111143039A (en) Virtual machine scheduling method and device and computer storage medium
CN111176790A (en) Active maintenance method and device of cloud platform physical host and readable storage medium
CN110569154B (en) Chip interface function testing method, system, terminal and storage medium
CN110489242A (en) Distributed data calculation method, device, terminal device and storage medium
CN110750359A (en) Hardware resource configuration method and device, cloud side equipment and storage medium
CN114911714A (en) Method, device, electronic equipment and medium for calculating test resources
CN109460234B (en) Application slimming method and device, terminal and storage medium
CN109800166B (en) Debugging method and device for embedded real-time operating system
CN116126719A (en) Interface testing method and device, electronic equipment and storage medium
CN114153601A (en) Resource scheduling method, device and medium under multi-cloud model
CN115756615A (en) Quick starting method, device, equipment and storage medium
CN115630011A (en) Method and device for realizing I2C bus communication of master and slave equipment by using CPLD
CN115016735A (en) Control method, device and medium for distributed cache system
CN114721876A (en) Data backup method, device and medium
CN114862223A (en) Robot scheduling method, device, equipment and storage medium
CN113886376A (en) Data cleaning method and device, electronic equipment and medium
CN109947559B (en) Method, device, equipment and computer storage medium for optimizing MapReduce calculation
CN112395081A (en) Resource online automatic recovery method, system, server and storage medium
CN110990209A (en) Storage stability test method, test device, test equipment and storage medium
CN106528577B (en) Method and device for setting file to be cleaned
CN106775917B (en) Method and system for starting virtual machine
CN114995981A (en) Parallel task scheduling method, system, storage medium and terminal
CN114968208A (en) Object recovery method, device and medium
CN115576835A (en) Automatic testing method, system, terminal and storage medium of embedded RTOS

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination