Automatic assertion method and device, equipment and storage medium
By using dynamic range comparison in automated assertion methods, the limitations of traditional assertion methods in dynamic data scenarios are overcome. This enables flexible verification of dynamic data and improves the stability of test assertions, while simplifying the expression and maintenance of test logic.
Patent Information
- Application Number
- CN202511908698.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-03-06
AI Technical Summary
Traditional assertion methods have limitations in dynamic data scenarios. They cannot be applied to dynamically changing data, resulting in poor test stability and reliability. Furthermore, they lack support for complex comparison logic, which increases the complexity of test development and maintenance.
By designing an automated assertion method, a flexible and dynamic range comparison approach is adopted. It utilizes string expression parsing of comparison operators, dynamic baseline values, and tolerance parameters to dynamically construct database query conditions, supporting fuzzy matching and range matching, thereby improving the expressiveness and maintainability of test assertions.
It enables flexible verification of dynamic data, improves the stability and maintainability of test assertions, simplifies the expression and maintenance of complex logic, and expands the coverage of test scenarios.
Smart Images

Figure CN121614404A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software testing technology, and in particular to an automated assertion method, an automated assertion device, a corresponding electronic device, and a corresponding computer-readable storage medium. Background Technology
[0002] In software automation testing, it is often necessary to verify whether the data in the database matches the expected values; this test is called assertion. Traditional assertion methods mostly use static, exact-match assertions. This approach has limitations for dynamically changing data, such as the current system time, randomly generated order numbers, and session IDs, and is not suitable for assertions in dynamic data scenarios. Summary of the Invention
[0003] This application provides an automated assertion method, apparatus, device, and storage medium that can support automated data verification for flexible and dynamic range comparisons, solve the problem of the failure of the exact matching method in dynamic data scenarios, and improve the performance and maintainability of test assertions.
[0004] In one aspect, this application provides an automated assertion method, the method comprising:
[0005] Receive assertion expressions input by the user; the assertion expressions are string expressions used to indicate comparison logic;
[0006] The string expression is parsed to extract target elements; the target elements include comparison operators, dynamic baseline values, and tolerance parameters.
[0007] Based on the comparison operator, the dynamic benchmark value, and the tolerance parameter, database query conditions are dynamically constructed.
[0008] Execute the database query conditions and generate assertion results based on the database query results.
[0009] In some embodiments of this application, the general format of the string expression is:
[0010] Field name: (operator) baseline value / tolerance parameter.
[0011] In some embodiments of this application, the comparison operator includes an exact comparison operator and a range comparison operator; the dynamic benchmark value is used to calculate the target benchmark value; and the tolerance parameter is used to define the deviation range.
[0012] In some embodiments of this application, the step of dynamically constructing database query conditions based on the comparison operator, the dynamic benchmark value, and the tolerance parameter includes:
[0013] If the comparison operator is an exact comparison operator, then the exact comparison operator, the field name, and the target benchmark value are combined to obtain the database query conditions;
[0014] If the comparison operator is a range comparison operator, then the database query conditions are constructed based on the target benchmark value, the benchmark value range determined by the deviation range, and the field name.
[0015] In some embodiments of this application, generating assertion results based on the database query return results includes:
[0016] If the database query returns at least one record, an assertion result indicating successful assertion is generated.
[0017] If the database query returns an empty result, an assertion result indicating that the assertion failed is generated.
[0018] On the other hand, this application provides an automated assertion apparatus, the apparatus comprising:
[0019] An expression receiving module is used to receive assertion expressions input by the user; the assertion expression is a string expression used to indicate comparison logic;
[0020] The expression parsing module is used to parse the string expression and extract the target elements; the target elements include comparison operators, dynamic baseline values, and tolerance parameters.
[0021] The query condition construction module is used to dynamically construct database query conditions based on the comparison operator, the dynamic benchmark value, and the tolerance parameter;
[0022] The assertion result generation module is used to execute the database query conditions and generate assertion results based on the return results of the database query.
[0023] In some embodiments of this application, the general format of the string expression is:
[0024] Field name: (operator) baseline value / tolerance parameter.
[0025] In some embodiments of this application, the comparison operator includes an exact comparison operator and a range comparison operator; the dynamic benchmark value is used to calculate the target benchmark value; and the tolerance parameter is used to define the deviation range.
[0026] In some embodiments of this application, the query condition construction module includes:
[0027] The first query condition construction submodule is used to combine the exact comparison operator, the field name, and the target benchmark value to obtain the database query conditions when the comparison operator is an exact comparison operator.
[0028] The second query condition construction submodule is used to construct database query conditions based on the target benchmark value and the benchmark value range determined by the deviation range, as well as the field name, when the comparison operator is a range comparison operator.
[0029] In some embodiments of this application, the assertion result generation module includes:
[0030] The assertion generation submodule is used to generate an assertion result indicating successful assertion when the database query returns at least one record, and to generate an assertion result indicating failed assertion when the database query returns no record.
[0031] In another aspect, this application also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements any of the automated assertion methods described above.
[0032] In another aspect, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements any of the automated assertion methods described above.
[0033] In another aspect, this application also provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the automated assertion methods described in the foregoing aspects.
[0034] The automated assertion method, apparatus, device, and storage medium provided in this application parse the string expression used to indicate comparison logic, extracting three target elements: comparison operator, dynamic benchmark value, and tolerance parameter. Based on these three target elements, database query conditions are dynamically constructed, and a database query operation is executed. Assertion results are generated based on the returned results of the database query. By dynamically constructing database query conditions based on the comparison operator, dynamic benchmark value, and tolerance parameter obtained from the assertion expression parsing, the constructed database query conditions carry comparison operators and dynamic calculation logic. This supports flexible, dynamic range comparison for automated data verification, solving the problem of exact matching methods failing in dynamic data scenarios. Furthermore, the dynamic construction based on database query conditions improves the expressiveness and maintainability of test assertions. Attached Figure Description
[0035] Figure 1This is a flowchart illustrating the steps of an automated assertion method provided in an embodiment of this application;
[0036] Figure 2 This is a schematic diagram illustrating the process of constructing database query conditions provided in an embodiment of this application;
[0037] Figure 3 This is a structural block diagram of an automated assertion device provided in an embodiment of this application;
[0038] Figure 4 This is a structural block diagram of an electronic device provided in an embodiment of this application;
[0039] Figure 5 This is a structural block diagram of a computer-readable storage medium provided in an embodiment of this application. Detailed Implementation
[0040] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0041] Traditional assertion methods have significant limitations when dealing with dynamically changing data. Specifically: 1) Inadequacy of static assertions: Traditional assertion methods mostly use static, exact-match assertions, such as `field = expectedValue`. When the expected value is a dynamically generated value (such as `${currentTime}`), due to minor delays in code execution, network transmission, and database writing, there is an unavoidable time difference between the value actually written to the database by the system under test and the expected value generated in the test case, causing the exact-match assertion to fail. This problem will seriously affect the stability and reliability of the test. 2) Insufficient flexibility: Existing assertion frameworks lack native support for complex comparison logic. If testers want to verify whether a value is within a certain range, they usually need to write complex custom scripts or additional logic code. This not only increases the complexity of test development but also makes test cases difficult to maintain and understand, which contradicts the original intention of automated testing. 3) Weak expressiveness: Traditional assertion expressions cannot intuitively express common verification requirements in business logic such as "greater than", "less than a certain baseline value by an offset", or "within a certain interval".
[0042] This application's embodiments support flexible, dynamic range comparison for automated data verification, addressing the issue of exact matching failing in dynamic data scenarios and improving the expressiveness and maintainability of test assertions. Specifically, by introducing tolerance-based dynamic range comparison into the field of automatic assertions, and using string expressions conforming to preset syntax, traditional exact equality assertions are upgraded to fuzzy matching or range matching, fundamentally solving the technical pain point of dynamic data failing due to minor delays during assertion, thus realizing a dynamic range assertion mechanism. Furthermore, by designing a concise, self-explanatory declarative syntax, complex comparison logic is encapsulated in a unified string expression, greatly enhancing the expressiveness of test scripts, enabling non-technical personnel to intuitively understand the verification logic, while reducing the cost of writing and maintaining complex verification code, achieving declarative and expression-based assertion syntax. Additionally, because it supports embedding and calculating dynamic values in assertion expressions, assertion conditions are no longer static but can be dynamically generated based on the test context, greatly expanding the coverage of test scenarios. For example, it can easily verify business logic such as future effective times or past update times, possessing flexible dynamic value calculation capabilities. Furthermore, although the automated assertion method provided in this application originates from the field of automated testing, its core idea of dynamic range data verification can be widely applied to multiple scenarios that require verification of data consistency and validity, such as data quality monitoring, system log auditing, and business rule verification. It has strong scalability and cross-domain application potential, and can realize cross-domain applications in the technical field.
[0043] Reference Figure 1 The diagram illustrates a flowchart of an automated assertion method provided in an embodiment of this application, which may specifically include the following steps:
[0044] Step S101: Receive the assertion expression input by the user.
[0045] In this embodiment, a concise, self-explanatory declarative syntax can be designed to encapsulate complex comparison logic within a unified string expression, thereby enhancing the expressiveness of the test script. That is, the assertion expression can be a string expression used to indicate the comparison logic.
[0046] Specifically, comparison logic can be based on operators, benchmark values, and tolerance parameters. These operators, benchmark values, and tolerance parameters can be encapsulated in a concise string following specific syntax rules. The general format of the string expression is:
[0047] Field name: (operator) baseline value / tolerance parameter;
[0048] This string expression can be used to indicate whether a field meets the corresponding comparison with the baseline value or tolerance parameter.
[0049] As an example, the string expression "place_order_time":"(>)${currentTime+1h}" is used to verify whether place_order_time is greater than the current time plus 1 hour; as another example, the string expression "amount":"(>=)100" is used to verify whether amount is greater than or equal to 100; as yet another example, the string expression "place_order_time":"(=)${currentTime} / 30000" is used to verify whether place_order_time is within 30 seconds (i.e., 30000 milliseconds) before or after the current time. This application does not impose any limitations on these aspects.
[0050] Step S102: Parse the string expression and extract the target element.
[0051] After obtaining a string expression that conforms to the preset syntax, the string expression can be further parsed to extract the target elements. The extracted target elements are key elements used to indicate the comparison logic, including comparison operators, dynamic baseline values, and tolerance parameters.
[0052] The comparison operators can include exact comparison operators and range comparison operators. Exact comparison operators can be, for example, ">", ">=", "<", "<=", etc.; range comparison operators can be, for example, "=", which can be used to indicate that the ranges are equal.
[0053] Dynamic benchmark values can be used to calculate target benchmark values. For example, for dynamically changing data ${currentTime+1h} or ${currentTime}, when parsing the assertion expression and extracting this key element, the expression can be executed to calculate a specific comparison benchmark, i.e., to calculate the target benchmark value. Optionally, the calculated target benchmark value can be a specific timestamp or numerical value, used for the dynamic construction of subsequent database query conditions.
[0054] Tolerance parameters can be used to define the deviation range. Specifically, in the expression, a specific operator indicating equality of ranges (such as "=") is followed by numerical values separated by " / " to define the allowable deviation range. Optionally, the deviation range and the calculated target benchmark value can be used to calculate the benchmark value range.
[0055] Step S103: Dynamically construct database query conditions based on comparison operators, dynamic baseline values, and tolerance parameters.
[0056] The key elements extracted above can upgrade traditional exact equality assertions to fuzzy matching or range matching. In some embodiments of this application, database query conditions can be dynamically constructed based on the key elements extracted above, so as to introduce dynamic range comparison with tolerance into the field of automatic assertion.
[0057] like Figure 2 As shown, the steps for dynamically constructing database query conditions can specifically include the following sub-steps:
[0058] Sub-step S31: If the comparison operator is an exact comparison operator, then combine the exact comparison operator, field name, and target baseline value to obtain the database query conditions.
[0059] In sub-step S32, if the comparison operator is a range comparison operator, the database query conditions are constructed based on the target baseline value, the baseline value range determined by the deviation range, and the field names.
[0060] Specifically, the dynamic construction of database query conditions manifests as the dynamic construction of the SQL WHERE clause used for the query.
[0061] For exact comparison operators such as ">", ">=", "<", and "<=", the exact comparison operator, field name, and target baseline value can be directly combined to obtain the database query conditions. For example, for the first example above, we can construct WHERE place_order_time > [calculated future timestamp], where the calculated future timestamp is the target baseline value calculated in step S102. For example, ${currentTime+1h} is 1 hour after the current time.
[0062] For range comparison symbols, such as "=", the database query conditions can be constructed by combining the target baseline value and tolerance parameters, specifically based on the baseline value range determined by the target baseline value and the deviation range, and the field names. Optionally, a BETWEEN...AND... clause can be generated based on the aforementioned elements in the WHERE clause. For example, for the third example above, the following can be constructed: WHERE place_order_time BETWEEN [calculated current timestamp - 30000] AND [calculated current timestamp + 30000], where "calculated current timestamp - 30000" and "calculated current timestamp + 30000" are the determined baseline value ranges, and the calculated current timestamp is the target baseline value calculated in step S102, for example, ${currentTime} is the current time.
[0063] It should be noted that the execution of each test case initializes the test data in real time. The initialization of most test data, such as the parsing / replacement of ${currentTime}, is performed simultaneously, so all values of ${currentTime} are the same. Even if the initialization of ${currentTime} for a small portion of data is separate, for example, in scenarios where the initialization of different data has a sequential dependency, since all initializations are completed within the same test case execution, and the execution time of the same test case is only a few seconds, there will be no significant difference in determining the current timestamp (${currentTime}). This embodiment assumes that the current timestamp is the same when parsing assertion expressions, constructing database query conditions, and executing database query conditions.
[0064] Step S104: Execute the database query conditions and generate assertion results based on the returned results of the database query.
[0065] After dynamically constructing the database query conditions, the constructed SQL query statement can be executed, and the judgment logic for the assertion results can be determined based on the return results of the database query.
[0066] In one scenario, if the database query returns at least one record, it indicates that the target data meets the expected comparison conditions, the assertion is successful, and a successful assertion result is generated. In another scenario, if the database query returns an empty result, it indicates that no data meets the conditions, the assertion is unsuccessful, and a failed assertion result is generated.
[0067] In this embodiment, the string expression used to indicate comparison logic is parsed to extract three target elements: comparison operator, dynamic benchmark value, and tolerance parameter. Database query conditions are then dynamically constructed based on these three target elements, and a database query operation is executed. Assertion results are generated based on the returned results of the database query. By dynamically constructing database query conditions based on the comparison operator, dynamic benchmark value, and tolerance parameter obtained from the parsed assertion expression, the constructed database query conditions carry comparison operators and dynamic calculation logic. This supports flexible, dynamic range comparison and automated data verification, solving the problem of exact matching failing in dynamic data scenarios. Furthermore, the dynamic construction based on database query conditions improves the expressiveness and maintainability of test assertions.
[0068] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.
[0069] Reference Figure 3 The diagram shows a structural block diagram of an automated assertion device provided in an embodiment of this application, which may specifically include the following modules:
[0070] The expression receiving module 301 is used to receive assertion expressions input by the user; the assertion expression is a string expression used to indicate comparison logic;
[0071] The expression parsing module 302 is used to parse string expressions and extract target elements; the target elements include comparison operators, dynamic baseline values, and tolerance parameters.
[0072] The query condition construction module 303 is used to dynamically construct database query conditions based on comparison operators, dynamic baseline values, and tolerance parameters.
[0073] The assertion result generation module 304 is used to execute database query conditions and generate assertion results based on the return results of the database query.
[0074] In some embodiments of this application, the general format of the string expression is:
[0075] Field name: (operator) baseline value / tolerance parameter.
[0076] In some embodiments of this application, the comparison operators include exact comparison operators and range comparison operators; the dynamic benchmark value is used to calculate the target benchmark value; and the tolerance parameter is used to define the deviation range.
[0077] In some embodiments of this application, the query condition construction module 303 may include the following sub-modules:
[0078] The first query condition construction submodule is used to combine the exact comparison operator, field name, and target benchmark value to obtain the database query conditions when the comparison operator is an exact comparison operator.
[0079] The second query condition construction submodule is used to construct database query conditions based on the target baseline value, the baseline value range determined by the deviation range, and the field names when the comparison operator is a range comparison operator.
[0080] In some embodiments of this application, the assertion result generation module 304 may include the following sub-modules:
[0081] The assertion generation submodule is used to generate assertion results when the database query returns at least one record, and assertion results when the database query returns no record.
[0082] In this embodiment, the string expression used to indicate comparison logic is parsed to extract three target elements: comparison operator, dynamic benchmark value, and tolerance parameter. Database query conditions are then dynamically constructed based on these three target elements, and a database query operation is executed. Assertion results are generated based on the returned results of the database query. By dynamically constructing database query conditions based on the comparison operator, dynamic benchmark value, and tolerance parameter obtained from the parsed assertion expression, the constructed database query conditions carry comparison operators and dynamic calculation logic. This supports flexible, dynamic range comparison and automated data verification, solving the problem of exact matching failing in dynamic data scenarios. Furthermore, the dynamic construction based on database query conditions improves the expressiveness and maintainability of test assertions.
[0083] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0084] This application also provides an electronic device, see embodiments thereof. Figure 4 The provided electronic device 400 includes a memory 410, a processor 420, and a computer program 411 stored in the memory 410 and capable of running on the processor 420. When the computer program 411 is executed by the processor, it implements the various processes of the above-described automated assertion method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0085] This application also provides a computer-readable storage medium, see embodiments thereof. Figure 5 The computer-readable storage medium 500 provides a computer program 411 stored on it. When the computer program 411 is executed by the processor, it implements the various processes of the above-described automated assertion method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0086] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0087] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of the embodiments of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or modules is not necessarily limited to those steps or modules explicitly listed, but may include other steps or modules not explicitly listed or inherent to these processes, methods, products, or devices. The division of modules in the embodiments of this application is merely a logical division; in actual applications, there may be other division methods. For example, multiple modules may be combined into or integrated into another system, or some features may be ignored or not performed. Additionally, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interface, and the indirect coupling or communication connection between modules may be electrical or other similar forms, none of which are limited in the embodiments of this application. Furthermore, the modules or sub-modules described as separate components may or may not be physically separated, may or may not be physical modules, or may be distributed among multiple circuit modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiments of this application.
[0088] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0089] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and modules described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0090] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, apparatuses, or modules, and may be electrical, mechanical, or other forms.
[0091] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0092] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium.
[0093] In the above embodiments, the implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, in the form of a computer program product.
[0094] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0095] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0096] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The functions specified in one or more boxes; these computer program instructions may also be loaded onto a computer or other programmable data processing terminal equipment to cause a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0097] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0098] Finally, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0099] The technical solutions provided in the embodiments of this application have been described in detail above. Specific examples have been used in the embodiments of this application to illustrate the principles and implementation methods of the embodiments of this application. The description of the above embodiments is only for the purpose of helping to understand the methods and core ideas of the embodiments of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the embodiments of this application. Therefore, the content of this specification should not be construed as a limitation on the embodiments of this application.
Claims
1. An automated assertion method, characterized by, The method comprises: receiving an assertion expression input by a user; the assertion expression is a string expression used for indicating comparison logic; parsing the string expression to extract target elements; the target elements comprise a comparison operator, a dynamic reference value and a tolerance parameter; dynamically constructing a database query condition according to the comparison operator, the dynamic reference value and the tolerance parameter; executing the database query condition to generate an assertion result based on a return result of a database query.
2. The method of claim 1, wherein, A general format of the string expression is: field name: (operator) reference value / tolerance parameter.
3. The method of claim 2, wherein, The comparison operator comprises an exact comparison operator and a range comparison operator; the dynamic reference value is used for calculating a target reference value; and the tolerance parameter is used for defining a deviation range.
4. The method of claim 3, wherein, The dynamically constructing a database query condition according to the comparison operator, the dynamic reference value and the tolerance parameter comprises: if the comparison operator is an exact comparison operator, combining the exact comparison operator, the field name and the target reference value to obtain the database query condition; if the comparison operator is a range comparison operator, constructing the database query condition based on a reference value range determined according to the target reference value and the deviation range, and the field name.
5. The method of claim 1, wherein, The generating an assertion result based on a return result of a database query comprises: if the return result of the database query comprises at least one record, generating an assertion success assertion result; if the return result of the database query is empty, generating an assertion failure assertion result.
6. An automated assertion device, characterized by, The apparatus comprises: an expression receiving module configured to receive an assertion expression input by a user; the assertion expression is a string expression used for indicating comparison logic; an expression parsing module configured to parse the string expression to extract target elements; the target elements comprise a comparison operator, a dynamic reference value and a tolerance parameter; a query condition constructing module configured to dynamically construct a database query condition according to the comparison operator, the dynamic reference value and the tolerance parameter; an assertion result generating module configured to execute the database query condition to generate an assertion result based on a return result of a database query.
7. The apparatus of claim 6, wherein, A general format of the string expression is: field name: (operator) reference value / tolerance parameter; and the comparison operator comprises an exact comparison operator and a range comparison operator. The dynamic reference value is used for calculating a target reference value. The tolerance parameter is used for defining a deviation range. The query condition constructing module comprises: a first query condition constructing submodule configured to, when the comparison operator is an exact comparison operator, combine the exact comparison operator, the field name and the target reference value to obtain the database query condition; a second query condition constructing submodule configured to, when the comparison operator is a range comparison operator, construct the database query condition based on a reference value range determined according to the target reference value and the deviation range, and the field name.
8. The apparatus of claim 6, wherein, The assertion result generating module comprises: The assertion generation submodule is configured to generate an assertion success result when the returned result of the database query includes at least one record, and generate an assertion failure result when the returned result of the database query is empty.
9. An electronic device, comprising: The computer program is stored on the computer readable storage medium and is executed by the processor to implement the automated assertion method according to any one of claims 1 to 5. The computer program is stored on the computer readable storage medium and is executed by the processor to implement the automated assertion method according to any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that,