Automatic test method, device and equipment for universal actuator and storage medium
Through the automated test method of a general executor, cross-language function calls and decoupling executors and test action functions are used to solve the problem of docking between different subsystems, realize code reuse and resource optimization, and improve the efficiency and universality of automated testing. sex.
Patent Information
- Application Number
- CN202411295339.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2024-11-08
AI Technical Summary
The existing automation software testing framework is difficult to connect between different subsystems, resulting in waste of resources and repeated code development, lack of universality, and it is difficult to achieve cross-subsystem reuse.
Provides an automated test method for a general executor, which can perform test action functions through parsing test cases and cross-language function calls, decoupling executors and test action functions, allowing implementation of different programming languages to improve the universality of the framework and code complexity. Usability.
It reduces the difficulty of writing test cases, reduces code duplication development, avoids human resources waste, and improves the universality and testing efficiency of the framework.
Smart Images

Figure CN118916293A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of automated software testing, and in particular to an automated testing method, device, equipment and storage medium for a universal actuator. Background Art
[0002] Automated software testing is becoming more and more popular in the field of software testing because it is more reliable and faster. A common automated software testing framework is the "keyword-driven framework", which decomposes test cases into multiple detailed test steps, and then simplifies and abstracts the test steps into a keyword. There may be very similar test steps in multiple test cases, which can be replaced with the same keyword, and the differences in details of these similar test steps can be distinguished by step parameters. The automated test developers of specific product projects complete the specific test action code writing corresponding to each keyword. When writing automated test cases, project testers only need to combine and arrange multiple keywords and required step parameters in a certain order to form a test case; this can separate code writing from test case writing, so that project testers do not need coding skills and can think more about how to improve the quality of test cases.
[0003] A complete chip product development activity often involves multiple subsystems, which can be roughly divided into chip hardware, chip firmware, board firmware, and host driver subsystems. These subsystems have different focuses and characteristics, and usually have their own dedicated automated testing architectures, and then develop corresponding tools, test scripts, and test cases. Even if everyone chooses the "keyword-driven framework", since it is just a framework, many details need to be added before it can be implemented, so there will still be basic isolation between the subsystems, and the implementation details of the framework and the test methods are different, making it difficult to connect and reuse across subsystems, resulting in a waste of resources.
[0004] Therefore, how to realize a universal executor based on a keyword-driven framework, improve the versatility of the framework, reduce duplicate code development, and avoid waste of human resources is an urgent problem that needs to be solved today. Summary of the invention
[0005] The purpose of the present invention is to provide an automated testing method, device, equipment and computer-readable storage medium for a universal executor, so as to realize a universal executor based on a keyword-driven framework, improve the versatility of the framework, reduce the situation of repeated code development, and avoid the waste of human resources.
[0006] In order to solve the above technical problems, the present invention provides an automatic testing method for a universal actuator, comprising:
[0007] Parse the acquired current test case to determine the current test step; wherein the current test step is any test step in the current test case, the test step includes a keyword identifier and a step parameter, and the step parameter includes an expected return value of the step and an input parameter of a test action function;
[0008] Searching for a target keyword record item corresponding to the keyword identifier of the current test step from the keyword library; wherein the target keyword record item is any keyword record item in the keyword library, the keyword record item includes a keyword, a test action function entry and a test action description, the keyword includes a test action and a test object, and the test action functions corresponding to the test action function entries in at least two keyword record items in the keyword library adopt different programming languages;
[0009] According to the step parameters of the current test step, a target test action function is called and executed by adopting a cross-language function call method to obtain a step test result of the current test step; wherein the target test action function is a test action function corresponding to a test action function entry in the target keyword record item;
[0010] According to the step test results, the test result of the current test case is determined.
[0011] On the other hand, the current test case is a smoke test case, and before parsing the acquired test case and determining the current test step, the method further includes:
[0012] Get code change pull requests;
[0013] Searching for a current test case corresponding to the code change merge request from a preset smoke test case set;
[0014] Correspondingly, after determining the test result of the current test case according to the test result of the step, the method further includes:
[0015] If the test result of the current test case is a test failure, the code change of the code change merge request is rejected.
[0016] On the other hand, the step parameters also include step scheduling methods, which include serial and parallel methods; the keyword library is a text file or a table file.
[0017] On the other hand, the step parameters of the current test step are used to call and execute the target test action function in a cross-language function call mode to obtain the step test result of the current test step, including:
[0018] If the step scheduling mode of the current test step is serial, calling and executing the target test action function according to the test action function input parameters of the current test step, and obtaining the function return value of the target test action function;
[0019] Obtaining a step test result of the current test step according to the function return value and the expected step return value of the current test step;
[0020] If the step scheduling mode of the current test step is parallel, a new test process is enabled to utilize the test process, call and execute the target test action function according to the test action function input parameters of the current test step, and obtain the function return value of the target test action function;
[0021] Determine whether the step scheduling mode of the next test step adjacent to the current test step in the current test case is parallel;
[0022] If yes, the next test step is used as the current test step, and the step of searching the keyword library for the target keyword record item corresponding to the keyword identifier of the current test step is performed;
[0023] If not, then obtain the step test results of the current test step and the adjacent parallel test steps based on the function return values and step expected return values corresponding to each of the current test step and the parallel test steps adjacent to the current test step, and execute the step of determining the case test result of the current test case based on the step test results.
[0024] On the other hand, determining the test result of the current test case according to the test result of the step includes:
[0025] In the case where the step scheduling mode of the current test step is serial, if the step test result of the current test step is a test failure, the case test result of the current test case is determined to be a test failure; if the step test result of the current test step is a test pass, then when the current test step is the last test step of the current test case, the case test result of the current test case is determined to be a test pass; when the current test step is not the last test step of the current test case, the parsing of the acquired current test case is performed to determine the step of the current test step;
[0026] When the step scheduling mode of the current test step is parallel, if there is a test failure in the step test results of the current test step and the adjacent parallel test steps, the case test result of the current test case is determined to be a test failure; if the step test results of the current test step and the adjacent parallel test steps are both test successes, then when the last test step of the current test step and the adjacent parallel test steps is the last test step of the current test case, the case test result of the current test case is determined to be a test pass; when the last test step of the current test step and the adjacent parallel test steps is not the last test step of the current test case, the parsing of the acquired current test case is executed to determine the steps of the current test step.
[0027] In another aspect, the method further comprises:
[0028] Obtaining a record item addition request; wherein the record item addition request includes a newly added keyword and an identifier of a historical test action function entry;
[0029] According to the record item addition request, a corresponding keyword record item is added to the keyword library.
[0030] In another aspect, the method further comprises:
[0031] Obtain a keyword search request; wherein the keyword search request includes a target object under test and a target test action;
[0032] According to the target object to be measured, searching the target keyword corresponding to the target object to be measured from the keyword library; wherein the target keyword includes the target object to be measured;
[0033] Searching for an optional keyword corresponding to the target test action from the target keyword; wherein the optional keyword includes the target test action;
[0034] The test action description in the keyword record item where the optional keyword is located is displayed and outputted.
[0035] The present invention also provides an automatic testing device for a universal actuator, comprising:
[0036] A parsing module, used to parse the acquired current test case to determine the current test step; wherein the current test step is any test step in the current test case, the test step includes a keyword identifier and a step parameter, and the step parameter includes an expected return value of the step and an input parameter of a test action function;
[0037] A search module, used for searching a target keyword record item corresponding to a keyword identifier of a current test step from a keyword library; wherein the target keyword record item is any keyword record item in the keyword library, the keyword record item includes a keyword, a test action function entry and a test action description, the keyword includes a test action and a test object, and the test action functions corresponding to the test action function entries in at least two keyword record items in the keyword library adopt different programming languages;
[0038] An execution module, used to call and execute a target test action function in a cross-language function call mode according to the step parameters of the current test step, to obtain a step test result of the current test step; wherein the target test action function is a test action function corresponding to a test action function entry in the target keyword record item;
[0039] The determination module is used to determine the test result of the current test case according to the step test result.
[0040] The present invention also provides an automatic testing device for a universal actuator, comprising:
[0041] Memory for storing computer programs;
[0042] A processor is used to implement the steps of the above-mentioned method for automated testing of a universal actuator when executing the computer program.
[0043] In addition, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the automatic testing method for the universal actuator as described above are implemented.
[0044] An automated testing method for a universal actuator provided by the present invention comprises: parsing an acquired current test case to determine a current test step; wherein the current test step is any test step in the current test case, the test step comprises a keyword identifier and a step parameter, and the step parameter comprises an expected return value of the step and an input parameter of a test action function; searching a target keyword record item corresponding to the keyword identifier of the current test step from a keyword library; wherein the target keyword record item is any keyword record item in the keyword library, the keyword record item comprises a keyword, a test action function entry and a test action description, the keyword comprises a test action and a tested object, and the test action functions corresponding to the test action function entries in at least two keyword record items in the keyword library adopt different programming languages; according to the step parameter of the current test step, calling and executing the target test action function in a cross-language function calling manner to obtain a step test result of the current test step; wherein the target test action function is the test action function corresponding to the test action function entry in the target keyword record item; according to the step test result, determining the case test result of the current test case;
[0045] It can be seen that the present invention decouples the executor from the test action function, so that the executor can use a cross-language function call method to call and execute the test action function corresponding to each test step from the function entry, so that the test action function and the executor can be independently implemented in different programming languages, and the test action function can be implemented in different programming languages, so that the test action function can be coded by test developers from different teams using the programming language they are good at or meet their own needs, which reduces the difficulty of writing test cases and improves the versatility of the framework. Therefore, through the configuration of keywords in the keyword record items in the keyword library, the test action function entry and the test action description, the situation of repeated code development is reduced and the waste of human resources is avoided. In addition, the present invention also provides an automated testing device, equipment and computer-readable storage medium for a universal executor, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0047] Figure 1 A flowchart of an automated testing method for a universal actuator provided by an embodiment of the present invention;
[0048] Figure 2A schematic flow chart of another automated testing method for a universal actuator provided by an embodiment of the present invention;
[0049] Figure 3 A schematic diagram of a keyword library search and new addition process provided by an embodiment of the present invention;
[0050] Figure 4 A flowchart of an automated testing method for a universal actuator provided by an embodiment of the present invention;
[0051] Figure 5 A schematic flow chart of another automated testing method for a universal actuator provided by an embodiment of the present invention;
[0052] Figure 6 A structural block diagram of an automatic testing device for a universal actuator provided by an embodiment of the present invention;
[0053] Figure 7 A schematic structural diagram of an automated testing device for a universal actuator provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0055] Please refer to Figure 1 , Figure 1 A flowchart of an automated testing method for a universal actuator provided by an embodiment of the present invention. The method may include:
[0056] Step 101: parse the acquired current test case to determine the current test step; wherein the current test step is any test step in the current test case, the test step includes a keyword identifier and step parameters, and the step parameters include the expected return value of the step and the input parameters of the test action function.
[0057] It can be understood that the current test case in this embodiment can be a test case that needs to be tested currently. In this step, the processor can parse the acquired current test case through the executor (i.e., the general executor) running in the test environment to determine the current test step; wherein the executor can be a component in the keyword-driven automated test, running in the test environment, and the core function is to parse the test case and execute the test action. Keyword-driven refers to separating the writing and execution of the test script, and using a set of predefined keywords to represent the actions to be performed by the test, such as click, input, wait, etc. Testers can create test cases by combining these keywords without writing actual code, so that testers with non-technical backgrounds can also participate in the process of automated testing.
[0058] Correspondingly, the specific type of the current test case in this embodiment can be set by the designer or user according to the usage scenario and user needs. For example, the current test case can be a test case configured and input by the tester; or it can be an automatically generated test case, such as a smoke test case for performing a smoke test on the changed code. This embodiment does not impose any restrictions on this.
[0059] Correspondingly, the specific content of the current test case in this embodiment can be set by the designer. For example, each test case in this embodiment (i.e., the current test case) can include one or more test steps, and each test step can include a keyword identifier and a step parameter; wherein, the keyword identifier can identify a keyword record item in the keyword library (i.e., the target keyword record item), such as the keyword identifier can be a keyword in the keyword record item (i.e., the keyword name), or it can be other identifiers, such as the serial number code of the keyword record item; as long as the corresponding target keyword record item can be found from the keyword library according to the keyword identifier, this embodiment does not impose any restrictions on this.
[0060] Correspondingly, the step parameters of each test step may include parameters for passing to the corresponding test action function (i.e., test action function input parameters) and the expected return value after the test action function is executed (i.e., the expected return value of the step). In order to improve the accuracy of the test, the step parameters of each test step may also include step scheduling methods, such as serial (i.e., sequential execution) and parallel (i.e., concurrent execution), so that the executor can support different scheduling methods for each test step; for example, when the step scheduling method of test step 1 is serial, the executor can execute the subsequent test step 2 after test step 1 is executed; when the step scheduling methods of two or more adjacent test steps are parallel, the executor can execute these test steps simultaneously, and these test steps are independent of each other.
[0061] It should be noted that, for the specific method of parsing the current test case obtained in this step and determining the current test step, for example, the current test case obtained can be parsed through an executor, and a test step that needs to be executed currently (i.e., the current test step) can be determined from all the test steps of the current test case; for example, after the tester or the upstream module of an automation system starts the executor on the environment to be tested, a test case (i.e., the current test case) can be sent to the environment to be tested; after receiving the current test case, the executor parses it, and first determines the test step corresponding to the first keyword obtained by the analysis (i.e., the first test step) as the current test step, and enters step 102; when the test result of the first or other test steps is that the test passes, the next test step can be determined as the current test step, and the process goes to step 102.
[0062] Step 102: Search the keyword library for the target keyword record item corresponding to the keyword identifier of the current test step.
[0063] Among them, the target keyword record item is any keyword record item in the keyword library, the keyword record item includes keywords, test action function entries and test action descriptions, the keywords include test actions and tested objects, and the test action functions corresponding to the test action function entries in at least two keyword record items in the keyword library use different programming languages.
[0064] It is understandable that the conventional keyword library in the related art is relatively simple, and usually exists in the form of program code as part of the executor, in which only the available keywords and their mapping relationship with the test action or test action function entry are stored. In this embodiment, in order to facilitate the search of keywords and the configuration of test cases, the storage structure of each keyword record item in the keyword library is set to include 3 required elements: keywords, test action function entry and test action description; wherein the test action description can be written by the configurator of the test action function (such as an automated test developer within a subsystem team) to describe the function parameters and function functions required by the test action function, so that subsequent testers can easily view the test action status of the test action function corresponding to the test action function entry.
[0065] Correspondingly, the naming of keywords in this embodiment can introduce specific rules to facilitate keyword indexing; for example, the keywords in each keyword record item can include test actions and objects under test. In some embodiments, the keywords can also include special suffixes to distinguish keywords with the same test actions and objects under test through the special suffixes.
[0066] Correspondingly, the naming of the test action function entry in each keyword record item in the present embodiment can also be set with reference to the naming rules of the above-mentioned keywords, so that automated test developers have unified rules when determining the name of the test action function. For example, the test action function entry in each keyword record item can include a test action, a test object and / or a special suffix.
[0067] In this embodiment, different keywords can be allowed to correspond to the same test action function entry in each keyword record item of the keyword library; for example, the closing action and exit action of a tested object can correspond to the same test action function entry. In other words, in this embodiment, two keyword record items with the same keyword can have different test action function entries.
[0068] Specifically, this embodiment does not limit the storage form of the keyword library. For example, the keyword library may not exist in the form of program code, but may be stored in a more convenient file form (such as a text file or a table file), so as to better decouple the executor from the keyword library. For example, the keyword library may be a text file or a table file.
[0069] It should be noted that the specific method of searching the keyword library for the target keyword record item corresponding to the keyword identifier of the current test step in this step can be set by the designer. For example, the processor can find the test action function entry (i.e., the target keyword record item) where the keyword corresponding to the keyword identifier is located from the keyword library according to the keyword identifier in the current test step. For example, when the keyword identifier in the current test step is a keyword, the processor can directly use the keyword in the current test step through the executor to find the target keyword record item from the keyword library.
[0070] Step 103: According to the step parameters of the current test step, a cross-language function call method is used to call and execute the target test action function to obtain the step test result of the current test step; wherein the target test action function is the test action function corresponding to the test action function entry in the target keyword record item.
[0071] It is understandable that in this embodiment, the executor can use a cross-language function call method to start executing the corresponding test action function through the test action function entry; for example, the CFFI (C Foreign Function Interface) technology of Python language (a programming language) calling a function written in C language (a programming language) and the JNI (Java Native Interface, a technology that allows Java programs to interact with other programming languages) technology of Java language calling a function written in C language. In this embodiment, through the cross-language function call method adopted by the executor and the setting of the test action function entry in the keyword library, the executor does not need to only support the test action function written in the same programming language as the executor, or only support the test action function written in a specified other programming language, as in the related art, but can make the test action function and the executor independently implemented in different programming languages, and allow the test action function to be implemented in different programming languages, so that the test action function can be coded by test developers of different teams using the programming language they are good at or meet their own needs, which reduces the difficulty of writing test cases, improves the versatility of the framework, and reduces the situation of repeated code development.
[0072] Correspondingly, the specific method for obtaining the step test result of the current test step by calling and executing the target test action function in a cross-language function calling manner according to the step parameters of the current test step in this step can be set by the designer. For example, when the step parameters of the current test step do not include the step scheduling method, the processor can use the executor to directly call and execute the target test action function in a cross-language function calling manner according to the test action function input parameters of the current test step to obtain the function return value (i.e., the actual return value) of the target test action function; the step test result of the current test step is determined by comparing the function return value with the expected step return value of the current test step; for example, when the function return value meets the expected step return value (such as being the same or within the range of the expected step return value), the step test result of the current test step is determined to be a passed test; when the function return value does not meet the expected step return value, the step test result of the current test step is determined to be a failed test.
[0073] Correspondingly, when the step parameters of the current test step include a step scheduling mode, the processor can, through the executor, when the step scheduling mode of the current test step is serial, call and execute the target test action function according to the test action function input parameters of the current test step to obtain the function return value of the target test action function; obtain the step test result of the current test step according to the function return value and the expected step return value of the current test step, and enter step 104; when the step scheduling mode of the current test step is parallel, enable a new test process to utilize the test process, call and execute the target test action function according to the test action function input parameters of the current test step, and obtain the function return value of the target test action function; determine whether the step scheduling mode of the next test step adjacent to the current test step in the current test case is parallel; if so, take the next test step as the current test step, and enter step 102; if not, obtain the step test results of the current test step and the adjacent parallel test step according to the function return value and the step expected return value corresponding to each of the current test step and the parallel test step adjacent to the current test step, and enter step 104.
[0074] For example, if Figure 2 As shown, the executor uses a keyword obtained by parsing (i.e., the keyword of the current test step) to search the target keyword record item corresponding to the keyword from the keyword library, and then obtains the test action function entry corresponding to the keyword in the target keyword record item; finds the step parameters of the current test step from the current test case and parses them to obtain the expected return value of the step and the step scheduling method in the step parameters; and parses the parameters to be passed to the test action function (i.e., the test action function input parameters) from the step parameters according to the test action description in the target keyword record item.
[0075] Afterwards, the executor can be divided into the following two modes according to the step scheduling mode: execute the test action function from the test action function entrance, and pass in the parsed test action function input parameters; if the step scheduling mode is serial, execute the test action function normally, wait for the test action function to be executed, and receive the return value of the test action function (i.e., the function return value); if the step scheduling mode is parallel, it is necessary to start a new process to execute the test action function, and when the current test step is not the last parallel test step in a section of adjacent test steps, the executor can enter step 102 to continue parsing and execute the next test step; when the current test step is the last parallel test step in a section of adjacent test steps, the executor can wait for the test action functions of this section of adjacent and parallel test steps to be executed, receive each function return value, and compare all function return values of this section of adjacent and parallel test steps with their respective step expected return values one by one to obtain their respective step test results.
[0076] Furthermore, the target test action function in this embodiment can be a binary library file, so that by compiling the test action functions corresponding to each test action function entry in the keyword library into a binary library, it is possible to prevent exposure of encoding technical details in the test action function; accordingly, the executor can execute the binary library file corresponding to the target test action function to complete the execution of the target test action function.
[0077] Step 104: Determine the test case test result of the current test case according to the step test result.
[0078] It is understandable that in this step, the processor can determine the case test result of the current test case through the executor according to the step test results of each test step. Correspondingly, the specific method of determining the case test result of the current test case according to the step test result in this step can be set by the designer according to the practical scenario and user needs. For example, when the step parameter of the current test step does not include the step scheduling method, the processor can determine the case test result of the current test case as a test failure through the executor when the step test result of the current test step is a test failure; when the step test result of the current test step is a test pass, if the current test step is the last test step of the current test case, then determine the case test result of the current test case as a test pass; if the current test step is not the last test step of the current test case, enter step 101, and continue to determine the next adjacent test step as the current test step to perform the test of the next test step.
[0079] Accordingly, when the step parameters of the current test step include a step scheduling mode, the processor can use the executor to, when the step scheduling mode of the current test step is serial, if the step test result of the current test step is a test failure (such as Figure 2 FAIL in the test case), the test result of the current test case is determined to be a test failure; if the step test result of the current test step is a test pass (such as Figure 2PASS in it), then when the current test step is the last test step of the current test case, it is determined that the case test result of the current test case is a passed test; when the current test step is not the last test step of the current test case, go to step 101; when the step scheduling mode of the current test step is parallel, if there is a test failure in the step test results of the current test step and the adjacent parallel test step, it is determined that the case test result of the current test case is a test failure; if the step test results of the current test step and the adjacent parallel test step are both successful tests, then when the last test step of the current test step and the adjacent parallel test step is the last test step of the current test case, it is determined that the case test result of the current test case is a passed test; when the last test step of the current test step and the adjacent parallel test step is not the last test step of the current test case, go to step 101.
[0080] That is to say, in this embodiment, the executor can run in the environment to be tested. After receiving the current test case, it parses it to obtain the first keyword (i.e., the first test step), and then parses the keyword library file to obtain the test action function entry corresponding to the keyword, and then passes in the test action function required by the function and starts executing the test action function from the entry. After the function is executed, the executor receives the function return value of the function, and determines whether it is consistent with the expected return value of the step indicated in the step parameter. If it does not meet the requirements, the parsing of the test case is terminated and the executor feeds back the test case failure information; if it meets the expected return value, the above test case is continued to be parsed to obtain the next keyword (i.e., the next test step)..., and so on, until the last test step is executed and the executor completes the test case result information feedback.
[0081] Since the executor in this embodiment can support different scheduling methods for test steps, the executor can parse the test case one by one to obtain the step keyword, and can also parse the step scheduling method from the step parameter corresponding to the keyword, and then schedule the test action function corresponding to the execution keyword according to the step scheduling method. For example, suppose a test case includes test step 1 (the scheduling method in the step parameter is serial), test step 2 (the scheduling method in the step parameter is parallel), test step 3 (parallel), test step 4 (parallel), test step 5 (serial), test step 6 (parallel), and test step 7 (parallel), and it is assumed that the test action function of each test step will return a function return value that meets the expected return value of the step; then, after the executor executes the test action function of test step 1, the executor receives the function return value of the function, and the function return value meets expectations. After that, the executor finds that the scheduling method of test step 2 is parallel, so it starts a new process to execute step 2 without waiting for its execution. After the execution is completed, a new process is started to execute step 3. Without waiting for its completion, a new process is started to execute test step 4. Then the executor waits for test steps 2, 3 and 4 to be completed. The executor determines that the function return values of test steps 2, 3 and 4 are in line with expectations. Then the executor executes the test action function of test step 5. After receiving the function return value of test step 5, a new process is started to execute test step 6. Without waiting for its completion, a new process is started to execute test step 7. The executor waits for test steps 6 and 7 to be completed. The executor determines that the function return values of test steps 6 and 7 are in line with expectations. Finally, the executor feedbacks the test case result as the case test passed.
[0082] Furthermore, the automated testing method provided by the present embodiment may also include a keyword search process in a keyword library to facilitate testers to create test cases. For example, the method provided by the present embodiment may also include: obtaining a keyword search request; wherein the keyword search request includes a target object under test and a target test action; according to the target object under test, searching the keyword library for a target keyword corresponding to the target object under test; wherein the target keyword includes the target object under test; searching the target keyword for an optional keyword corresponding to the target test action; wherein the optional keyword includes the target test action; and displaying and outputting the test action description in the keyword record item where the optional keyword is located.
[0083] That is to say, Figure 3As shown, when testers inside or outside the team intend to create test cases by combining and arranging keywords, they can first determine the object to be tested (i.e., the target object to be tested) and the test action (target test action) of a test step in the test case, and configure the keyword search request for the test step; after obtaining the keyword search request, the processor can search whether there is a corresponding keyword (i.e., an optional keyword) in the keyword library; if so, the corresponding test action description can be displayed, so that the tester can determine whether it meets the requirements through the displayed test action description, and then select an optional keyword as a test step of the test case when it meets the requirements; if there is no optional keyword or it does not meet the requirements, the automated test developer can be contacted to add a new keyword record item in the keyword library, and decide whether to introduce a new test action function entry or reuse an existing test action function entry as the test action function entry of the newly added record item based on the actual situation, and when adding a new test action function entry, the corresponding test action description must also be added.
[0084] Correspondingly, the method provided in this embodiment may further include: obtaining a record item addition request; adding a corresponding keyword record item to the keyword library according to the record item addition request. The record item addition request includes a newly added keyword and an identifier of a historical test action function entry, or includes a newly added keyword, a newly added test action function entry, and a newly added test action description.
[0085] Wherein, when the test action description in the keyword record item where the output optional keyword is located is displayed, the output optional keyword or the identifier of the optional keyword may also be displayed at the same time to facilitate the tester to configure the test case.
[0086] In this embodiment, the embodiment of the present invention decouples the executor from the test action function, so that the executor can use a cross-language function call method to call and execute the test action function corresponding to each test step from the function entry, so that the test action function and the executor can be independently implemented in different programming languages, and different programming languages are allowed to be used to implement the test action function, so that the test action function can be encoded by test developers from different teams using the programming language that they are good at or meets their own needs, which reduces the difficulty of writing test cases and improves the versatility of the framework, thereby reducing the situation of repeated code development and avoiding waste of human resources through the configuration of keywords in the keyword record items in the keyword library, the test action function entry and the test action description.
[0087] Based on the above embodiment, the present invention also provides another general actuator automatic testing method to achieve the connection between upstream and downstream modules in the automation system. Figure 4 , Figure 4A flowchart of an automated testing method for a universal actuator provided by an embodiment of the present invention. The method may include:
[0088] Step 201: Obtain a code change merge request.
[0089] It is understandable that, in the process of chip development, every time the software / hardware code is changed, in order to avoid introducing serious quality problems due to negligence or accident, a smoke test must be performed to verify whether the basic functions of the new version of software / hardware can operate normally and ensure that the main functions and processes can be executed smoothly. In this embodiment, the processor can perform a smoke test on the changed code based on the code change merge request triggered when the code is changed, such as the code change merge request submitted by the R&D personnel, and decide to accept or reject the code change based on the test results.
[0090] Correspondingly, the specific method of obtaining the code change merge request in this step can be set by the designer according to practical scenarios and user needs, such as Figure 5 As shown, the processor can receive a code change merge request submitted by a user through the code management system; in order to further ensure the security of the code, the processor in this embodiment can also generate a code change merge request corresponding to the changed code in the preset monitoring code when it detects that the preset monitoring code has changed; that is, the processor can monitor the preset monitoring code and, when it detects that the preset monitoring code has changed, automatically generate a corresponding code change merge request based on the file path or module where the changed code in the preset monitoring code is located, so as to avoid quality problems caused by code changes in the preset monitoring code.
[0091] Step 202: Search the current test case corresponding to the code change merge request from the preset smoke test case set.
[0092] The preset smoke test case set in this embodiment may be a set of pre-set smoke test cases. The current test case in this embodiment may be a smoke test case corresponding to the code change merge request.
[0093] like Figure 5 As shown, in this embodiment, the processor can search the file path or module corresponding to the code changed in the code change merge request from the preset smoke test case set through the code management system, and send it to the executor for processing in sequence.
[0094] Step 203: parse the acquired current test case to determine the current test step.
[0095] Step 204: Search the keyword library for the target keyword record item corresponding to the keyword identifier of the current test step.
[0096] Step 205: According to the step parameters of the current test step, a target test action function is called and executed by adopting a cross-language function calling method to obtain a step test result of the current test step.
[0097] Step 206: Determine the test case test result of the current test case according to the step test result.
[0098] Among them, steps 203 to 206 are similar to steps 101 to 104 in the above embodiment, and are not described again here.
[0099] Step 207: If the test result of the current test case is a test failure, the code change requested for the code change merge is rejected.
[0100] It is understandable that in this embodiment, the processor can use the code management system to manage the current test case when the test result of the test case is a test failure (such as Figure 5 When the code change is rejected and the requested code change is merged, the basic functions of the software / hardware cannot run normally after the code change.
[0101] Correspondingly, for the case test result of the current test case in this embodiment is a case where the test is passed, the designer can set it by himself, such as Figure 5 As shown, the processor can determine whether there is a next smoke test case corresponding to the code change merge request when the test result of the current test case is a test pass (PASS); if so, it can enter step 202, find the next smoke test case as the current test case through the code management system, and continue to perform the smoke test of the next smoke test case; if not, it can accept the code change of the code change merge request.
[0102] In this embodiment, the embodiment of the present invention can realize automated smoke testing of code changes by searching for the current test case corresponding to the code change merge request from a preset smoke test case set, so that the executor of the test case can be connected with other automated processes or systems as a module, so that it can be started and run after being connected with the upstream module, and the test case results can be fed back to the downstream after being connected with the downstream module so that the downstream can perform subsequent processing.
[0103] Corresponding to the above method embodiment, an embodiment of the present invention further provides an automatic testing device for a universal actuator. The automatic testing device for a universal actuator described below and the automatic testing method for a universal actuator described above can refer to each other.
[0104] Please refer to Figure 6 , Figure 6 This is a structural block diagram of an automatic testing device for a universal actuator provided by an embodiment of the present invention. The device may include:
[0105] The parsing module 10 is used to parse the acquired current test case and determine the current test step; wherein the current test step is any test step in the current test case, the test step includes a keyword identifier and a step parameter, and the step parameter includes an expected return value of the step and an input parameter of a test action function;
[0106] A search module 20 is used to search for a target keyword record item corresponding to the keyword identifier of the current test step from the keyword library; wherein the target keyword record item is any keyword record item in the keyword library, the keyword record item includes a keyword, a test action function entry and a test action description, the keyword includes a test action and a test object, and the test action functions corresponding to the test action function entries in at least two keyword record items in the keyword library adopt different programming languages;
[0107] An execution module 30 is used to call and execute a target test action function in a cross-language function call mode according to the step parameters of the current test step to obtain a step test result of the current test step; wherein the target test action function is a test action function corresponding to a test action function entry in a target keyword record item;
[0108] The determination module 40 is used to determine the test case result of the current test case according to the step test result.
[0109] In some embodiments, the current test case is a smoke test case, and the apparatus may further include:
[0110] The change acquisition module is used to obtain code change merge requests;
[0111] The use case acquisition module is used to find the current test case corresponding to the code change merge request from the preset smoke test case set;
[0112] The rejection acquisition module is used to reject the code change of the code change merge request after determining the case test result of the current test case according to the step test result, if the case test result of the current test case is a test failure.
[0113] In some embodiments, the step parameters also include step scheduling methods, and the step scheduling methods include serial and parallel; the keyword library is a text file or a table file.
[0114] In some embodiments, according to the step parameters of the current test step, a target test action function is called and executed in a cross-language function call manner to obtain a step test result of the current test step, including:
[0115] If the step scheduling mode of the current test step is serial, the target test action function is called and executed according to the test action function input parameters of the current test step to obtain the function return value of the target test action function;
[0116] According to the function return value and the expected return value of the current test step, the step test result of the current test step is obtained;
[0117] If the step scheduling mode of the current test step is parallel, a new test process is enabled to utilize the test process, call and execute the target test action function according to the test action function input parameters of the current test step, and obtain the function return value of the target test action function;
[0118] Determine whether the step scheduling mode of the next test step adjacent to the current test step in the current test case is parallel;
[0119] If yes, the next test step is used as the current test step, and the step of searching the keyword library for the target keyword record item corresponding to the keyword identifier of the current test step is performed;
[0120] If not, then obtain the step test results of the current test step and the adjacent parallel test steps based on the function return values and step expected return values corresponding to each of the current test step and the parallel test steps adjacent to the current test step, and execute the step of determining the case test result of the current test case based on the step test results.
[0121] In some embodiments, determining the test case test result of the current test case according to the step test result includes:
[0122] When the step scheduling mode of the current test step is serial, if the step test result of the current test step is a test failure, the case test result of the current test case is determined to be a test failure; if the step test result of the current test step is a test pass, when the current test step is the last test step of the current test case, the case test result of the current test case is determined to be a test pass; when the current test step is not the last test step of the current test case, the obtained current test case is parsed to determine the step of the current test step;
[0123] When the step scheduling mode of the current test step is parallel, if there is a test failure in the step test results of the current test step and the adjacent parallel test step, the case test result of the current test case is determined to be a test failure; if the step test results of the current test step and the adjacent parallel test step are both test successes, then when the last test step of the current test step and the adjacent parallel test step is the last test step of the current test case, the case test result of the current test case is determined to be a test pass; when the last test step of the current test step and the adjacent parallel test step is not the last test step of the current test case, the acquired current test case is parsed to determine the steps of the current test step.
[0124] In some embodiments, the method further comprises:
[0125] Obtain a record item addition request; wherein the record item addition request includes a newly added keyword and an identifier of a historical test action function entry;
[0126] According to the record item addition request, the corresponding keyword record item is added to the keyword library.
[0127] In some embodiments, the apparatus may further include:
[0128] A search acquisition module is used to obtain a keyword search request; wherein the keyword search request includes a target object under test and a target test action;
[0129] The object search module is used to search for a target keyword corresponding to the target object from a keyword library according to the target object to be tested; wherein the target keyword includes the target object to be tested;
[0130] An action search module, used to search for optional keywords corresponding to a target test action from a target keyword; wherein the optional keywords include the target test action;
[0131] The display module is used to display the test action description in the keyword record item where the output optional keyword is located.
[0132] In this embodiment, the embodiment of the present invention decouples the executor from the test action function, so that the executor can use a cross-language function call method to call and execute the test action function corresponding to each test step from the function entry, so that the test action function and the executor can be independently implemented in different programming languages, and different programming languages are allowed to be used to implement the test action function, so that the test action function can be encoded by test developers from different teams using the programming language that they are good at or meets their own needs, which reduces the difficulty of writing test cases and improves the versatility of the framework, thereby reducing the situation of repeated code development and avoiding waste of human resources through the configuration of keywords in the keyword record items in the keyword library, the test action function entry and the test action description.
[0133] Corresponding to the above method embodiment, the embodiment of the present invention further provides an automatic testing device for a universal actuator. The automatic testing device for a universal actuator described below and the automatic testing method for a universal actuator described above can refer to each other.
[0134] Please refer to Figure 7 , Figure 7 A schematic diagram of the structure of an automatic test device for a universal actuator provided by an embodiment of the present invention. The automatic test device may include:
[0135] A memory D1, for storing computer programs;
[0136] The processor D2 is used to implement the steps of the automatic testing method for the universal actuator provided by the above method embodiment when executing the computer program.
[0137] The automated testing device provided in this embodiment may specifically be a server or a computer device, such as a server of a code management system.
[0138] The steps in the above-described method for automatically testing a universal actuator may be implemented by the structure of an automatically testing device for a universal actuator.
[0139] Corresponding to the above method embodiment, an embodiment of the present invention further provides a computer program product. The computer program product described below and the automatic testing method for an actuator described above can be referred to each other.
[0140] A computer program product includes a computer program / instruction, which, when executed by a processor, implements the steps of the automatic testing method for an actuator provided in the above method embodiment.
[0141] Corresponding to the above method embodiment, an embodiment of the present invention further provides a computer-readable storage medium. The computer-readable storage medium described below and the automatic testing method of an actuator described above can refer to each other.
[0142] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the automated testing method for an actuator of the above method embodiment.
[0143] The computer-readable storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which can store program codes.
[0144] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the devices, equipment, computer program products and computer-readable storage media disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0145] The above is a detailed introduction to the automated testing method, device, equipment and computer-readable storage medium for a universal actuator provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. An automated testing method for a universal actuator, characterized in that: include: Parse the acquired current test case to determine the current test step; wherein the current test step is any test step in the current test case, the test step includes a keyword identifier and a step parameter, and the step parameter includes an expected return value of the step and an input parameter of a test action function; Searching for a target keyword record item corresponding to the keyword identifier of the current test step from the keyword library; wherein the target keyword record item is any keyword record item in the keyword library, the keyword record item includes a keyword, a test action function entry and a test action description, the keyword includes a test action and a test object, and the test action functions corresponding to the test action function entries in at least two keyword record items in the keyword library adopt different programming languages; According to the step parameters of the current test step, a target test action function is called and executed by adopting a cross-language function call method to obtain a step test result of the current test step; wherein the target test action function is a test action function corresponding to a test action function entry in the target keyword record item; According to the step test results, the test result of the current test case is determined.
2. The automated testing method for a universal actuator according to claim 1, characterized in that: The current test case is a smoke test case. Before parsing the acquired test case and determining the current test step, the following steps are also included: Get code change pull requests; Searching for a current test case corresponding to the code change merge request from a preset smoke test case set; Correspondingly, after determining the test result of the current test case according to the test result of the step, the method further includes: If the test result of the current test case is a test failure, the code change of the code change merge request is rejected.
3. The automated testing method for a universal actuator according to claim 1, characterized in that: The step parameters also include step scheduling modes, which include serial and parallel. The keyword library is a text file or a table file.
4. The automated testing method for a universal actuator according to claim 3, characterized in that: The step of calling and executing the target test action function in a cross-language function calling manner according to the step parameters of the current test step to obtain the step test result of the current test step includes: If the step scheduling mode of the current test step is serial, calling and executing the target test action function according to the test action function input parameters of the current test step, and obtaining the function return value of the target test action function; Obtaining a step test result of the current test step according to the function return value and the expected step return value of the current test step; If the step scheduling mode of the current test step is parallel, a new test process is enabled to utilize the test process, call and execute the target test action function according to the test action function input parameters of the current test step, and obtain the function return value of the target test action function; Determine whether the step scheduling mode of the next test step adjacent to the current test step in the current test case is parallel; If yes, the next test step is used as the current test step, and the step of searching the keyword library for the target keyword record item corresponding to the keyword identifier of the current test step is performed; If not, then obtain the step test results of the current test step and the adjacent parallel test steps based on the function return values and step expected return values corresponding to each of the current test step and the parallel test steps adjacent to the current test step, and execute the step of determining the case test result of the current test case based on the step test results.
5. The automated testing method for a universal actuator according to claim 4, characterized in that: Determining the test result of the current test case according to the test result of the step includes: In the case where the step scheduling mode of the current test step is serial, if the step test result of the current test step is a test failure, the case test result of the current test case is determined to be a test failure; if the step test result of the current test step is a test pass, then when the current test step is the last test step of the current test case, the case test result of the current test case is determined to be a test pass; when the current test step is not the last test step of the current test case, the parsing of the acquired current test case is performed to determine the step of the current test step; When the step scheduling mode of the current test step is parallel, if there is a test failure in the step test results of the current test step and the adjacent parallel test steps, the case test result of the current test case is determined to be a test failure; if the step test results of the current test step and the adjacent parallel test steps are both test successes, then when the last test step of the current test step and the adjacent parallel test steps is the last test step of the current test case, the case test result of the current test case is determined to be a test pass; when the last test step of the current test step and the adjacent parallel test steps is not the last test step of the current test case, the parsing of the acquired current test case is executed to determine the steps of the current test step.
6. The automated testing method for a universal actuator according to claim 1, characterized in that: Also includes: Obtaining a record item addition request; wherein the record item addition request includes a newly added keyword and an identifier of a historical test action function entry; According to the record item addition request, a corresponding keyword record item is added to the keyword library.
7. The automated testing method for a universal actuator according to any one of claims 1 to 6, characterized in that: Also includes: Obtain a keyword search request; wherein the keyword search request includes a target object under test and a target test action; According to the target object to be measured, searching the target keyword corresponding to the target object to be measured from the keyword library; wherein the target keyword includes the target object to be measured; Searching for an optional keyword corresponding to the target test action from the target keyword; wherein the optional keyword includes the target test action; The test action description in the keyword record item where the optional keyword is located is displayed and outputted.
8. An automatic testing device for a universal actuator, characterized in that: include: A parsing module, used to parse the acquired current test case to determine the current test step; wherein the current test step is any test step in the current test case, the test step includes a keyword identifier and a step parameter, and the step parameter includes an expected return value of the step and an input parameter of a test action function; A search module, used for searching a target keyword record item corresponding to a keyword identifier of a current test step from a keyword library; wherein the target keyword record item is any keyword record item in the keyword library, the keyword record item includes a keyword, a test action function entry and a test action description, the keyword includes a test action and a test object, and the test action functions corresponding to the test action function entries in at least two keyword record items in the keyword library adopt different programming languages; An execution module, used to call and execute a target test action function in a cross-language function call mode according to the step parameters of the current test step, to obtain a step test result of the current test step; wherein the target test action function is a test action function corresponding to a test action function entry in the target keyword record item; The determination module is used to determine the test result of the current test case according to the step test result.
9. An automatic testing device for a universal actuator, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the method for automated testing of a universal actuator as claimed in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the automated testing method for a universal actuator according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Keyword-driven aerospace measurement and control software automatic test method and system
CN119621557A
A keyword-driven spaceflight TT&C software automatic testing method and system
CN119621557B
SOC access verification system and method, electronic equipment and storage medium
CN122332203A
An SOC path verification system, method, electronic device and storage medium
CN122332203B
