Test method and device
By automatically obtaining compilation tools and generating test scripts, the accuracy problems caused by manual testing are solved and efficient software testing results are achieved.
Patent Information
- Application Number
- CN202311659035.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-04
- Publication Date
- 2025-07-22
AI Technical Summary
Existing software testing methods rely on manual operations, resulting in low accuracy of test results and are susceptible to operator technical level and errors.
By obtaining test requirements, using control scripts to automatically obtain compilation tools, generate test scripts containing test cases, and automatically perform test operations to achieve automated testing.
It improves the accuracy of the test process, avoids errors caused by manual operations and low-level test results, and realizes automated testing based on user needs.
Smart Images

Figure CN120353689A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software technology, and in particular, to a testing method and apparatus. Background Art
[0002] With the development of technology, software technology has also advanced. In the process of software development, software testing is an important part of it, which is a process of running or testing a software system by manual or automatic means. Software testing can ensure the correctness of the software process and determine whether there is a correct application logic relationship. Its purpose is to check whether the test results meet the specified requirements or find the difference between the actual results and the expected results.
[0003] Currently, in the existing testing process, generally, it is necessary for a person to test a certain function of the software manually. However, in actual applications, testing in a manual way often requires the operator to have a certain testing foundation. Once the technical ability of the operator is poor or there are manual operation errors, the accuracy of the existing test results will be affected, which makes the existing testing method have the problem of low accuracy of test results. Summary of the Invention
[0004] Embodiments of this application provide a testing method and apparatus, and the main purpose is to implement a testing method to solve the problem of low accuracy of test results obtained in the existing testing process.
[0005] To solve the above technical problems, the embodiments of this application provide the following technical solutions:
[0006] In a first aspect, this application provides a testing method, and the method includes:
[0007] Obtain a test requirement, and determine a function to be tested based on the test requirement;
[0008] Based on the function to be tested, obtain a compilation tool for the function to be tested through a control script;
[0009] Generate a test script for the function to be tested through the compilation tool, where the test script includes at least one test case corresponding to the function to be tested;
[0010] Execute a test operation on the function to be tested through the test script.
[0011] Optionally, before obtaining the compilation tool for the function to be tested through the control script based on the function to be tested, the method further includes:
[0012] Respectively determine the compilation tool corresponding to each function to be tested, and set path information for each compilation tool;
[0013] Based on the function to be tested, the compilation tool for obtaining the function to be tested through the control script includes:
[0014] Based on the control script, determine the target compilation tool corresponding to the function to be tested, and obtain the target compilation tool based on the path information of the target compilation tool.
[0015] Optionally, the test script for generating the function to be tested through the compilation tool includes:
[0016] Based on the compilation tool, determine the compilation parameters and function categories corresponding to the function to be tested, and perform a compilation operation based on the compilation parameters according to the function categories to obtain at least one test case corresponding to the function to be tested;
[0017] Generate the test script based on at least one test case, wherein the execution order of each test case during testing is set in the test script.
[0018] Optionally, the test script for generating the function to be tested through the compilation tool includes:
[0019] When it is determined that there are compiled test cases, obtain the compiled test cases based on the preset test case path;
[0020] Judge the compatibility between the compiled test cases and the function to be tested;
[0021] When it is determined that the compiled test cases are compatible with the function to be tested and there are multiple compiled test cases, generate the test script by the compilation tool according to the logical relationship, where the logical relationship is used to represent the logical order during the execution of multiple compiled test cases when implementing the function to be tested.
[0022] Optionally, the test script for generating the function to be tested through the compilation tool includes:
[0023] When it is determined that the function to be tested corresponds to multiple test dimensions, generate corresponding test cases respectively by the compilation tool for each test dimension;
[0024] The test operation for the function to be tested through the test script includes:
[0025] Perform test operations respectively based on the test scripts corresponding to each test dimension, and use the control script to summarize the test results obtained based on each test script to obtain the total test result.
[0026] Optionally, perform test operations based on the test scripts corresponding to each test dimension respectively, and use the control script to summarize the test results obtained based on each test script to obtain the total test result, including:
[0027] Obtain the general test parameters and target test parameters of each test script, where the target test parameters are used to characterize the specific test parameters for the current test dimension;
[0028] Based on the test script, input the general test parameters and the target test parameters respectively, and obtain the first test result corresponding to the general test parameters and the second test result corresponding to the target test parameters respectively;
[0029] Based on the control script, obtain the first test result and the second test result obtained by each test script respectively, and determine the total test result based on the first test result and the second test result.
[0030] Optionally, determining the total test result based on the first test result and the second test result includes:
[0031] When it is determined that the deviation value between the first test result and the second test result exceeds a preset threshold, use the second test result as the total test result;
[0032] Or,
[0033] When it is determined that the deviation value between the first test result and the second test result exceeds a preset threshold, generate a third test result, and determine the third test result as the total test result, where the third test result is used to characterize that there is an abnormality in the function to be tested.
[0034] In a second aspect, the present application also provides a test device, and the device includes:
[0035] A first determination unit, configured to obtain a test requirement and determine a function to be tested based on the test requirement;
[0036] An acquisition unit, configured to obtain a compilation tool for the function to be tested through a control script based on the function to be tested;
[0037] A generation unit, configured to generate a test script for the function to be tested through the compilation tool, where the test script includes at least one test case corresponding to the function to be tested;
[0038] An execution unit, configured to perform a test operation on the function to be tested through the test script.
[0039] Optionally, the device further includes:
[0040] A second determination unit, configured to respectively determine a compilation tool corresponding to each of the functions to be tested, and set path information for each of the compilation tools;
[0041] The obtaining unit is further configured to determine a target compilation tool corresponding to the function to be tested based on the control script, and obtain the target compilation tool based on the path information of the target compilation tool.
[0042] Optionally, the generating unit is further configured to determine compilation parameters and function categories corresponding to the function to be tested based on the compilation tool, and perform a compilation operation based on the compilation parameters according to the function categories to obtain at least one of the test cases corresponding to the function to be tested; and generate the test script based on at least one of the test cases, wherein an execution order of each of the test cases during testing is set in the test script.
[0043] Optionally, the generating unit is further configured to, when it is determined that there are compiled test cases, obtain the compiled test cases based on a preset test case path; and determine the compatibility between the compiled test cases and the function to be tested; and when it is determined that the compiled test cases are compatible with the function to be tested and there are multiple compiled test cases, generate the test script by the compilation tool according to a logical relationship between the compiled test cases, where the logical relationship is used to represent an execution logical order of multiple compiled test cases when implementing the function to be tested.
[0044] Optionally, the generating unit is further configured to, when it is determined that the function to be tested corresponds to multiple test dimensions, respectively generate corresponding test cases for each of the test dimensions by using the compilation tool;
[0045] The execution unit is further specifically configured to perform test operations respectively based on the test scripts corresponding to each test dimension, and aggregate the test results obtained based on each of the test scripts by using the control script to obtain a total test result.
[0046] Optionally, the execution unit is further configured to obtain the general test parameters and the target test parameters of each of the test scripts, where the target test parameters are used to characterize specific test parameters for the current test dimension; and, based on the test scripts, input the general test parameters and the target test parameters respectively, and obtain a first test result corresponding to the general test parameters and a second test result corresponding to the target test parameters respectively; and, based on the control script, obtain the first test result and the second test result obtained by each of the test scripts respectively, and determine the total test result based on the first test result and the second test result.
[0047] Optionally, the execution unit is further configured to, when determining that the deviation value between the first test result and the second test result exceeds a preset threshold, use the second test result as the total test result;
[0048] The execution unit is further configured to, when determining that the deviation value between the first test result and the second test result exceeds a preset threshold, generate a third test result and determine the third test result as the total test result, where the third test result is used to characterize that there is an abnormality in the function to be tested.
[0049] In a third aspect, the present application further provides a storage medium, where the storage medium includes a stored program, and when the program runs, it controls the device where the storage medium is located to execute the test method described in the first aspect.
[0050] In a fourth aspect, the present application further provides a test device, where the device includes a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions run, they execute the test method described in any one of the first aspect.
[0051] By means of the above technical solutions, the technical solutions provided by the present application have at least the following advantages:
[0052] The present application provides a test method and apparatus. The present application can first obtain test requirements and determine the function to be tested based on the test requirements; then, based on the function to be tested, obtain the compilation tool for the function to be tested through a control script; after that, generate a test script for the function to be tested through the compilation tool, where the test script includes at least one test case corresponding to the function to be tested; finally, perform a test operation on the function to be tested through the test script, thereby realizing the test function. Compared with the prior art, in the present application, a corresponding test script can be directly generated based on the test requirements during testing, and the test script is used for testing, so that a function of automatically testing based on the user's test requirements is realized, which is different from the process of manual testing in the prior art. The present application can directly and automatically determine the function to be tested after obtaining the user's test requirements, so the process of the operator independently determining the required test function is omitted, and the possibility of problems in the determination result of the function to be tested caused by the low test level or operation error of the operator is avoided. At the same time, after obtaining the compilation tool through the control script based on the function to be tested, a test script corresponding to the test function can be automatically generated based on the compilation tool, which realizes the effect of automatically compiling the test script by the compilation tool itself, thereby omitting the compilation threshold required for the operator to manually compile the test script, and further avoiding the problem of low accuracy of the test result caused by problems in the test script compiled manually, and then improving the accuracy of the test process.
[0053] The above description is only an overview of the technical solution of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present application more obvious and understandable, the following specifically describes the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] By referring to the drawings and reading the following detailed description, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0055] Figure 1 Shows a flowchart of a test method provided by an embodiment of the present application;
[0056] Figure 2 Shows a block diagram of the composition of a test apparatus provided by an embodiment of the present application;
[0057] Figure 3 Shows a block diagram of the composition of another test apparatus provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0058] Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present application can be more thoroughly understood and the scope of the present application can be fully conveyed to those skilled in the art.
[0059] It should be noted that unless otherwise specified, the technical terms or scientific terms used in the present application should have the ordinary meaning understood by those skilled in the art to which the present application belongs.
[0060] An embodiment of the present application provides a flowchart of a test method, as Figure 1 shown, the method includes:
[0061] 101. Obtain test requirements and determine the function to be tested based on the test requirements.
[0062] In this embodiment, the test requirements can be understood as what items the user needs to test. The test requirements can be input by the user based on a preset interaction interface. Of course, the specific acquisition methods of the test requirements include but are not limited to the following methods: For example, the user can input which functions or services need to be specified for testing currently, or the user can input the name of a certain software or program. It can also be a function chart in a certain software displayed on the preset interaction interface, and the user clicks an instruction to obtain the test requirements. Here, the acquisition method of the test requirements can be carried out according to any of the above, and no limitation is made here.
[0063] After obtaining the test requirements, the specific function that the actual user wants to test can be parsed from the test requirements, that is, the function to be tested. Since in the implementation process of the test method described in this embodiment, the main focus is on the testing of software or programs, in this embodiment, the content that the user needs to test is distinguished by the various functions actually included in the software or program. Here, the function to be tested can be any one or several functions of the software or program. Of course, since the specific form of the function can be a service or a component, etc., in this embodiment, the function to be tested is actually just a way of expressing these services or components, and specifically, it should be subject to the content that the actual user needs to test.
[0064] 102. Based on the function to be tested, obtain the compilation tool of the function to be tested through a control script.
[0065] In this embodiment, the control script can be understood as a preset script dedicated to obtaining a compilation tool. That is to say, during the execution of the test method described in this embodiment, it is not necessary to directly obtain the compilation tool, but the existing control script can be directly used for obtaining. This ensures that during the process of obtaining the compilation script based on the function to be tested, the code corresponding to the compilation and acquisition function is omitted, and the control script can be directly called. In addition, in this embodiment, the general compilation tool can specifically be the toolchain compilation tool, also known as a cross-compiler, which is a cross-compiler for debugging software or programs on a development board built based on the Linux system. This general compilation tool can mainly be used to compile dedicated test programs or scripts according to preset instructions and user requirements. In this step, the compilation tool can specifically be a compilation tool that is specifically adjusted based on different functions. That is to say, for different functions, since there are some differences in their test processes, such as the setting of environment variables or different test dimensions, the function of compiling their test scripts also has targeted optimizations. Therefore, it is equivalent to optimizing different specific compilation tools based on the general compilation tool. Based on this, in this step, after determining the function to be tested, the compilation tool corresponding to this function that needs to be tested currently can be found and obtained based on the control script.
[0066] 103. Generate a test script for the function to be tested through the compilation tool.
[0067] Among them, the test script includes at least one test case corresponding to the function to be tested.
[0068] In this embodiment, the test script can be understood as a script capable of performing automated testing formed based on test cases. That is to say, the test script contains at least one test case, and the test script is pre-configured with configuration information that can be used to complete the test function.
[0069] Based on the test method described in this embodiment, it is a method that can automatically test corresponding functions based on the user's test requirements. Therefore, in the case where the compilation tool corresponding to the function to be tested has been obtained in the previous step, the corresponding test script can be generated through this compilation tool. That is to say, an automated script including test cases and covering the parameters and relevant configuration information required during testing is generated.
[0070] 104. Execute a test operation on the function to be tested through the test script.
[0071] After the test script is generated, the test script can be used for test operations. Based on the description of the foregoing steps, the test script is a script program that can automatically execute tests on test cases. Therefore, by starting the test script, the automatic execution effect of the test operations on the function to be tested can be achieved.
[0072] Based on this, this embodiment provides a test method. Compared with the prior art, in the embodiment of the present application, during testing, a corresponding test script can be directly generated based on the test requirements, and the test script is used for testing. In this way, a function of automatically testing based on the user's test requirements is realized. Different from the prior art that requires manual testing, the method of the embodiment of the present application can directly determine the function to be tested automatically by obtaining the user's test requirements. Therefore, the process of the operator determining the required test function by himself is omitted, and the possibility that the determination result of the function to be tested is problematic due to the low test level or operation error of the operator is avoided. At the same time, after obtaining the compilation tool based on the function to be tested through the control script, a test script corresponding to the test function can be automatically generated based on the compilation tool. This realizes the effect of automatically compiling the test script by the compilation tool itself, thus eliminating the compilation threshold required for the operator to manually compile the test script. Further, the problem that the accuracy of the test result is relatively low due to problems in the test script compiled manually can be avoided, and then the accuracy of the test process can be improved.
[0073] In some embodiments, before step 102 of obtaining the compilation tool for the function to be tested through the control script based on the function to be tested, the method further includes:
[0074] Determine the compilation tool corresponding to each function to be tested respectively, and set path information for each compilation tool;
[0075] Based on this, step 102 of obtaining the compilation tool for the function to be tested through the control script based on the function to be tested includes:
[0076] Based on the control script, determine the target compilation tool corresponding to the function to be tested, and obtain the target compilation tool based on the path information of the target compilation tool.
[0077] In some cases, different functions need to be compiled using different compilation tools to achieve better test results. Based on this, to ensure a closer fit with the function to be tested during subsequent testing, in this embodiment, before obtaining the compilation tool, it is necessary to pre-set the compilation tool matching each function to be tested in the manner of this embodiment, and then set a dedicated path for each compilation tool. Then, when step 102 is executed, it is possible to directly query, based on the control script, which compilation tool corresponds to the currently tested function, that is, the target compilation function, and then directly obtain the target compilation tool through the pre-set path information. This achieves the effect of determining the adapted tool based on the function to be tested and setting a path for it, thus ensuring that the control script can accurately obtain the tool adapted to the function to be tested in accordance with the path during the process of obtaining the compilation tool, laying a foundation for more accurate subsequent testing.
[0078] In some embodiments, generating the test script for the function to be tested through the compilation tool in the aforementioned step 103 includes:
[0079] Determine the compilation parameters and function categories corresponding to the function to be tested based on the compilation tool, and perform a compilation operation based on the compilation parameters according to the function categories to obtain at least one test case corresponding to the function to be tested;
[0080] Generate the test script based on at least one test case, where the execution order of each test case during testing is set in the test script.
[0081] In this embodiment, the test script can be understood as a functional instruction capable of performing automated testing based on test cases. The test cases are the same as regular test cases, which are test programs formed by combining functions based on certain parameters according to the functional characteristics of each function in advance. Therefore, when generating the test script for the function to be tested based on the compilation tool, it is possible to first perform compilation based on the compilation parameters and function categories to generate the corresponding test cases. The function types can be understood as corresponding to the types of functions to be tested. That is to say, if the function to be tested is a query function, then the function type should also be the type of function corresponding to the query function. The compilation parameters can be understood as some important variables that need to be pre-set when the functions for constructing the test cases are running. Therefore, based on the function categories and compilation parameters, the generation function of test cases can be achieved. Of course, the specific generation process is the same as the existing process of constructing test cases based on functions and compilation parameters, and will not be limited here.
[0082] After the test cases are determined, since a test case itself is a program that can test a certain function, but when executing the test operation, it is necessary to determine what the input is, what the output is, and whether the output is consistent with the expected output. In this case, it is necessary to rely on a test script. That is to say, the test script can automatically add inputs to the test case, collect the output of the test case, and compare it with the expected output to obtain the result. Therefore, after generating the test cases for the function to be tested, it is necessary to set instructions for automatically adding inputs, obtaining the output of the test case, and setting instructions for judging whether the output matches the expected output based on the test cases to obtain the test script. Of course, in actual applications, the process of setting the test script based on the test cases includes but is not limited to the above process. In the specific usage process, the user can also add other additional function instructions based on their own needs during the process of generating the test script so that the test script can achieve the corresponding effects during subsequent testing.
[0083] In some embodiments, the generation of the test script for the function to be tested by the compilation tool in the foregoing step 103 includes:
[0084] When it is determined that there are compiled test cases, obtain the compiled test cases based on a preset test case path;
[0085] Judge the compatibility between the compiled test cases and the function to be tested;
[0086] When it is determined that the compiled test cases are compatible with the function to be tested and there are multiple compiled test cases, generate the test script by the compilation tool according to the logical relationship, where the logical relationship is used to represent the logical order during the execution of multiple compiled test cases when implementing the function to be tested.
[0087] In some cases, the user may have pre-compiled the test cases. Then, during the process of generating the test script in step 103, the test script can be directly generated based on these test cases. That is to say, when it is determined that there are compiled test cases, the test cases can be obtained based on their paths. Of course, since the compiled test cases may sometimes not be completely matched with the function that the current user wants to test, in order to avoid using unmatched test cases for subsequent testing, in this embodiment, the compatibility between the test cases and the function to be tested can be judged first. This compatibility can be understood as determining whether the current test case and the function to be tested are functionally matched, or determining whether the test case is a test case specifically generated for this function in advance. The user can use any one of the above methods or other methods to determine the compatibility.
[0088] When it is determined that the compiled test case is compatible with the function to be tested, it means that the test script can be directly compiled based on this test case. Of course, there is another situation, that is, when it is determined that multiple test cases are all compatible with the function to be tested, that is to say, the function to be tested is actually formed by a combination of multiple sub-functions, and multiple sub-functions are actually tested during the test. Then, the order between test cases can be constructed according to the logic between these sub-functions according to the method of this embodiment, that is, a test script is generated based on the logical relationship. For example, when the function to be tested is actually executed in the logical order of "sub-function A - sub-function C - sub-function B" during implementation, and sub-function A corresponds to the compiled test case 1, sub-function C corresponds to the compiled test case 3, and sub-function B corresponds to the compiled test case 2. Then when constructing the test script for these test cases, the logical order between them should also correspond to the order between sub-functions, that is, "compiled test case 1 - compiled test case 3 - compiled test case 2".
[0089] In some embodiments, generating the test script for the function to be tested through the compilation tool in the foregoing step 103 includes:
[0090] When it is determined that the function to be tested corresponds to multiple test dimensions, corresponding test cases are respectively generated by using the compilation tool based on each test dimension;
[0091] Performing a test operation on the function to be tested through the test script includes:
[0092] Performing test operations respectively based on the test scripts corresponding to each test dimension, and using the control script to summarize the test results obtained based on each test script to obtain a total test result.
[0093] For many functions, different perspectives can be adopted for testing them, that is, the dimensions described in this embodiment. Then, when testing based on different dimensions, test results for each dimension will be generated. Therefore, in this embodiment, during the test, test operations need to be performed based on the test scripts corresponding to each dimension. At the same time, after the test operations are executed, these test results are summarized by using the control script to obtain a total test result. In this way, a certain function can be tested through multiple different dimensions, so that the obtained result is more comprehensive, avoiding the final result being too one-sided when only a certain dimension is used for testing, thereby ensuring the accuracy of the test.
[0094] In some embodiments, in the foregoing embodiments, test operations are respectively performed based on the test scripts corresponding to each test dimension, and the control script is used to summarize the test results obtained based on each test script to obtain the total test result, including:
[0095] Obtain the general test parameters and target test parameters of each test script, where the target test parameters are used to characterize the specific test parameters for the current test dimension;
[0096] Based on the test script, input the general test parameters and the target test parameters respectively, and obtain the first test result corresponding to the general test parameters and the second test result corresponding to the target test parameters respectively;
[0097] Based on the control script, obtain the first test result and the second test result obtained by each test script respectively, and determine the total test result based on the first test result and the second test result.
[0098] In some cases, when testing using a test script, dedicated parameters can also be set for the test script for input based on the needs of the user, so as to simulate the stability of the function to be tested under certain special circumstances. Therefore, in this embodiment, in addition to the general test parameters, target test parameters can also be used for testing. Therefore, in this embodiment, by inputting the general test parameters into the test script to obtain the first test result, the running situation of the function to be tested under normal circumstances can be obtained, and by inputting the target test parameters into the test script to obtain the second test result, the running situation of the function to be tested under certain special circumstances can be obtained. In this way, determining the total test result based on the first test result and the second test result can enable different situations to be tested when testing the function to be tested, ensuring that more comprehensive results can be obtained during testing, and then enabling subsequent staff to more comprehensively predict the running situation of a current function based on this total test result.
[0099] In some embodiments, the determination of the total test result based on the first test result and the second test result can be divided into the following two situations when executed, including:
[0100] On the one hand, when it is determined that the deviation value between the first test result and the second test result exceeds a preset threshold, the second test result is used as the total test result;
[0101] On the other hand, when it is determined that the deviation value between the first test result and the second test result exceeds a preset threshold, a third test result is generated, and the third test result is determined as the total test result, where the third test result is used to characterize that the function to be tested is abnormal.
[0102] Based on the foregoing embodiments, the first test result and the second test result respectively characterize the operating conditions of the function to be tested under normal circumstances and special circumstances. Therefore, that is to say, sometimes, these two situations are very likely to be two results obtained by testing using the average value and the extreme value. Therefore, when determining the total test result based on the first test result and the second test result, if the user needs to ensure that a certain function operates normally in all situations, then the method of the previous aspect of this step can be followed. When the deviation value between the two test results is too large, only the second test result is used as the total test result. That is to say, only when it is ensured that the function to be tested is normal in extreme situations can it be determined that the function is normal. Then only the second test result, that is, the test result obtained by inputting the target test parameter, is used as the test result of the entire function, that is, the total test result.
[0103] On the contrary, in some cases, it is not only necessary to ensure that the function to be tested can operate normally in some extreme situations, but also necessary to ensure the normal operation of the function to be tested under normal circumstances. Then in this embodiment, the method of the latter aspect can be followed. Analyze based on the first test result and the second test result to obtain a third test result, and determine the third test result as the total test result based on the third test result. That is to say, when the deviation value between the two results obtained by the general test parameter and the target test parameter is too large, it can be determined that the current function has a problem, and thus directly obtain the third test result indicating that the function to be tested is abnormal as the total test result, so as to directly prompt the subsequent staff that the test function cannot ensure normal operation under normal circumstances and extreme situations.
[0104] Furthermore, as an implementation of the above Figure 1 shown method, another embodiment of the present application also provides a testing device. This device embodiment corresponds to the foregoing method embodiment. For the convenience of reading, this device embodiment will not repeat the detailed content of the foregoing method embodiment one by one, but it should be clear that the device in this embodiment can correspondingly implement all the content of the foregoing method embodiment. In order to implement a testing method, specifically as Figure 2 shown, the device includes:
[0105] The first determination unit 21 can be used to obtain a test requirement and determine the function to be tested based on the test requirement;
[0106] The acquisition unit 22 can be used to obtain the compilation tool of the function to be tested through a control script based on the function to be tested;
[0107] A generating unit 23, which can be used to generate a test script for the function to be tested by the compilation tool, where the test script includes at least one test case corresponding to the function to be tested;
[0108] An execution unit 24, which can be used to perform a test operation on the function to be tested through the test script.
[0109] Furthermore, as Figure 3 shown, the apparatus further includes:
[0110] A second determination unit 25, which can be used to respectively determine the compilation tools corresponding to each function to be tested and set path information for each compilation tool;
[0111] The obtaining unit 22 can also be used to determine the target compilation tool corresponding to the function to be tested based on the control script, and obtain the target compilation tool based on the path information of the target compilation tool.
[0112] Furthermore, as Figure 3 shown, the generating unit 23 can also be used to determine the compilation parameters and function categories corresponding to the function to be tested based on the compilation tool, and perform a compilation operation based on the compilation parameters according to the function categories to obtain at least one of the test cases corresponding to the function to be tested; and generate the test script based on at least one of the test cases, where the execution order of each test case during the test is set in the test script.
[0113] Furthermore, as Figure 3 shown, the generating unit 23 can also be used to, when it is determined that there are compiled test cases, obtain the compiled test cases based on a preset test case path; and determine the compatibility between the compiled test cases and the function to be tested; and when it is determined that the compiled test cases are compatible with the function to be tested and there are multiple compiled test cases, generate the test script by the compilation tool according to the logical relationship between the compiled test cases, where the logical relationship can be used to represent the logical order during the execution of multiple compiled test cases when implementing the function to be tested.
[0114] Furthermore, as Figure 3 shown, the generating unit 23 can also be used to, when it is determined that the function to be tested corresponds to multiple test dimensions, respectively generate corresponding test cases for each test dimension by using the compilation tool;
[0115] The execution unit 24 may specifically be further configured to perform test operations based on the test scripts corresponding to each test dimension, and summarize the test results obtained based on each of the test scripts by using the control script to obtain the total test result.
[0116] Further, as Figure 3 shown, the execution unit 24 may further be configured to obtain the general test parameters and the target test parameters of each of the test scripts, where the target test parameters may be used to represent specific test parameters for the current test dimension; and, input the general test parameters and the target test parameters based on the test scripts respectively, and obtain a first test result corresponding to the general test parameters and a second test result corresponding to the target test parameters respectively; and, obtain the first test result and the second test result obtained by each of the test scripts based on the control script respectively, and determine the total test result based on the first test result and the second test result.
[0117] Further, as Figure 3 shown, the execution unit 24 may further be configured to use the second test result as the total test result when it is determined that the deviation value between the first test result and the second test result exceeds a preset threshold;
[0118] The execution unit 24 may further be configured to generate a third test result and determine the third test result as the total test result when it is determined that the deviation value between the first test result and the second test result exceeds a preset threshold, and the third test result may be used to represent that the function to be tested is abnormal.
[0119] To achieve the above object, according to another aspect of the present application, an embodiment of the present application further provides a storage medium, where the storage medium includes a stored program, and when the program runs, it controls the device where the storage medium is located to execute the above-mentioned test method.
[0120] To achieve the above object, according to another aspect of the present application, an embodiment of the present application further provides a test device, where the device includes a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions run, they execute the above-mentioned test method.
[0121] An embodiment of the present application provides a testing method and apparatus. In the embodiment of the present application, it is possible to first obtain a testing requirement and determine a function to be tested based on the testing requirement; then, based on the function to be tested, obtain a compilation tool for the function to be tested through a control script; thereafter, generate a test script for the function to be tested through the compilation tool, where the test script includes at least one test case corresponding to the function to be tested; and finally, perform a testing operation on the function to be tested through the test script, thereby implementing the testing function. Compared with the prior art, in the embodiment of the present application, a corresponding test script can be directly generated based on the testing requirement during testing, and the test script is used for testing. In this way, a function of automatically testing based on the user's testing requirement is realized, which is different from the process of manual testing in the prior art. The method in the embodiment of the present application can directly and automatically determine the function to be tested by obtaining the user's testing requirement, so the process of the operator independently determining the required testing function is omitted, and the possibility that the determination result of the function to be tested is problematic due to the low testing level or operation error of the operator is avoided. At the same time, after obtaining the compilation tool through the control script based on the function to be tested, a test script corresponding to the testing function can be automatically generated based on the compilation tool, which realizes the effect of automatically compiling the test script by the compilation tool itself, thereby omitting the compilation threshold required for the operator to manually compile the test script, and further avoiding the problem that the accuracy of the testing result is relatively low when there are problems with the test script compiled manually, and then improving the accuracy of the testing process.
[0122] The testing apparatus includes a processor and a memory. The above-mentioned first determination unit, acquisition unit, generation unit, execution unit, etc. are all stored in the memory as program units, and the corresponding functions are realized by the processor executing the above-mentioned program units stored in the memory.
[0123] The processor includes a kernel, and the kernel retrieves the corresponding program unit from the memory. One or more kernels can be set, and by adjusting the kernel parameters, a testing method is implemented to solve the problem that the accuracy of the testing result obtained in the existing testing process is relatively low.
[0124] An embodiment of the present application provides a testing device, where the device includes a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions run, they execute the testing method described in any one of the foregoing.
[0125] An embodiment of the present application provides a storage medium, where the storage medium includes a stored program, and when the program runs, it controls the device where the storage medium is located to execute the testing method described above.
[0126] The storage medium may include non - permanent memory in the form of computer - readable media, random access memory (RAM) and / or non - volatile memory, such as read - only memory (ROM) or flash RAM, and the memory includes at least one storage chip.
[0127] An embodiment of the present application provides a device, which includes a processor, a memory, and a program stored on the memory and executable on the processor. When the processor executes the program, the following steps are implemented: obtaining test requirements, and determining a function to be tested based on the test requirements; based on the function to be tested, obtaining a compilation tool for the function to be tested through a control script; generating a test script for the function to be tested through the compilation tool, where the test script includes at least one test case corresponding to the function to be tested; and performing a test operation on the function to be tested through the test script.
[0128] Further, before obtaining the compilation tool for the function to be tested through the control script based on the function to be tested, the method further includes:
[0129] Determining the compilation tool corresponding to each function to be tested respectively, and setting path information for each compilation tool;
[0130] The obtaining the compilation tool for the function to be tested through the control script based on the function to be tested includes:
[0131] Based on the control script, determining the target compilation tool corresponding to the function to be tested, and obtaining the target compilation tool based on the path information of the target compilation tool.
[0132] Further, the generating the test script for the function to be tested through the compilation tool includes:
[0133] Determining compilation parameters and function categories corresponding to the function to be tested based on the compilation tool, and performing a compilation operation based on the compilation parameters according to the function categories to obtain at least one of the test cases corresponding to the function to be tested;
[0134] Generating the test script based on at least one of the test cases, where the execution order of each test case during the test is set in the test script.
[0135] Further, the generating the test script for the function to be tested through the compilation tool includes:
[0136] When it is determined that there are compiled test cases, obtaining the compiled test cases based on a preset test case path;
[0137] Judging the compatibility between the compiled test cases and the function to be tested;
[0138] When it is determined that the compiled test cases are compatible with the function to be tested and it is determined that there are multiple compiled test cases, the compiled test cases are used by the compilation tool to generate the test script according to the logical relationship, where the logical relationship is used to characterize the logical order during the execution of multiple compiled test cases when implementing the function to be tested.
[0139] Further, generating the test script for the function to be tested by the compilation tool includes:
[0140] When it is determined that the function to be tested corresponds to multiple test dimensions, corresponding test cases are respectively generated for each test dimension by using the compilation tool;
[0141] Performing a test operation on the function to be tested by the test script includes:
[0142] Performing test operations respectively based on the test scripts corresponding to each test dimension, and using the control script to summarize the test results obtained based on each test script to obtain the total test result.
[0143] Further, performing test operations respectively based on the test scripts corresponding to each test dimension, and using the control script to summarize the test results obtained based on each test script to obtain the total test result includes:
[0144] Obtaining the general test parameters and target test parameters of each test script, where the target test parameters are used to characterize the specific test parameters for the current test dimension;
[0145] Inputting the general test parameters and the target test parameters respectively based on the test script, and respectively obtaining a first test result corresponding to the general test parameters and a second test result corresponding to the target test parameters;
[0146] Obtaining the first test result and the second test result obtained by each test script respectively based on the control script, and determining the total test result based on the first test result and the second test result.
[0147] Further, determining the total test result based on the first test result and the second test result includes:
[0148] When it is determined that the deviation value between the first test result and the second test result exceeds a preset threshold, taking the second test result as the total test result;
[0149] Or,
[0150] When it is determined that the deviation value between the first test result and the second test result exceeds a preset threshold, a third test result is generated, and the third test result is determined as the total test result, where the third test result is used to characterize that the function to be tested is abnormal.
[0151] The present application also provides a computer program product that can execute corresponding functions, including: obtaining test requirements, and determining a function to be tested based on the test requirements; based on the function to be tested, obtaining a compilation tool for the function to be tested through a control script; generating a test script for the function to be tested through the compilation tool, where the test script includes at least one test case corresponding to the function to be tested; and performing a test operation on the function to be tested through the test script.
[0152] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0153] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or multiple flows and / or blocks
[0154] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device that implements the functions specified in Figure 1 one or more of the flows Figure 1 or multiple flows and / or blocks
[0155] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 steps of the functions specified in one block or multiple blocks.
[0156] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0157] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM) and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer-readable media.
[0158] Computer-readable media includes permanent and non-permanent, removable and non-removable media and can be implemented by any method or technology for information storage. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0159] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.
[0160] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0161] The above are only the embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A testing method, characterized in that, The method includes: Obtain test requirements and determine the function to be tested based on the test requirements; Based on the function to be tested, obtain the compilation tool for the function to be tested through a control script; Generate a test script for the function to be tested through the compilation tool, where the test script includes at least one test case corresponding to the function to be tested; Execute a test operation on the function to be tested through the test script.
2. The method according to claim 1, wherein Before the step of obtaining the compilation tool for the function to be tested through a control script based on the function to be tested, the method further includes: Respectively determine the compilation tool corresponding to each function to be tested and set path information for each compilation tool; The step of obtaining the compilation tool for the function to be tested through a control script based on the function to be tested includes: Based on the control script, determine the target compilation tool corresponding to the function to be tested, and obtain the target compilation tool based on the path information of the target compilation tool.
3. The method according to claim 1, characterized in that The step of generating a test script for the function to be tested through the compilation tool includes: Based on the compilation tool, determine the compilation parameters and function categories corresponding to the function to be tested, and perform a compilation operation based on the compilation parameters according to the function categories to obtain at least one test case corresponding to the function to be tested; Generate the test script based on at least one test case, where the execution order of each test case during testing is set in the test script.
4. The method according to claim 1, characterized in that, The step of generating a test script for the function to be tested through the compilation tool includes: When it is determined that there are compiled test cases, obtain the compiled test cases based on a preset test case path; Judge the compatibility between the compiled test cases and the function to be tested; When it is determined that the compiled test cases are compatible with the function to be tested and there are multiple compiled test cases, generate the test script by the compilation tool according to the logical relationship among the compiled test cases, where the logical relationship is used to represent the logical order during execution when multiple compiled test cases implement the function to be tested.
5. The method according to claim 1, wherein The step of generating a test script for the function to be tested through the compilation tool includes: When it is determined that the function to be tested corresponds to multiple test dimensions, respectively generate corresponding test cases for each test dimension by using the compilation tool; The step of executing a test operation on the function to be tested through the test script includes: Respectively perform test operations based on the test scripts corresponding to each test dimension, and use the control script to summarize the test results obtained based on each test script to obtain a total test result.
6. The method according to claim 5, characterized in that The step of respectively performing test operations based on the test scripts corresponding to each test dimension and using the control script to summarize the test results obtained based on each test script to obtain a total test result includes: Obtain the general test parameters and target test parameters of each test script, where the target test parameters are used to represent specific test parameters for the current test dimension; Input the general test parameters and the target test parameters respectively based on the test script, and obtain a first test result corresponding to the general test parameters and a second test result corresponding to the target test parameters respectively; Obtain the first test result and the second test result obtained by each test script respectively based on the control script, and determine the total test result based on the first test result and the second test result.
7. The method according to claim 6, characterized in that The determining the total test result based on the first test result and the second test result includes: When it is determined that the deviation value between the first test result and the second test result exceeds a preset threshold, use the second test result as the total test result; Or, When it is determined that the deviation value between the first test result and the second test result exceeds a preset threshold, generate a third test result, and determine the third test result as the total test result, where the third test result is used to characterize that there is an abnormality in the function to be tested.
8. A testing device, characterized in that, The device includes: A first determination unit, configured to obtain a test requirement and determine a function to be tested based on the test requirement; An acquisition unit, configured to obtain a compilation tool for the function to be tested through a control script based on the function to be tested; A generation unit, configured to generate a test script for the function to be tested through the compilation tool, where the test script includes at least one test case corresponding to the function to be tested; An execution unit, configured to perform a test operation on the function to be tested through the test script.
9. A storage medium, characterized in that, The storage medium includes a stored program, where, when the program runs, it controls the device where the storage medium is located to execute the test method according to any one of claims 1-7.
10. A test device, characterized in that, The device includes a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions run, they execute the test method according to any one of claims 1-7.