A software testing method and device, electronic equipment and storage medium
By customizing component information entries and data templates, the problem of poor scalability of automated testing tools is solved, achieving more efficient adaptability and flexibility in testing tools.
Patent Information
- Application Number
- CN202210061315.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-19
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2042-01-19
AI Technical Summary
Existing automated testing tools have poor scalability and are unable to meet the ever-changing testing needs.
The system can customize and construct input data templates and software test programs by using preset component information entries. It can also assemble data to be processed using preset data templates and configuration information in preset component information entries, and process the data to be processed using preset software test programs.
This greatly enhances the scalability and flexibility of automated testing tools, thereby increasing their application value.
Smart Images

Figure CN114238151B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software testing, and in particular to a software testing method, apparatus, electronic device, and storage medium. Background Technology
[0002] To improve testing efficiency, testers typically use automated testing tools to assist in software testing tasks. However, these tools are usually developed based on specific testing engines, resulting in poor scalability and making it difficult for them to meet ever-changing testing needs. Summary of the Invention
[0003] The purpose of this invention is to provide a software testing method, apparatus, electronic device, and storage medium that can customize data templates for constructing input data and software testing programs for performing software testing using preset component information entries, thereby effectively enhancing the scalability of automated testing tools.
[0004] To address the aforementioned technical problems, this invention provides a software testing method, comprising:
[0005] Upon receiving the test case configuration information, the first execution node information entry in the test case configuration information is set as a pending entry;
[0006] Find the corresponding preset component information entry based on the component type in the entry to be processed, and assemble the data to be processed using the preset data template in the preset component information entry and the configuration information in the entry to be processed;
[0007] The data to be processed is processed using the preset software test program corresponding to the preset component information entry;
[0008] When it is determined that the entry to be processed has a corresponding next execution node information entry, the entry to be processed is updated to the next execution node information entry, and the step of searching for the corresponding preset component information entry based on the component type in the entry to be processed is entered.
[0009] If it is determined that the entry to be processed does not have the next execution node information entry, the process exits.
[0010] Optionally, assembling the data to be processed using the preset data template in the preset component information entry and the configuration information in the entry to be processed includes:
[0011] Extract the custom data template and input parameter data from the configuration information;
[0012] The input parameter data is filled into the preset data template and the custom data template, and the completed preset data template and custom data template are spliced together to obtain the data to be processed.
[0013] Optionally, extracting input parameter data from the configuration information includes:
[0014] Extract the input parameter data ID from the configuration information, and extract the corresponding test data from the parameter pool in the test case configuration information according to the input parameter data ID;
[0015] Accordingly, processing the data to be processed using the preset software test program corresponding to the preset component information entry includes:
[0016] The data to be processed is processed using the preset software test program corresponding to the preset component information entry to obtain output data and the corresponding output data ID;
[0017] The corresponding test data is updated in the parameter pool using the output data and the output data ID.
[0018] Optionally, when the component type is a general component type, the data to be processed is request information, and the step of processing the data to be processed using the preset software test program corresponding to the preset component information entry to obtain output data and the corresponding output data ID includes:
[0019] The request information is sent to the preset software testing program, so that the preset software testing program sends the request information to the target device and extracts the output data and determines the output data ID from the response information of the target device;
[0020] Receive the output data and the output data ID sent by the preset software test program.
[0021] Optionally, when the component type is a branch control type, the data to be processed is a logical expression, and the step of processing the data to be processed using the preset software test program corresponding to the preset component information entry includes:
[0022] The logical value of the logical expression is determined using the preset software testing program, and the next execution node information entry corresponding to the logical value is extracted from the entry to be processed.
[0023] Optionally, when the component type is a loop control type, the input parameter data is the number of loops. The step of filling the input parameter data into the preset data template and the custom data template, and then concatenating the completed preset data template and custom data template to obtain the data to be processed includes:
[0024] The number of iterations is filled into the preset data template and the custom data template, and the completed preset data template and custom data template are concatenated to obtain a loop control logic expression used to determine whether the number of iterations is greater than a preset value;
[0025] Accordingly, processing the data to be processed using the preset software test program corresponding to the preset component information entry includes:
[0026] The loop logic value of the loop control logic expression is determined using the preset software test program corresponding to the branch control type, the loop count is updated, and the next execution node information entry corresponding to the loop logic value is extracted from the pending entry.
[0027] Optionally, when the component type is a loop control type, the input parameter data includes the actual result, expected result, and assertion method of the test case. The step of filling the input parameter data into the preset data template and the custom data template, and then concatenating the completed preset data template and custom data template to obtain the data to be processed includes:
[0028] The actual results, the expected results, and the assertion method are filled into the preset data template and the custom data template, and the completed preset data template and custom data template are spliced together to obtain the assertion logic expression used to determine whether the test case is successfully tested.
[0029] Accordingly, processing the data to be processed using the preset software test program corresponding to the preset component information entry includes:
[0030] The pre-defined software test program corresponding to the branch control type is used to determine the assertion logic value of the assertion logic expression, and the test case is determined to be successful based on the assertion logic value.
[0031] The present invention also provides a software testing apparatus, comprising:
[0032] The setting module is used to set the first execution node information entry in the test case configuration information as a pending entry when the test case configuration information is received.
[0033] The assembly module is used to find the corresponding preset component information entries according to the component types in the entries to be processed, and to assemble the data to be processed using the preset data templates in the preset component information entries and the configuration information in the entries to be processed;
[0034] The testing module is used to process the data to be processed using a preset software testing program corresponding to the preset component information entries;
[0035] The update module is used to update the pending entry to the next execution node information entry when it is determined that the pending entry has a corresponding next execution node information entry, and then proceed to the step of finding the corresponding preset component information entry according to the component type in the pending entry;
[0036] The exit module is used to exit the process when it is determined that the entry to be processed does not have the next execution node information entry.
[0037] The present invention also provides an electronic device, comprising:
[0038] Memory, used to store computer programs;
[0039] A processor for implementing the software testing method as described above when executing the computer program.
[0040] The present invention also provides a storage medium storing computer-executable instructions, which, when loaded and executed by a processor, implement the software testing method described above.
[0041] This invention provides a software testing method, comprising: upon receiving test case configuration information, setting the first execution node information entry in the test case configuration information as a pending entry; searching for a corresponding preset component information entry based on the component type in the pending entry, and assembling pending data using a preset data template in the preset component information entry and the configuration information in the pending entry; processing the pending data using a preset software testing program corresponding to the preset component information entry; when it is determined that the pending entry has a corresponding next execution node information entry, updating the pending entry to the next execution node information entry, and proceeding to the step of searching for the corresponding preset component information entry based on the component type in the pending entry; when it is determined that the pending entry does not have the next execution node information entry, exiting the process.
[0042] As can be seen, when the present invention receives the test case configuration information corresponding to the test case, it automatically extracts the execution node information from it, queries the corresponding preset component information entries according to the component type in the execution node information, assembles the data to be processed using the preset data template corresponding to the preset component information entries, and processes the data to be processed using the preset software test program corresponding to the preset component information entries to carry out software testing tasks. In short, since the data to be processed can be assembled using the preset data template corresponding to the component type, the present invention does not limit the format of the input data. When the input data required for testing changes, only the preset data template in the corresponding component type needs to be changed. Similarly, since software testing is performed by the preset software test program corresponding to the component type, when the test steps change, only the preset software test program in the corresponding component type needs to be changed, greatly improving the scalability of the automated testing tool and thus effectively enhancing the utilization value of the tool. The present invention also provides a software testing device, electronic device, and storage medium, which have the above-mentioned beneficial effects. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0044] Figure 1 A flowchart of a software testing method provided in an embodiment of the present invention;
[0045] Figure 2 This is a schematic diagram of a process structure provided in an embodiment of the present invention;
[0046] Figure 3 A schematic diagram of a component provided in an embodiment of the present invention;
[0047] Figure 4 A flowchart illustrating the execution process of an HTTP component, provided as an embodiment of the present invention;
[0048] Figure 5 A flowchart illustrating the execution process of a branch control component provided in an embodiment of the present invention;
[0049] Figure 6 A flowchart illustrating the execution process of a loop control component provided in an embodiment of the present invention;
[0050] Figure 7 A flowchart of the execution process of an assertion component is provided in an embodiment of the present invention;
[0051] Figure 8 This is an overall flowchart of the test case execution process provided in the embodiments of the present invention;
[0052] Figure 9 This is a structural block diagram of a software testing device provided in an embodiment of the present invention. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0054] In related technologies, automated testing tools are typically developed based on specific testing engines, which results in poor scalability and makes it difficult for these tools to meet ever-changing testing needs. In view of this, the present invention provides a software testing method that allows users to customize data templates for constructing input data and software testing programs for performing software tests using preset component information entries, thereby effectively enhancing the scalability of automated testing tools. Please refer to... Figure 1 , Figure 1 A flowchart of a software testing method provided in an embodiment of the present invention, the method may include:
[0055] S101. Upon receiving the test case configuration information, set the first execution node information entry in the test case configuration information as a pending entry.
[0056] Understandably, software testing typically follows a testing process. In related technologies, testers usually use a software testing engine to execute this process. However, when the testing process changes, testers can only modify the software testing engine itself to adapt to the new process, which is not flexible. In this application, the software testing process is first divided into multiple execution actions, and these actions are handled using corresponding execution nodes. For example, in... Figure 2In the provided example, the software testing process can be broken down into five execution actions. Each action can be executed by a corresponding execution node: SQL component logic, HTTP interface component logic, branch control, assertion component logic, and RPC interface component logic. The SQL component logic tests the database, the HTTP interface component logic tests the HTTP interface, branch control controls the test flow based on the logical result of the field value (seg1.value) encountered during the test, directing the flow towards either the assertion component logic or the RPC interface component logic. The assertion component logic determines whether the test case was successfully executed, and the RPC interface component logic tests the RPC (Remote Procedure Call) interface. Execution nodes can be customized from different preset components in the testing tool. Each component has a corresponding preset data template and a preset software test program. The preset data template assembles the data to be processed into the software test program, while the preset software test program handles the execution logic during the software testing process. Clearly, in this embodiment, the component is the smallest execution unit in the software testing process; its schematic diagram can be found in the provided text. Figure 3 , Figure 3 This is a schematic diagram of a component provided in an embodiment of the present invention. Its main structure is execution logic (i.e., a software testing program). By simply inputting data into the component according to its requirements, the processed input data can be obtained. Because the present invention uses a multi-component approach to handle the software testing process, the components can be arbitrarily arranged to adapt to different software testing processes. Furthermore, the preset data templates and preset software testing programs for each component can be updated and modified according to actual application needs. Therefore, the present invention can greatly improve the flexibility and scalability of automated testing tools, thereby effectively enhancing the application value of automated testing tools in the testing field.
[0057] Furthermore, it is understood that in order to customize the components in the testing tool to obtain execution nodes and control the execution nodes to process execution actions according to a preset order, overall configuration information should be provided to the testing tool. This configuration information includes execution node information entries corresponding to each execution node, as well as the working order of each execution node. In this embodiment of the invention, the test case configuration information is precisely the aforementioned overall configuration information. When performing software testing for the first time, the first execution node information entry in the test case configuration information should be set as a pending entry to start the software testing process. It should be noted that this embodiment of the invention does not limit the storage format, maximum number, or sorting method of execution node information entries in the test case configuration information, and can be set according to actual application requirements. To assemble execution nodes in sequence, each execution node information entry may further include a node ID used to uniquely identify the execution node, thereby allowing for quick retrieval of the execution node information entries required for node assembly based on this ID. Of course, the test case configuration information may also include other information, such as parameter information required for software testing, test case name, and test case ID that uniquely identifies the test case, which can be set according to actual application requirements. In one possible case, the structure of the test case configuration information can be:
[0058] {
[0059] "Process ID":"Process ID",
[0060] "Node execution set":["Node1ID","Node2ID",...],
[0061] "Parameter set":"Parameter set"
[0062] }
[0063] Furthermore, components come in various types. To quickly match the component corresponding to the execution node, the execution node information should include the component type. In one possible scenario, the structure of the execution node information entry can be simply represented as follows:
[0064] {
[0065] "Node ID":"Node ID",
[0066] "Component Type":"
[0067] }
[0068] This invention does not limit the specific component types. For example, it may include database operation components, file operation components, keyword components, interface components, flow control components, and assertion components. The database operation component is used to perform CRUD operations on the database; the file operation component is used to operate on files; the keyword component is used to call different programming languages; the interface library component is used to call different protocol interfaces, such as HTTP, TCP (Transmission Control Protocol), UDP (User Datagram Protocol), RPC, and socket interfaces; the flow control component is used to control automated processes; and the assertion component is used to compare test case execution results based on complex rules. Of course, it may also include a test case reuse component for reusing existing execution nodes or test cases. The reuse of existing execution nodes and test cases can be achieved through node IDs and test case IDs. Furthermore, to improve component management efficiency, this invention can divide components into two main types: general components and branch control components. The specific structure and functions of these two components will be described in detail later.
[0069] S102. Find the corresponding preset component information entry based on the component type in the entry to be processed, and assemble the data to be processed using the preset data template in the preset component information entry and the configuration information in the entry to be processed.
[0070] In this embodiment of the invention, the execution node information entry also includes configuration information, which is used to provide necessary information in the data to be processed. Since the preset component information entry already contains a preset data template for standardizing the format of the data to be processed, only the configuration information needs to be filled into the preset data template. This embodiment of the invention does not limit the specific content of the configuration information; it can primarily include input parameter data. This invention also does not limit the specific input parameter data. For example, when detecting an HTTP interface, the input parameter data can be parameters such as request headers and request bodies; when detecting a database, the input parameter data can be information such as database name and table name. The data type of the input parameter data can be integer (int), string (String), JSON (JavaScript Object Notation), etc., and can be set according to actual application requirements. Furthermore, to improve the scalability of the preset data template, the configuration information can also further include user-defined data templates, which can be concatenated into the preset data template to add custom content to the preset data template. Understandably, when the configuration information includes a custom data template, the input parameter data needs to be written into both the preset data template and the custom data template. Then, the two completed templates are joined together to obtain the data to be processed.
[0071] In one possible scenario, assembling the data to be processed using the preset data template in the preset component information entry and the configuration information in the entry to be processed can include:
[0072] Step 11: Extract the custom data template and input parameter data from the configuration information;
[0073] Step 12: Fill in the input data into the preset data template and the custom data template, and then combine the completed preset data template and the custom data template to obtain the data to be processed.
[0074] It should be noted that the embodiments of the present invention do not limit the position of the input data in each template, nor do they limit the splicing method of the two templates, and can be set according to the actual application requirements.
[0075] Furthermore, test data reuse is frequently observed in the field of software testing, for example, the output data of one test item is used as the input data for the next test item. To achieve test data reuse in the multi-component testing tool provided in this embodiment, a parameter pool can be added to the test case configuration information to record the values of each test data item. When assembling the data to be processed in the execution node, the required input parameter data can be extracted from the parameter pool. After the execution node completes processing and obtains the output data, the corresponding test data in the parameter pool can be updated using the output data. This embodiment does not limit how input parameter data is extracted from the parameter pool or how the corresponding test data is updated using the output data. For example, the above operations can be performed based on the data name, or an ID can be set for each test data item, and the above operations can be performed based on the data ID. To improve comparison efficiency, in this embodiment, an ID can be set for each test data item, so that matching can be performed based on the ID when extracting input parameter data and finding the test data corresponding to the output data.
[0076] In one possible scenario, extracting input parameter data from configuration information may include:
[0077] Step 21: Extract the input parameter data ID from the configuration information, and extract the corresponding test data from the parameter pool in the test case configuration information according to the input parameter data ID;
[0078] Accordingly, processing the data to be processed using the preset software test program corresponding to the preset component information entry may include:
[0079] Step 31: Use the preset software test program corresponding to the preset component information entry to process the data to be processed, and obtain the output data and the corresponding output data ID;
[0080] Step 32: Update the corresponding test data in the parameter pool using the output data and output data ID.
[0081] It should be noted that the embodiments of the present invention do not limit the attributes of the test data. In addition to the basic name, parameter value, and parameter type, it may also include an English name and identification information indicating whether it is associated with other parameters, which can be set according to actual application needs. In one possible case, the test data is stored in the following format:
[0082] {
[0083] "Parameter 1ID": {
[0084] "Parameter Name":"Parameter Name",
[0085] "EnName":"English Name",
[0086] "Parameter value":"Parameter value",
[0087] "Associate parameters": "Yes / No"
[0088] "Parameter type":"Parameter type", ...
[0090] },
[0091] "Parameter 2ID": {
[0092] "Parameter Name":"Parameter Name",
[0093] "EnName":"English Name",
[0094] "Parameter value":"Parameter value",
[0095] "Associate parameters": "Yes / No"
[0096] "Parameter type":"Parameter type", ...
[0098] } ...
[0100] }
[0101] S103. Process the data to be processed using the preset software test program corresponding to the preset component information entries.
[0102] It is understandable that different types of components have different preset software test programs with different functions. The preset software test programs for general components and branch control components are introduced below.
[0103] In this embodiment of the invention, the general component is mainly used for detecting target devices. It is applicable to assembling interface components, database operation components, keyword components, file operation components, test case reuse components, and other components used for detecting target devices. The target device may include interfaces, databases, function libraries in different programming languages, files, etc., and may also be a combination of multiple objects. Since the preset software test program (Exec program) is mainly used to execute software test actions, the preset software test program in the general component is mainly used to detect the aforementioned target devices. For example, this program can be a program that detects interfaces, a program that detects databases, a program that calls function libraries, or a program that detects target files. Since it is usually necessary to send request information to the target device in order to determine whether it is working properly through the response information of the object, the data to be processed by the preset software test program in the general component should be request information. The function of this program is simply to send request information to the target device, receive the response information of the target device, and then determine whether the target device is working properly and obtain output data by parsing the response information. Of course, the actual functions of the preset software test program in the general components are more complex. The embodiments of the present invention are only briefly described, and the specific functions can be referred to the relevant technologies.
[0104] In one possible scenario, when the component type is a generic component type, the data to be processed is request information. The data is processed using a preset software test program corresponding to the preset component information entry, yielding output data and its corresponding output data ID, which may include:
[0105] Step 41: Send the request information to the preset software test program, so that the preset software test program sends the request information to the target device and extracts the output data and determines the output data ID from the response information of the target device;
[0106] Step 42: Receive the output data and output data ID sent by the preset software test program.
[0107] The following example illustrates the execution process of a general component. Please refer to [link / reference]. Figure 4 , Figure 4 The flowchart provided in this embodiment of the invention illustrates the execution process of an HTTP component. In this process, an HTTP request template and input parameter data, such as business parameters and tokens, are first obtained. Then, the template and input parameter data are used to assemble the data to be processed (Body data) to obtain an HTTP request message. Finally, the message is sent to the request execution program for processing, and the corresponding HTTP response message is received.
[0108] In one possible scenario, the structure of a general-purpose component can be represented as follows:
[0109] {
[0110] "Body":"", / / Preset data template used to assemble messages, request type, request address, database name, table name, result type, etc.
[0111] "Exec program":"", / / Execution logic
[0112] "Node Input Parameters":["Input Parameter 1 ID","Input Parameter 2 ID",...],
[0113] "Node Output Parameters":["Output Parameter 1 ID","Output Parameter 2 ID",...]
[0114] }
[0115] Furthermore, in this embodiment of the invention, the main function of the branch control component is to control the test case logic based on the real-time execution results of the test cases, similar to the flow control keywords such as goto, if-else, and for in programming languages. In other words, the preset software test program of the branch control component mainly processes logical expressions as the data to be processed, and its specific function is mainly to calculate the logical values corresponding to the logical expressions, namely True and False values. It can be understood that the logical value can be set with corresponding next execution node information entries, thus enabling flow control based on the logical value. Of course, to implement the else if function, the logical value can also be set with corresponding next logical expression; to control the exit of the test process, the logical value can also be set with corresponding termination flags.
[0116] In one possible scenario, when the component type is a branch control type, the data to be processed is a logical expression. The data is processed using a preset software test program corresponding to the preset component information entry, including:
[0117] Step 51: Use a preset software test program to determine the logical value of the logical expression, and extract the next execution node information entry corresponding to the logical value from the entry to be processed.
[0118] In one possible scenario, the structure of the branch control component can be represented as follows:
[0119] {
[0120] "Control Condition 1":{
[0121] "Control Conditions": "Supports logical expressions",
[0122] "Next Node ID": "Node ID" / / This keyword takes effect when the control component is a flow branch, and flow execution may jump.
[0123] "Process Termination": "Process Termination Identifier" / / This keyword takes effect when the control component is marked as terminated. At this time, the process will not execute subsequent processes, and the process terminates.
[0124] }, ......
[0126] }
[0127] Please refer to Figure 5 , Figure 5 The flowchart provided in this embodiment of the invention describes the execution process of a branch control component. Similar to general components, before performing logical judgment, input parameter data is first obtained. This data consists of the values of logical fields to be judged, which can come from the input parameter data, output data, or variable values of previous nodes. Logical expressions are then assembled using this data. Next, the logical expression is input into the preset software test program corresponding to the branch control component for judgment processing to obtain the corresponding logical value. Finally, the execution jumps to the next execution node or the next logical expression (else-if) based on whether the logical value is true.
[0128] It should be noted that logical expressions can also be constructed using a combination of preset data templates and custom templates. This invention does not limit the specific assembly method of logical expressions and can be set according to actual application requirements. Since the branch control component can be used for logical judgment, it can also be used to implement loop functions. Specifically, when assembling a logical expression, the input parameter data should be the loop count. The logical expression composed of the loop count (hereinafter referred to as the loop logical expression) is used to determine whether the loop count is greater than a preset value. Its logical value corresponds to the execution node information entries within the loop and the execution node information entries outside the loop, respectively. When the preset software test program corresponding to the branch control component determines the logical value of the loop logical expression, it can jump to the execution node within the loop or jump out of the loop based on the value. It is understood that the loop count should be updated before jumping.
[0129] In one possible scenario, when the component type is a loop control type, the input parameter data is the loop count. The input parameter data is filled into a preset data template and a custom data template, and then the completed preset data template and custom data template are concatenated to obtain the data to be processed, including:
[0130] Step 61: Fill in the number of loops into the preset data template and the custom data template, and then concatenate the completed preset data template and the custom data template to obtain the loop control logic expression used to determine whether the number of loops is greater than the preset value;
[0131] Accordingly, the data to be processed is processed using the preset software test program corresponding to the preset component information entries, including:
[0132] Step 71: Use the preset software test program corresponding to the branch control type to determine the loop logic value of the loop control logic expression, update the loop count, and extract the next execution node information entry corresponding to the loop logic value from the pending entry.
[0133] Please refer to Figure 6 , Figure 6 The flowchart shows the execution process of a loop control component provided in an embodiment of the present invention. It can be seen that the difference between this component and the branch control component is that the node input parameter is the number of loops.
[0134] Of course, the branch control component can also be used to implement assertion functionality, that is, to determine whether a test case was successfully executed. Specifically, when assembling the logical expression, the input parameters should be the actual result, expected result, and assertion method of executing the test case. The logical expression composed of the actual result, expected result, and assertion method (hereinafter referred to as the assertion logical expression) is used to determine whether the test case was successfully executed, and its logical value corresponds to test success and test failure, respectively. After the preset software test program corresponding to the branch control component determines the logical value of the loop logical expression, it can determine the execution status of the test case based on this value.
[0135] In one possible scenario, when the component type is a loop control type, the input parameters are the actual results, expected results, and assertion methods of the test case. The input parameters are filled into a preset data template and a custom data template, and then the completed preset and custom data templates are concatenated to obtain the data to be processed, which may include:
[0136] Step 81: Fill in the actual results, expected results and assertion methods into the preset data template and the custom data template, and then concatenate the completed preset data template and custom data template to obtain the assertion logic expression used to determine whether the test case was successfully tested;
[0137] Accordingly, the data to be processed is processed using the preset software test program corresponding to the preset component information entries, including:
[0138] Step 91: Use the preset software test program corresponding to the branch control type to determine the assertion logic value of the assertion logic expression, and determine whether the test case was successfully tested based on the assertion logic value.
[0139] Please refer to Figure 7 , Figure 7The flowchart illustrates the execution process of an assertion component provided in this embodiment of the invention. It is evident that this component differs from a branch control component in that the node input parameters are the actual result, the assertion method, and the expected result. It should be noted that this embodiment of the invention does not limit the specific assertion method; it can be greater than, equal to, less than, or inclusive, etc., and can be set according to actual application requirements. In one possible scenario, the structure of the assertion component can be represented as follows:
[0140] {
[0141] "Assertion1ID":{
[0142] "Actual Result Parameter ID":"Actual Result Parameter ID",
[0143] "Assertion style": "greater than / equal to / less than / inclusive of, etc."
[0144] "Expected Result Parameter ID":"Expected Result Parameter ID"
[0145] },
[0146] "Assert 2ID"{
[0147] "Actual Result Parameter ID":"Actual Result Parameter ID",
[0148] "Assertion style": "greater than / equal to / less than / inclusive of, etc."
[0149] "Expected Result Parameter ID":"Expected Result Parameter ID"
[0150] }, ...
[0152] }
[0153] S104. Determine whether the entry to be processed has a corresponding next execution node information entry. If yes, proceed to step S105; otherwise, proceed to step S106.
[0154] S105. When it is determined that the item to be processed has a corresponding next execution node information item, the item to be processed is updated to the next execution node information item, and the process proceeds to the step of finding the corresponding preset component information item according to the component type in the item to be processed.
[0155] In this embodiment of the invention, the next execution node information entry corresponding to the entry to be processed can be determined according to the execution order specified in the test case configuration information. Of course, if the component type of the current execution node is a branch control type, the entry to be processed may contain the next execution node specified by its current execution node, which can be selected according to the actual situation. Since a node ID can be set in the execution node information entry, the next execution node information entry corresponding to the entry to be processed can be found according to the node ID. Furthermore, since test cases can also be set with test case IDs, the next execution node corresponding to the entry to be processed can also be a test case, that is, the entry to be processed can correspond to a test case ID. In other words, the present invention can reuse a single execution node or a sequence of execution nodes that has been orchestrated, which can further improve the flexibility of automated testing tools.
[0156] S106. If it is determined that the entry to be processed does not have an entry with information about the next execution node, exit the process.
[0157] Finally, for ease of understanding, embodiments of the present invention also provide, as follows: Figure 8 The diagram shows the overall flowchart of the test case execution process.
[0158] Based on the above embodiments, when the present invention receives the test case configuration information corresponding to the test case, it automatically extracts the execution node information from it, queries the corresponding preset component information entries according to the component type in the execution node information, assembles the data to be processed using the preset data template corresponding to the preset component information entries, and processes the data to be processed using the preset software test program corresponding to the preset component information entries to carry out software testing tasks. In short, since the data to be processed can be assembled using the preset data template corresponding to the component type, the present invention does not limit the format of the input data. When the input data required for testing changes, only the preset data template in the corresponding component type needs to be changed. Similarly, since software testing is performed by the preset software test program corresponding to the component type, when the test steps change, only the preset software test program in the corresponding component type needs to be changed, greatly improving the scalability of the automated testing tool and thus effectively enhancing the utilization value of the tool.
[0159] The software testing apparatus, electronic device, and storage medium provided in the embodiments of the present invention are described below. The software testing apparatus, electronic device, and storage medium described below can be referred to in correspondence with the software testing method described above.
[0160] Please refer to Figure 9 , Figure 9 This is a structural block diagram of a software testing apparatus provided in an embodiment of the present invention. The apparatus includes:
[0161] The setting module 901 is used to set the first execution node information entry in the test case configuration information as a pending entry when the test case configuration information is received.
[0162] Assembly module 902 is used to find the corresponding preset component information entry according to the component type in the entry to be processed, and to assemble the data to be processed using the preset data template in the preset component information entry and the configuration information in the entry to be processed;
[0163] Test module 903 is used to process the data to be processed using the preset software test program corresponding to the preset component information entries;
[0164] The update module 904 is used to update the item to be processed to the next execution node information item when it is determined that the item to be processed has a corresponding next execution node information item, and then proceed to the step of finding the corresponding preset component information item according to the component type in the item to be processed.
[0165] Exit module 905 is used to exit the process when it is determined that the entry to be processed does not have an entry with information for the next execution node.
[0166] Optionally, the assembly module 902 may include:
[0167] The extraction submodule is used to extract custom data templates and input parameter data from the configuration information;
[0168] The assembly submodule is used to fill the input parameter data into the preset data template and the custom data template, and to splice the completed preset data template and the custom data template to obtain the data to be processed.
[0169] Optionally, extracting submodules may include:
[0170] The extraction unit is used to extract the input parameter data ID from the configuration information and extract the corresponding test data from the parameter pool in the test case configuration information according to the input parameter data ID.
[0171] Accordingly, test module 903 may include:
[0172] The test submodule is used to process the data to be processed using the preset software test program corresponding to the preset component information entries, and obtain the output data and the corresponding output data ID.
[0173] The data update submodule is used to update the corresponding test data in the parameter pool using the output data and the output data ID.
[0174] Optionally, when the component type is a general component type, the data to be processed is request information, and the test submodule may include:
[0175] The test unit is used to send request information to a preset software test program, so that the preset software test program sends the request information to the target device, and extracts output data and determines the output data ID from the response information of the target device.
[0176] The receiving unit is used to receive the output data and output data ID sent by the preset software test program.
[0177] Optionally, when the component type is a branch control type, the data to be processed is a logical expression, and test module 903 may include:
[0178] The logic judgment submodule is used to determine the logical value of a logical expression using a preset software test program, and to extract the next execution node information entry corresponding to the logical value from the entry to be processed.
[0179] Optionally, when the component type is a loop control type, the input parameter data is the number of loops, and the assembled sub-modules may include:
[0180] The loop control logic expression assembly unit is used to fill the loop count into the preset data template and the custom data template, and to splice the completed preset data template and the custom data template to obtain the loop control logic expression used to determine whether the loop count is greater than the preset value.
[0181] Accordingly, test module 903 may include:
[0182] The loop control submodule is used to determine the loop logic value of the loop control logic expression using the preset software test program corresponding to the branch control type, update the loop count, and extract the next execution node information entry corresponding to the loop logic value from the pending entries.
[0183] Optionally, when the component type is a loop control type, the input parameter data consists of the actual result, expected result, and assertion method of the test case. The assembled sub-modules may include:
[0184] The assertion logic expression assembly unit is used to fill the actual results, expected results and assertion methods into the preset data template and the custom data template, and to splice the completed preset data template and the custom data template to obtain the assertion logic expression used to determine whether the test case is successfully tested.
[0185] Accordingly, test module 903 may include:
[0186] The assertion submodule is used to determine the assertion logic value of the assertion logic expression using the preset software test program corresponding to the branch control type, and to determine whether the test case was successfully tested based on the assertion logic value.
[0187] This invention also provides an electronic device, comprising:
[0188] Memory, used to store computer programs;
[0189] A processor is used to implement the steps of the software testing method described above when executing a computer program.
[0190] Since the embodiments of the electronic device part correspond to the embodiments of the software testing method part, please refer to the description of the embodiments of the software testing method part for the embodiments of the electronic device part, and they will not be repeated here.
[0191] This invention also provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of the software testing method described in any of the above embodiments.
[0192] Since the embodiments of the storage medium section correspond to the embodiments of the software testing method section, please refer to the description of the embodiments of the software testing method section for the embodiments of the storage medium section, and they will not be repeated here.
[0193] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.
[0194] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0195] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0196] The software testing method, apparatus, electronic device, and storage medium provided by this invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this invention. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and core ideas of this invention. It should be noted that those skilled in the art can make various improvements and modifications to this invention without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this invention.
Claims
1. A software testing method, characterized in that, include: Upon receiving the test case configuration information, the first execution node information entry in the test case configuration information is set as a pending entry; The test case configuration information includes a parameter pool, which contains test data, and the test data serves as both input and output data. The corresponding preset component information entry is found according to the component type in the entry to be processed, and the data to be processed is assembled using the preset data template in the preset component information entry and the configuration information in the entry to be processed and the corresponding input parameter data in the parameter pool; when the component type is a general component type, the data to be processed is request information, and when the component type is a branch control type, the data to be processed is a logical expression. The preset software test program corresponding to the preset component information entry processes the data to be processed to obtain output data, and uses the output data to update the corresponding test data in the parameter pool; the preset software test program corresponding to the general component type is used to send the request information to the target device and extract the output data from the response information of the target device; the preset software test program corresponding to the branch control type is used to determine the logical value of the logical expression, so as to determine the next execution node information, the next logical expression, or the termination identifier used to control the exit of the test process corresponding to the logical value; When it is determined that the entry to be processed has a corresponding next execution node information entry, the entry to be processed is updated to the next execution node information entry, and the step of searching for the corresponding preset component information entry based on the component type in the entry to be processed is entered. If it is determined that the entry to be processed does not have the next execution node information entry, the process exits.
2. The software testing method according to claim 1, characterized in that, The data to be processed is assembled using the preset data template in the preset component information entry and the configuration information in the entry to be processed, corresponding to the input parameter data in the parameter pool. This includes: Extract the custom data template and input parameter data from the configuration information; The input parameter data is filled into the preset data template and the custom data template, and the completed preset data template and custom data template are spliced together to obtain the data to be processed.
3. The software testing method according to claim 2, characterized in that, The extraction of input parameter data from the configuration information includes: Extract the input parameter data ID from the configuration information, and extract the corresponding test data from the parameter pool in the test case configuration information according to the input parameter data ID; Accordingly, processing the data to be processed using the preset software test program corresponding to the preset component information entry includes: The data to be processed is processed using the preset software test program corresponding to the preset component information entry to obtain output data and the corresponding output data ID; The corresponding test data is updated in the parameter pool using the output data and the output data ID.
4. The software testing method according to claim 3, characterized in that, The process of using the preset software test program corresponding to the preset component information entry to process the data to be processed, and obtaining the output data and the corresponding output data ID, includes: The request information is sent to the preset software testing program, so that the preset software testing program sends the request information to the target device and extracts the output data and determines the output data ID from the response information of the target device; Receive the output data and the output data ID sent by the preset software test program.
5. The software testing method according to claim 2, characterized in that, The process of processing the data to be processed using the preset software test program corresponding to the preset component information entry includes: The logical value of the logical expression is determined using the preset software testing program, and the next execution node information entry corresponding to the logical value is extracted from the entry to be processed.
6. The software testing method according to claim 5, characterized in that, When the component type is a loop control type, the input parameter data is the number of loops. The input parameter data is filled into the preset data template and the custom data template, and the filled preset data template and custom data template are concatenated to obtain the data to be processed, including: The number of iterations is filled into the preset data template and the custom data template, and the completed preset data template and custom data template are concatenated to obtain a loop control logic expression used to determine whether the number of iterations is greater than a preset value; Accordingly, processing the data to be processed using the preset software test program corresponding to the preset component information entry includes: The loop logic value of the loop control logic expression is determined using the preset software test program corresponding to the branch control type, the loop count is updated, and the next execution node information entry corresponding to the loop logic value is extracted from the pending entry.
7. The software testing method according to claim 5, characterized in that, When the component type is a loop control type, the input parameter data consists of the actual result, expected result, and assertion method of the test case. The input parameter data is filled into the preset data template and the custom data template, and the completed preset data template and custom data template are concatenated to obtain the data to be processed, including: The actual results, the expected results, and the assertion method are filled into the preset data template and the custom data template, and the completed preset data template and custom data template are spliced together to obtain the assertion logic expression used to determine whether the test case is successfully tested. Accordingly, processing the data to be processed using the preset software test program corresponding to the preset component information entry includes: The pre-defined software test program corresponding to the branch control type is used to determine the assertion logic value of the assertion logic expression, and the test case is determined to be successful based on the assertion logic value.
8. A software testing apparatus, characterized in that, include: The configuration module is used to set the first execution node information entry in the test case configuration information as a pending entry when the test case configuration information is received; the test case configuration information includes a parameter pool, the parameter pool includes test data, and the test data serves as input parameter data and output data; The assembly module is used to find the corresponding preset component information entry according to the component type in the entry to be processed, and to assemble the data to be processed using the preset data template in the preset component information entry and the configuration information in the entry to be processed and the corresponding input parameter data in the parameter pool; when the component type is a general component type, the data to be processed is request information; when the component type is a branch control type, the data to be processed is a logical expression. The testing module is used to process the data to be processed using the preset software test program corresponding to the preset component information entry, obtain output data, and update the corresponding test data in the parameter pool using the output data; the preset software test program corresponding to the general component type is used to send the request information to the target device and receive the response information from the target device, so as to determine whether the target device is normal by parsing the response information; the preset software test program corresponding to the branch control type is used to determine the logical value of the logical expression, so as to determine the next execution node information, the next logical expression, or the termination flag used to control the exit of the test process corresponding to the logical value. The update module is used to update the pending entry to the next execution node information entry when it is determined that the pending entry has a corresponding next execution node information entry, and then proceed to the step of finding the corresponding preset component information entry according to the component type in the pending entry; The exit module is used to exit the process when it is determined that the entry to be processed does not have the next execution node information entry.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for implementing the software testing method as described in any one of claims 1 to 7 when executing the computer program.
10. A storage medium, characterized in that, The storage medium stores computer-executable instructions, which, when loaded and executed by a processor, implement the software testing method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Expansion-based IFML mobile application test case forming method
CN106227667A
Test case test method and device, computer equipment and storage medium
CN109582563A
Use case generation method and device, electronic equipment and storage medium
CN110309062A
Full-link test method, device and system and computer readable storage medium
CN111078551A