Automatic test method for query function, storage medium and program product
By building a public model diagram and configuring personalized parameters to generate automated test cases, the problems of incomplete test coverage and low efficiency caused by rapid updates to business logic are solved, and efficient and accurate database query function testing is achieved.
Patent Information
- Application Number
- CN202510931641.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-07
- Publication Date
- 2025-10-17
AI Technical Summary
In existing technologies, the rapid update of business logic requires continuous iteration of case generation models, resulting in incomplete test coverage or poor readability, and manual testing is inefficient and error-prone.
By building a public model diagram, including multiple function check modules and configuration nodes, configuring personalized parameters, and generating automated test cases, automated testing of database query functions can be achieved.
Improves functional testing efficiency, reduces testing time and error rate, and ensures test coverage consistency and accuracy.
Smart Images

Figure CN120803936A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of testing, in particular to a query function automatic testing method, a storage medium and a program product. BACKGROUND
[0002] Currently, a new business requirement is usually input into a pre-constructed case generation model, a new test case corresponding to the new business requirement is obtained through the case generation model, and the new business requirement and the corresponding new test case are updated to a knowledge graph; when a tester performs function testing, the tester can obtain a test case required by the corresponding business from the knowledge graph, and manually completes the function testing according to the test case.
[0003] However, if the business logic is updated quickly, the case generation model needs to be iteratively updated; the model structure and integrity differ greatly when different testers design the case generation model, resulting in incomplete test coverage or poor readability; the task amount is large, and manual execution of the test case not only requires a large amount of time, but also may miss some steps or introduce errors, resulting in reduced function testing efficiency. SUMMARY
[0004] The main purpose of the present application is to provide a query function automatic testing method, a storage medium and a program product, which aims to solve the technical problem of low function testing efficiency.
[0005] To achieve the above purpose, the present application provides a query function automatic testing method, which comprises:
[0006] In response to an editing operation on a target function checking module in a public model graph, a personalized parameter is configured, wherein the public model graph is constructed according to general query logic of different query businesses, the public model graph comprises a plurality of function checking modules, the target function checking module is a checking module about a database query function, the target function checking module comprises a plurality of configuration nodes, and each configuration node comprises a default parameter and a personalized parameter;
[0007] According to the default parameter and the configured personalized parameter, an automatic testing case for the database query function is generated;
[0008] Based on the automatic testing case, the database query function is tested.
[0009] In an embodiment, the configuration node comprises a variable configuration node and a decision table configuration node, the personalized parameter comprises a configurable variable in a public variable, a query condition variable, a query combination condition and a query interface, and the step of configuring the personalized parameter in response to the editing operation on the target function checking module in the public model graph comprises:
[0010] configuring the configurable variable and the query condition variable in response to an editing operation on the variable configuration node;
[0011] configuring the query combination condition and the query interface in response to an editing operation on the decision table configuration node.
[0012] In an embodiment, the step of configuring the query combination condition in response to an editing operation on the decision table configuration node comprises:
[0013] displaying a strategy configuration interface in response to an editing operation on the decision table configuration node;
[0014] configuring an interface request parameter value of the query condition in response to an editing operation on a field configuration window in the strategy configuration interface;
[0015] calling a PICT tool to generate the query combination condition according to the configured query condition in response to a selection operation on a strategy generation option in the strategy configuration interface.
[0016] In an embodiment, the step of generating the automated test case for the database query function according to the default parameter and the configured personalized parameter comprises:
[0017] generating the automated test case for the database query function according to the default parameter, the configured configurable variable, the configured query condition variable, the configured query combination condition and the configured query interface.
[0018] In an embodiment, the step of configuring the interface request parameter value of the query condition further comprises:
[0019] configuring an initial interface request parameter value of the query condition as one of a null value, a default value, a fixed value and an enumeration value, wherein the default value is a variable value corresponding to the query condition variable;
[0020] The step of generating the query combination condition according to the configured query condition by the PICT tool further comprises:
[0021] adding a post-query condition or modifying the query combination condition in response to an editing operation on a strategy display interface in the strategy configuration interface.
[0022] In an embodiment, the configurable variable comprises a database query statement, a sorting manner of the query statement and a query rule configuration, and the step of configuring the configurable variable comprises at least one of:
[0023] configuring the database query statement as a target query statement, wherein the target query statement covers all query condition fields and list fields returned by the query interface;
[0024] configure a sorting field of the query statement according to a preset record order, wherein the preset record order is consistent with the query result list and the interface response data list;
[0025] configure the query field and at least one query rule as a key-value pair to support multiple query scenarios.
[0026] In an embodiment, before the step of configuring the database query statement as the target query statement, the method further comprises:
[0027] generate an initial query statement according to a preset interface definition file through a preset plug-in, wherein the preset interface definition file is an interface definition file formulated and uploaded by a user for different interface IDs, the preset interface definition file includes interface fields, naming rules and mapping relationships, and the mapping relationships are the association relationships between the interface fields and the database query statement;
[0028] display the initial query statement in a configuration interface for the variable configuration node for the user to view or edit.
[0029] In an embodiment, the common variable further includes a default variable, and the default variable includes a query default value, a comparison record number and a comparison ignore list.
[0030] The query default value is a default parameter value when the interface is called, and the default parameter value when the interface is called is the field value of any valid record obtained from the database according to the configured database query statement.
[0031] The comparison record number is the default comparison number of multiple records returned by the interface.
[0032] The comparison ignore list includes fields that need to be skipped by default when comparing the returned data of the interface with the expected result.
[0033] In addition, to achieve the above-mentioned purpose, the present application also proposes an automatic testing device for query function, which comprises a memory, a processor and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the automatic testing method for query function as described above.
[0034] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the automatic testing method for query function as described above.
[0035] In addition, to achieve the above object, the application further provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the automatic test method of the query function as described above.
[0036] The one or more technical solutions provided by the application have at least the following technical effects:
[0037] In the application, the public model graph is constructed according to the general query logic of different query services, and the public model graph comprises a plurality of function checking modules, the target function checking module is a checking module related to the database query function, the target function checking module comprises a plurality of configuration nodes, each configuration node comprises a default parameter and a personalized parameter; the user can edit the target function checking module in the public model graph to configure the personalized parameter, so as to generate an automatic test case for the database query function according to the default parameter and the configured personalized parameter; further, based on the automatic test case, the automatic test of the database query function can be realized.
[0038] It can be understood that the user of the application only needs to configure the corresponding personalized parameter according to different services, does not need to configure the general default parameter, and the model structures are the same, so that the problems of incomplete test coverage or poor readability do not occur; and the application can realize the automatic execution of the test case, reduce the test time, and reduce the probability of missing some steps or introducing errors; therefore, the application can improve the function test efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0039] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the application and, together with the specification, serve to explain the principles of the application.
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0041] Figure 1 The first flowchart is provided for the first embodiment of the automatic test method of the query function of the application;
[0042] Figure 2 The first scene diagram is provided for the first embodiment of the automatic test method of the query function of the application;
[0043] Figure 3 The second scene diagram is provided for the first embodiment of the automatic test method of the query function of the application;
[0044] Figure 4 The third scene schematic diagram provided for the first embodiment of the query function automation test method of the present application is shown in the following figure:
[0045] Figure 5 The fourth scene schematic diagram provided for the first embodiment of the query function automation test method of the present application is shown in the following figure:
[0046] Figure 6 The fifth scene schematic diagram provided for the second embodiment of the query function automation test method of the present application is shown in the following figure:
[0047] Figure 7 The sixth scene schematic diagram provided for the second embodiment of the query function automation test method of the present application is shown in the following figure:
[0048] Figure 8 The seventh scene schematic diagram provided for the third embodiment of the query function automation test method of the present application is shown in the following figure:
[0049] Figure 9 The eighth scene schematic diagram provided for the third embodiment of the query function automation test method of the present application is shown in the following figure:
[0050] Figure 10 The ninth scene schematic diagram provided for the third embodiment of the query function automation test method of the present application is shown in the following figure:
[0051] Figure 11 The device structure schematic diagram of the hardware running environment involved in the query function automation test method of the embodiments of the present application is shown in the following figure.
[0052] The purpose implementation, functional features and advantages of the present application will be further explained in combination with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0053] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and do not limit the present application.
[0054] In order to better understand the technical solutions of the present application, the following will be described in detail in combination with the drawings and specific embodiments of the specification.
[0055] It should be noted that the execution subject of the present embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a query function automation test device, etc. The present embodiment and the following embodiments will be described taking the query function automation test device as an example.
[0056] Based on this, the present embodiment of the present application provides a query function automation test method, which is described in detail with reference to Figure 1 ,Figure 1 A flowchart of a first embodiment of the method for automated testing of a query function.
[0057] In this embodiment, the method for automated testing of a query function comprises steps S10-S30:
[0058] In response to an editing operation on a target function checking module in a common model graph, a personalized parameter is configured, wherein the common model graph is constructed according to a general query logic of different query services, the common model graph comprises a plurality of function checking modules, the target function checking module is a checking module about a database query function, the target function checking module comprises a plurality of configuration nodes, each configuration node comprises a default parameter and a personalized parameter; wherein the general query logic comprises common query behaviors and structures abstracted from a plurality of specific services.
[0059] It should be noted that the automated testing device for a query function is installed with a function testing software, a user can open the function testing software through the automated testing device, and the automated testing device displays the common model graph on the screen.
[0060] Specifically, referring to Figure 2 , the common model graph comprises a plurality of function checking modules, for example, a permission checking module, an interface element checking module, a management page initialization logic checking module, a checking module about a database query function, a query list checking module, and a general function checking module; since the logic of the database query function is relatively complex, and the permission checking module, the interface element checking module, the management page initialization logic checking module, the query list checking module, and the general function checking module are all contents required for fixed testing of the query function, a tester can test according to a fixed testing logic; therefore, this embodiment aims to realize automated testing of the database query function.
[0061] Since the test points are relatively fixed in the process of testing the database query function, different query services all involve the same steps such as query condition combination, query data preparation, query interface request, and query result comparison, therefore, this embodiment can construct a common model graph according to a general query logic of different query services.
[0062] Referring to Figure 2 , the target function checking module in the common model graph comprises a plurality of configuration nodes, the configuration nodes comprise a variable configuration node (a pre-node), a decision table configuration node (a combined condition automated query node), and a result checking node (a post-node), each configuration node comprises a default parameter and a personalized parameter.
[0063] It can be understood that the default parameters are parameters applicable to different services, and the personalized parameters are parameters that can be personalized according to specific service requirements. Specifically, the personalized parameters include configurable variables in public variables, query condition variables, query combination conditions and query interfaces.
[0064] Each of the above configuration nodes is a touchable component, and a tester can directly click, drag or fill in the content to complete parameter configuration. It can be understood that in the above manner, the user only needs to edit the personalized parameters in the target function check module according to specific service requirements, without the need to redesign the entire public model diagram or modify the default parameter part, thereby saving task quantity, reducing error rate and maintaining consistency.
[0065] Specifically, the implementation of configuring personalized parameters in response to the editing operation on the target function check module in the public model diagram can be:
[0066] In response to the editing operation on the variable configuration node, the configurable variables and the query condition variables are configured; and in response to the editing operation on the decision table configuration node, the query combination conditions and the query interfaces are configured.
[0067] It should be noted that the user only needs to configure the configurable variables and the query condition variables in the variable configuration node, and configure the query combination conditions and the query interfaces in the decision table configuration node. Regardless of the service, only a small number of parameters such as configurable variables, query condition variables, query combination conditions and query interfaces need to be uniformly configured, and other data assembly, message sending and result comparison can be completed through the underlying public method, thereby effectively solving the problems of slow automatic configuration and low debugging efficiency.
[0068] The configuration method of the query condition variable can be that a default value is set for the query condition variable, a variable is defined for each field of the query condition, and the default value of the query condition can be generated by a data canvas or corresponding values are taken from query default values, for example:
[0069] The repayment date is generated by a function: @T+n(-381, 'yyyyMMdd')@, or the customer name existing in the database is obtained from the record by database query: @getJsonValue(${query default value,
[0070] $.customerName)@, etc.
[0071] The result checking node includes default parameters: test data and result checking actions, wherein the test data is derived from information configured by the preceding nodes (such as the variable configuration node, the decision table configuration node, etc.), and the software internally uses a method (function / class) encapsulated by Python to process and generate test data that can be used for result verification, with reference to Figure 3 The source of the test data can be configured in different types and different values (for example, spliced result SQL, total number of SQL queries, SQL query results and response message list, etc.). The result checking action defines how to verify the actual result, with reference to Figure 4 For example, how to perform total number checking and how to perform record detail comparison in the actual result verification process.
[0072] Specifically, with reference to Figure 5 The configurable variables include a database query statement, a sorting method of the query statement, and a query rule configuration, and the implementation of configuring the configurable variables can be at least one of the following:
[0073] The database query statement is configured as a target query statement, which covers all query condition fields and list fields returned by the query interface;
[0074] According to a preset record order, the sorting field of the query statement is configured, wherein the preset record order makes the query result list and the interface response data list consistent;
[0075] The query field and at least one query rule are configured as a key-value pair to support multiple query scenarios.
[0076] Through reasonable setting of the database query statement, the sorting method of the query statement, and the query rule configuration, it can be ensured that the generated test case can accurately simulate the actual business scenario, and the accuracy of the comparison between the interface response and the database query result is improved.
[0077] For example, the user can configure the database query statement as a target query statement, which should cover all query condition fields and fields in the interface return list, but not include the sorting field. This SQL will be used as the basis for dynamically splicing query conditions in the future to generate the final expected result data.
[0078] To ensure the consistency of the record order between the database query result and the interface return data, the software supports configuring the sorting field of the query statement according to a preset record order. It is usually defined in the form of order by MSN, fromId, so that the SQL execution result and the dictionary list order of the interface response data remain consistent, which is convenient for subsequent result comparison.
[0079] In order to adapt to various query scenarios (such as fuzzy matching, range filtering, multiple selection query, etc.), the software introduces a query rule configuration mechanism. By configuring the query field and the corresponding query rule as a key-value pair (key is the field name, and value is the rule expression), flexible support for different query logic is realized. For example, configuring a "LIKE" rule for a certain field can realize fuzzy matching query for the field; configuring an "IN" rule can support multiple selection query scenarios; configuring ">=" or "<=" can realize greater than or equal to or less than or equal to range query; configuring ">" or "<" can realize greater than or less than comparison query; if no rule is configured, the default is to use "= " equal value matching. This mechanism effectively improves the compatibility and coverage of test cases for complex query logic.
[0080] Through reasonable setting of the database query statement, the sorting mode of the query statement and the query rule configuration, comprehensive coverage and efficient verification of the query interface function are realized, the flexibility and accuracy of the test process are improved, and a standardized data basis is provided for subsequent result comparison.
[0081] Step S20, according to the default parameters and the configured personalized parameters, generating an automatic test case for the database query function;
[0082] Specifically, after the user configures the personalized parameters, the software can generate an automatic test case for the database query function according to the default parameters and the personalized parameters, realizing the automatic generation of test cases and reducing manual writing work; supporting flexible adaptation of multiple scenarios, which can cover different business requirements through parameter combination; improving the consistency and maintainability of the test, facilitating unified management and version control; supporting seamless integration with the automatic test platform, improving the test execution efficiency and accuracy; having good scalability and reusability, and can be applied to various database operation scenarios.
[0083] Step S30, testing the database query function based on the automatic test case.
[0084] The generated test case can be directly called and automatically executed by the test engine, the automatic test device initiates the database query or calls the API interface, obtains the actual return result of the interface, compares the expected result with the actual result using the Python encapsulation method, outputs the test report (success / failure, error details), completes the test of the database query function, and supports failure retry, log recording, exception capture and other enhanced functions. Among them, the database query function can be a query function of a certain system website or a query function of a certain software, etc.
[0085] The embodiment adopts the above manner, does not need manual execution of test cases one by one, reduces repetitive labor, only needs to configure a small number of parameters to generate multiple test combinations, ensures that each test dimension is covered (fields, conditions, interfaces, results, etc.), all test personnel use the same set of public model diagrams to ensure test logic consistency, and parameter setting is completed through a touchable component, so that non-technical personnel can easily get started.
[0086] Based on the first embodiment of the application, in the second embodiment of the application, the same or similar contents as the above embodiment one can be referred to the above introduction, and the subsequent will not be described in detail. On this basis, the implementation manner of configuring the query combination condition in response to the editing operation on the decision table configuration node can be:
[0087] In response to the editing operation on the decision table configuration node, a strategy configuration interface is displayed; in response to the editing operation on the field configuration window in the strategy configuration interface, the interface request parameter value of the query condition is configured; and in response to the selection operation on the strategy generation option in the strategy configuration interface, the PICT tool is called, and the query combination condition is generated by the PICT tool according to the configured query condition.
[0088] It should be noted that when manually combining the query condition, the test personnel needs to consider all possible parameter combinations, and as the number of query conditions increases, the combination explosion problem is serious (n conditions may produce 2 n combinations), which leads to a large workload and is easy to miss.
[0089] In the embodiment, the user only needs to configure the query combination condition in the decision table configuration node. Specifically, by clicking the decision table configuration node, the strategy configuration interface is opened, the field configuration window in the strategy configuration interface is edited (for example, adding or deleting a query condition, or changing the variable of the query condition), further, the strategy generation option (the query condition that needs to be combined) in the strategy configuration interface is selected, and the generation of the query combination condition is determined, and the software can call the PICT tool to generate the query combination condition according to the configured query condition, refer to Figure 6 .
[0090] Specifically, the PICT (Pairwise Independent Combinatorial Testing) tool can select the smallest but most representative combination set from a large number of parameter combinations through an orthogonal method or a pairwise combination algorithm; in the above scene that needs to cover multiple parameter combinations, multiple query combination conditions can be quickly generated, refer to Figure 5 ; thereby solving the problems of low efficiency and scene omission of manual combination of query conditions by the user.
[0091] After the step of generating a query combination condition according to the configured query condition by the PICT tool, the method further includes:
[0092] In response to an editing operation on the policy display interface in the policy configuration interface, a supplementary query condition is added or the query combination condition is modified.
[0093] Because the combination conditions generated by the PICT tool may not cover special business scenarios in database query functions in some cases; for example, high-order combination logic dependencies (when there are complex logical relationships between multiple input parameters, and only specific triples, quadruples or even higher-order combinations can trigger certain functions or defects), boundary value and extreme case combinations (when certain parameters are at boundary values or extreme values, the combination with other parameters has special meaning or is prone to errors), illegal input and abnormal combinations (when multiple parameters are input with illegal values at the same time, whether the system can correctly handle the error or throw an exception), etc.
[0094] To solve this problem, this solution supports manual supplementation and adjustment of combination conditions based on the results automatically generated by PICT, thereby improving the compatibility of the query model with special query scenarios.
[0095] Specifically, during the test case generation process:
[0096] For common query condition combination scenarios, corresponding test cases can be automatically generated for verification using the default values of the query conditions and PICT rules;
[0097] For special combination scenarios that are difficult for PICT tools to effectively cover, users can manually add specific combination conditions based on the decision table generated by PICT to form supplementary test cases, and also include them in the automated test process for verification. Figure 7 .
[0098] Furthermore, in the "Generate Decision Table Data Based on PICT Rules" step, although the initial data is automatically generated by the tool, manual configuration is still required to make necessary adjustments and additions. Users can edit the generated decision table content based on actual business needs to ensure that the final query scenario output is complete and accurate, meeting the testing requirements of various complex query functions.
[0099] It should be noted that when the policy configuration interface is displayed, the field values displayed in the policy configuration interface are all the initially configured interface request parameter values. In response to the editing operation of the field configuration window in the policy configuration interface, the initially configured interface request parameter values corresponding to the query conditions can be modified.
[0100] Specifically, before configuring the interface request parameter value of the query condition, you can also: configure the initial interface request parameter value of the query condition to be one of a null value, a default value, a fixed value, and an enumeration value, wherein the default value is the variable value corresponding to the query condition variable.
[0101] For example, the initial interface request parameter value of the query condition is empty: ${EMPTY};
[0102] Configure the initial interface request parameter value of the query condition as the default value: set it to the corresponding variable of "Query condition variable configuration";
[0103] Configure the initial interface request parameter value of the query condition as a fixed value or an enumeration value: directly set the specific value.
[0104] Specifically, the implementation method of generating an automated test case for the database query function based on the default parameters and the configured personalized parameters may be:
[0105] An automated test case for the database query function is generated based on the default parameters, the configured configurable variables, the configured query condition variables, the configured query combination conditions and the configured query interface.
[0106] It can be understood that based on the default parameters, configured configurable variables, configured query condition variables, configured query combination conditions and configured query interface, personalized automated test cases for database query functions covering all test points can be generated; in this process, users can clearly configure each personalized parameter that needs to be configured, and after configuration, they can generate multiple combination test cases with one click.
[0107] The above method of this embodiment combines standardized test logic with business personalized needs, ensuring that the generated test cases are both universal and can accurately cover the actual query scenarios of the target system, thereby achieving efficient and comprehensive database query function testing.
[0108] Based on the first and second embodiments of the present application, in the third embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to above and will not be described in detail. On this basis, before the step of configuring the database query statement as the target query statement, the following steps may also be performed:
[0109] The initial query statement is generated according to a preset interface definition file by a preset plug-in, wherein the preset interface definition file is an interface definition file formulated and uploaded by a user for different interface IDs, the preset interface definition file includes interface fields, naming rules and mapping relationships, and the mapping relationships are the association relationships between the interface fields and the database query statements; and the initial query statement is displayed in a configuration interface for a variable configuration node for the user to view or edit.
[0110] The initial query statement is automatically generated according to the interface definition file uploaded by the user through the preset plug-in, the mapping efficiency between the database query SQL and the interface fields is improved, and reference is made to Figure 8 For example, the field after XXXX AS can be changed into the interface field corresponding to the database according to the corresponding field of the response message.
[0111] Specifically, the interface definition file is formulated and uploaded by the user for different interface IDs, and includes interface fields, naming rules and mapping relationships between the interface fields and the database query statements, the plug-in quickly generates the initial query statement based on the interface definition file and displays the initial query statement in the configuration interface of the variable configuration node for the user to view or further edit.
[0112] Since the database query SQL statement and the interface response field need to be mapped one by one in the subsequent query automation comparison process, the traditional method relies on manual configuration, which is low in efficiency and prone to errors. The mapping process between the interface field and the database SQL is automatically completed after the input of the interface ID through the plug-in mechanism, which significantly improves the configuration efficiency and accuracy.
[0113] In addition, in terms of interface parameter configuration, in order to support parameter transmission based on the combined condition query case generated by the PICT tool, all query conditions are configured in the PICT rule in the form of variables, so that each group of combined conditions generated by the PICT can be directly used as the input parameters of the query interface, thereby effectively simplifying the manual mapping process from the test case data to the interface parameters.
[0114] On this basis, the following strategies are adopted in the query data preparation stage: first, a data is randomly obtained as an initialization input parameter based on the empty condition query SQL, and a customized initialization setting is supported through a function for special input parameters. When the interface is called, the input parameters of the query interface directly use the test case data generated by the PICT, and the interface response result is uniformly assigned to a fixed variable, which is convenient for subsequent result verification and comparison processing, and reference is made to Figure 9 For example, the query interface input parameter data can be used to splice the empty condition query SQL for querying, and then the SQL query result list and the interface response variable are compared by using a public verification method.
[0115] Based on the above, the scheme realizes the full-process automatic processing from interface definition parsing, query SQL generation, query condition combination generation to interface input parameter configuration, improves the efficiency and integrity of database query function testing, and reduces the error risk caused by manual operation.
[0116] In the process of interface configuration, a configuration step of uniform variable naming of query component return value is also included. To ensure the consistency of subsequent result comparison logic and the feasibility of automatic execution, the data returned by the interface request needs to be uniformly assigned to two fixed variables. Referring to Figure 10
[0117] The variable name corresponding to the interface request data is ${request_data} ;
[0118] The variable name corresponding to the interface response data is ${response_data}.
[0119] These two variable names are preset naming rules in the software. The subsequent result comparison public method will extract the corresponding data based on this variable name by default and perform field-level or structure-level comparison and verification. Through the uniform variable naming mechanism, the generality and reusability of the result checking module are improved, and the risk of verification failure caused by inconsistent variable naming is effectively reduced, thereby ensuring the stability and maintainability of the entire automatic test process.
[0120] Further, referring to Figure 5 , the public variable further includes a default variable, and the default variable includes a query default value, a comparison record number, and a comparison ignore list.
[0121] The query default value is a default parameter value when the interface is called, and the default parameter value when the interface is called is any field value of a valid record obtained from the database according to the configured database query statement.
[0122] The comparison record number is the default comparison number of multiple records returned by the interface.
[0123] The comparison ignore list includes the fields that need to be skipped by default when comparing the returned data of the interface with the expected result.
[0124] In order to improve the test configuration efficiency and result verification accuracy, the present scheme introduces a plurality of public variables as default configuration items, including: query default value, comparison record number and comparison ignore list.
[0125] Among them, the query default value is the default parameter value used when the interface is called, and the value is randomly obtained from the database by the software according to the user-configured database query SQL statement A valid record is obtained, and each field value of the record is used as the default query condition to ensure that the test data is real and executable.
[0126] In order to improve the result comparison efficiency, the software also sets the number of comparison records, that is, the default field-level comparison is only performed on the first N records returned by the interface. This value can be set in the configuration (such as the default 30), which avoids performance degradation due to excessive returned data volume, while ensuring verification integrity.
[0127] In addition, a comparison ignore list can also be configured to define fields that do not need to participate in the verification during the result comparison process. Through this mechanism, the comparison range can be flexibly controlled, and the accuracy and execution efficiency of field comparison can be improved.
[0128] In terms of query result verification process, the present scheme adopts a phased comparison strategy: first, verify whether the number of records returned by the interface is consistent with the expected value, if not, directly determine as failed; if consistent, continue to compare the field values one by one; This way not only avoids the risk of inconsistent fields caused by only comparing the number, but also solves the performance problem caused by full comparison, significantly improving the effectiveness and execution efficiency of result checking.
[0129] In order to be compatible with various complex query conditions, the present scheme maps the automatic input parameters to fuzzy matching, range filtering, multiple selection query and other scenarios through dictionary configuration, simplifying the parameter configuration process and improving the applicability of different query condition types.
[0130] For abnormal query scenarios involving special characters and field length, manual test cases in the public model are mainly used for coverage verification to ensure that the software can still run stably under boundary conditions.
[0131] In the present embodiment, by introducing default variable configuration, phased result comparison mechanism, diversified parameter assignment method and query condition scenario adaptation mechanism, the efficiency, accuracy and flexibility of database query function testing are realized, and the overall test quality and maintenance efficiency are improved.
[0132] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the query function automatic testing method of the present application. Based on this technical concept, more forms of simple transformation are within the protection scope of the present application.
[0133] The application provides an automatic test device for query function, the automatic test device for query function comprises at least one processor and a memory connected with the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the automatic test method for query function in the embodiment one.
[0134] Reference will be made to the drawings Figure 11 which shows a structural diagram of an automatic test device for query function suitable for implementing the embodiments of the application. The automatic test device for query function in the embodiments of the application can include, but is not limited to, mobile terminals such as mobile phones, tablet computers, notebook computers, digital broadcast receivers, PDAs (Personal Digital Assistant), PMPs (Portable Media Player), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and the like, and fixed terminals such as digital televisions, desktop computers, and the like. Figure 11 The automatic test device for query function shown is only an example, and should not bring any limitation to the functions and use range of the embodiments of the application.
[0135] As Figure 11As shown, the query function automation test device can include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 1002 or programs loaded from a storage device 1003 into a random access memory (RAM) 1004. Various programs and data required for the operation of the query function automation test device are also stored in the RAM 1004. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; the storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the query function automation test device to communicate wirelessly or wired with other devices to exchange data. Although the query function automation test device with various systems is shown in the figure, it should be understood that all the shown systems are not required to be implemented or possessed. More or fewer systems can be alternatively implemented or possessed.
[0136] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program codes for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through the communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the methods of the embodiments disclosed in the present application are performed.
[0137] The query function automation test device provided by the present application adopts the query function automation test method in the above-mentioned embodiments, and can solve the technical problem of low efficiency of function test. Compared with the prior art, the query function automation test device provided by the present application has the same beneficial effects as the query function automation test method provided by the above-mentioned embodiments, and other technical features in the query function automation test device are the same as the features disclosed in the previous embodiment method, which will not be repeated here.
[0138] It should be understood that various aspects of the disclosure can be implemented in hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any appropriate manner in any one or more embodiments or examples.
[0139] The above description is merely illustrative of the application and is not intended to limit the scope of the application. Any variations and modifications that can be made by any person skilled in the art within the spirit and scope of the application are intended to be encompassed by the application. The scope of the application is defined by the appended claims.
[0140] The application provides a computer readable storage medium having stored thereon computer readable program instructions (i.e., a computer program) for performing the automated testing method of the query function in the above-described embodiments.
[0141] The computer readable storage medium provided by the application may, for example, be a U disk, but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, system, or device, or any combination thereof. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more conductive wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any appropriate combination thereof. In the present embodiment, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer readable storage medium can be transmitted in any appropriate medium, including but not limited to an electrical wire, an optical cable, an RF (Radio Frequency) cable, etc., or any appropriate combination thereof.
[0142] The above-described computer readable storage medium can be included in the automated testing device of the query function; or can exist separately and not be assembled into the automated testing device of the query function.
[0143] The computer readable storage medium described above carries one or more programs, which, when executed by the automation test device for the query function, cause the automation test device for the query function to perform the automation test method for the query function.
[0144] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0145] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flow diagrams or block diagrams can represent a module, a procedure, or a part of code, which comprises one or more executable instructions for implementing the specified functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in some cases, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and flow diagrams, and combinations of blocks in the block diagrams and flow diagrams, can be implemented by a dedicated hardware-based system that carries out specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0146] The modules involved in the embodiments of the present application can be implemented in software or in hardware. In some cases, the names of the modules do not constitute a limitation on the modules themselves.
[0147] The readable storage medium provided by the application is a computer readable storage medium, which stores computer readable program instructions (i.e. computer programs) for executing the above-mentioned query function automated testing method, and can solve the technical problem of low efficiency of function testing. Compared with the prior art, the beneficial effects of the computer readable storage medium provided by the application are the same as those of the query function automated testing method provided by the above-mentioned embodiments, and will not be repeated here.
[0148] The application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the query function automated testing method as described above.
[0149] The computer program product provided by the application can solve the technical problem of low efficiency of function testing. Compared with the prior art, the beneficial effects of the computer program product provided by the application are the same as those of the query function automated testing method provided by the above-mentioned embodiments, and will not be repeated here.
[0150] The above-mentioned is only part of the embodiments of the application, and does not limit the patent scope of the application, and any equivalent structural transformation made by using the content of the application specification and drawings, or direct / indirect application in other related technical fields is included in the patent protection scope of the application.
Claims
1. An automated testing method for query functions, characterized in that: The method includes: In response to an edit operation on a target function check module in a common model diagram, configuring personalized parameters, wherein the common model diagram is constructed according to a common query logic for different query services, the common model diagram includes a plurality of function check modules, the target function check module is a check module for a database query function, the target function check module includes a plurality of configuration nodes, each configuration node including a default parameter and a personalized parameter; Generate automated test cases for database query functions based on the default parameters and the configured personalized parameters; Based on the automated test case, the database query function is tested.
2. The method according to claim 1, wherein The configuration node includes a variable configuration node and a decision table configuration node, the personalized parameters include configurable variables in the public variables, query condition variables, query combination conditions, and query interfaces, and the step of configuring the personalized parameters in response to an editing operation on the target function check module in the public model diagram includes: In response to an edit operation on a variable configuration node, configuring the configurable variables and the query condition variables; In response to an edit operation on a decision table configuration node, a query combination condition and a query interface are configured.
3. The method according to claim 2, wherein The step of configuring the query combination condition in response to the editing operation on the decision table configuration node includes: In response to an edit operation on a decision table configuration node, displaying a policy configuration interface; In response to an edit operation on a field configuration window in a policy configuration interface, configuring an interface request parameter value of a query condition; In response to a selection operation on a policy generation option in the policy configuration interface, a PICT tool is called, and a query combination condition is generated according to the configured query condition by the PICT tool.
4. The method according to claim 3, wherein The step of generating an automated test case for the database query function based on the default parameters and the configured personalized parameters includes: An automated test case for the database query function is generated based on the default parameters, the configured configurable variables, the configured query condition variables, the configured query combination conditions and the configured query interface.
5. The method according to claim 3, wherein Before the step of configuring the interface request parameter value of the query condition, the method further includes: The initial interface request parameter value of the configuration query condition is one of a null value, a default value, a fixed value, and an enumeration value, wherein the default value is the variable value corresponding to the query condition variable; After the step of generating a query combination condition according to the configured query condition by the PICT tool, the method further includes: In response to an editing operation on the policy display interface in the policy configuration interface, a supplementary query condition is added or the query combination condition is modified.
6. The method according to claim 2, wherein The configurable variables include database query statements, query statement sorting methods, and query rule configurations. The step of configuring the configurable variables includes at least one of the following: Configure the database query statement as a target query statement, which covers all query condition fields and the list fields returned by the query interface; Configuring the sorting fields of the query statement according to a preset record order, wherein the preset record order makes the query result list and the interface response data list consistent; Configure query fields and at least one query rule as key-value pairs to support various query scenarios.
7. The method according to claim 6, characterized in that, Before the step of configuring the database query statement as the target query statement, the method further includes: Generate an initial query statement through a preset plug-in according to a preset interface definition file, wherein the preset interface definition file is an interface definition file prepared and uploaded by the user for different interface IDs, and the preset interface definition file includes interface fields, naming rules, and mapping relationships, and the mapping relationship is the association relationship between the interface fields and the database query statement; The initial query statement is displayed in a configuration interface for a variable configuration node for viewing or editing by a user.
8. The method according to claim 6, wherein The common variables also include default variables, which include query default values, comparison record counts, and comparison ignore lists; The query default value is the default parameter value when the interface is called, and the default parameter value when the interface is called is the value of each field of any valid record obtained from the database according to the configured database query statement; The number of comparison records is the default number of comparison records returned by the interface; The comparison ignore list includes fields that need to be skipped by default when comparing the interface return data with the expected results.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the automated testing method for the query function according to any one of claims 1 to 8 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the automated testing method for the query function according to any one of claims 1 to 8 are implemented.