Assertion processing method, device, computer equipment and storage medium

By analyzing the hierarchical structure and matching logic of the target statement and combining the assertion instruction set, the problem of high efficiency and low assertion processing in the existing technology is solved, and efficient assertion processing is achieved.

CN114239538BActive Publication Date: 2025-08-19PING AN PAY ELECTRONIC PAYMENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111555661.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-17
Publication Date
2025-08-19
Estimated Expiration
2041-12-17

AI Technical Summary

Technical Problem

The assertion processing method of the existing interface test platform requires multiple maintenance of each field, resulting in high cost and inefficient assertion processing.

Method used

By obtaining and parsing the target statements entered by the user, the hierarchical structure and matching logic of the target field are determined, combined into an assertion instruction set, and detecting whether the response data meets the assertion instruction, and outputting an alarm prompt.

Benefits of technology

It reduces the maintenance cost of assertion processing, improves the efficiency of assertion processing, ensures that the target matching logic is consistent with the response data format, and quickly compares the response data and assertion instructions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114239538B_ABST
    Figure CN114239538B_ABST
Patent Text Reader

Abstract

This application relates to artificial intelligence technology and provides an assertion processing method, apparatus, computer device, and storage medium, including: obtaining and parsing a target statement input by a user to obtain a hierarchical structure corresponding to the target statement; determining target matching logic corresponding to several target fields in the target statement; combining the target matching logic according to the hierarchical structure to obtain an assertion instruction set; obtaining response data corresponding to the target field and a target assertion instruction corresponding to the target field; detecting whether the response data satisfies the target assertion instruction; and outputting an alarm prompt when the detection result shows that the response data does not satisfy the target assertion instruction. This application can improve assertion processing efficiency and promote the rapid development of smart cities.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to an assertion processing method, apparatus, computer device, and storage medium. Background Art

[0002] When writing code, we often make assumptions. Assertions are used to capture these assumptions in code, and can be considered an advanced form of exception handling. Assertions are expressed as Boolean expressions that determine certain key data. If the key data is not as expected, the program will issue an alarm or exit. In interface testing, when calling assertion requests and returning a JSON response, you may need to assert multiple fields to ensure assertion accuracy.

[0003] In the process of implementing this application, the applicant found that the existing technology has the following technical problems: the assertion processing method of the existing interface testing platform mostly adds an assertion for each field separately. If the response results of these fields need to be obtained from the database for comparison, similar SQL texts need to be maintained multiple times, resulting in high assertion processing costs and low efficiency.

[0004] Therefore, it is necessary to provide an assertion processing method that can improve assertion processing efficiency. Summary of the Invention

[0005] In view of the above, it is necessary to propose an assertion processing method, an assertion processing apparatus, a computer device, and a medium to improve the assertion processing efficiency.

[0006] A first aspect of an embodiment of the present application provides an assertion processing method, the assertion processing method comprising:

[0007] Obtain and parse the target sentence input by the user to obtain the hierarchical structure corresponding to the target sentence;

[0008] Determine target matching logic corresponding to a plurality of target fields in the target sentence;

[0009] Combining the target matching logic according to the hierarchical structure to obtain an assertion instruction set;

[0010] Obtaining response data corresponding to the target field and a target assertion instruction corresponding to the target field;

[0011] Detecting whether the response data satisfies the target assertion instruction;

[0012] When the detection result is that the response data does not meet the target assertion instruction, an alarm prompt is output.

[0013] Furthermore, in the assertion processing method provided in the embodiment of the present application, obtaining and parsing the target sentence input by the user to obtain the hierarchical structure corresponding to the target sentence includes:

[0014] Parsing the target sentence and detecting whether the target sentence contains preset level keywords;

[0015] When the detection result is that the target sentence contains the preset level keywords, obtaining the hierarchical order of the preset level keywords in the target sentence;

[0016] The preset hierarchical keywords are combined according to the hierarchical order to obtain a hierarchical structure corresponding to the target sentence.

[0017] Furthermore, in the assertion processing method provided in the embodiment of the present application, the target matching logic for determining the target fields in the target statement includes:

[0018] Obtaining several target fields in the target sentence;

[0019] Determining a set of historical fields whose similarity to the target field exceeds a preset similarity threshold;

[0020] Obtaining the initial matching logic corresponding to each historical field in the historical field set to obtain an initial matching logic set;

[0021] The matching logic with the highest occurrence frequency in the initial matching logic set is selected as the target matching logic.

[0022] Furthermore, in the assertion processing method provided in the embodiment of the present application, combining the target matching logic according to the hierarchical structure to obtain the assertion instruction set includes:

[0023] Acquire the structural relationship between the target fields according to the hierarchical structure;

[0024] Traversing the mapping relationship between the preset fields and the matching logic according to the target field to obtain the target matching logic corresponding to the target field;

[0025] The target matching logic is combined according to the structural relationship to obtain an assertion instruction set.

[0026] Furthermore, in the above-mentioned assertion processing method provided in the embodiment of the present application, obtaining the response data corresponding to the target field and the target assertion instruction corresponding to the target field includes:

[0027] Obtaining a first mapping relationship between a preset field and response data;

[0028] Traversing the first mapping relationship according to the target field to obtain response data corresponding to the target field;

[0029] Obtaining a second mapping relationship between a preset field and an assertion instruction;

[0030] The second mapping relationship is traversed according to the target field to obtain a target predicate instruction corresponding to the target field.

[0031] Furthermore, in the assertion processing method provided in the embodiment of the present application, detecting whether the response data satisfies the target assertion instruction includes:

[0032] Detecting whether the response data is identical to the target assertion instruction;

[0033] When the detection result is that the response data is identical to the target assertion instruction, it is determined that the response data satisfies the target assertion instruction, and an assertion success result is returned.

[0034] Furthermore, in the assertion processing method provided in the embodiment of the present application, after selecting the matching logic with the highest frequency in the initial matching logic set as the target matching logic, the method further includes:

[0035] Outputting the target matching logic corresponding to the target field to a preset terminal;

[0036] Monitoring whether the preset terminal outputs a logically correct prompt;

[0037] When the monitoring result indicates that the preset terminal outputs a prompt indicating that the logic is correct, it is determined that the target matching logic is correct.

[0038] A second aspect of the present application further provides an assertion processing device, the assertion processing device comprising:

[0039] A hierarchical acquisition module is used to acquire and parse the target sentence input by the user to obtain the hierarchical structure corresponding to the target sentence;

[0040] A logic determination module, configured to determine target matching logic corresponding to a plurality of target fields in the target sentence;

[0041] An assertion combination module, configured to combine the target matching logic according to the hierarchical structure to obtain an assertion instruction set;

[0042] An assertion acquisition module, configured to acquire response data corresponding to the target field and a target assertion instruction corresponding to the target field;

[0043] A result comparison module, configured to detect whether the response data satisfies the target assertion instruction;

[0044] The alarm output module is used to output an alarm prompt when the detection result is that the response data does not meet the target assertion instruction.

[0045] A third aspect of an embodiment of the present application further provides a computer device, the computer device comprising a processor, the processor being configured to implement any one of the above-described assertion processing methods when executing a computer program stored in a memory.

[0046] A fourth aspect of the embodiments of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, any one of the above-mentioned assertion processing methods is implemented.

[0047] The above-mentioned assertion processing method, assertion processing device, computer equipment and computer-readable storage medium provided by the embodiment of the present application can reduce the maintenance cost of assertions and improve the efficiency of assertion processing by merging the target matching logic corresponding to each target field in the target statement into an assertion instruction set for processing; in addition, the present application obtains the hierarchical relationship corresponding to the target statement input by the user, and combines the target matching logic corresponding to several fields in the target statement according to the hierarchical relationship, so as to ensure that the structural relationship of the target matching logic is consistent with the format of the response data, and can quickly compare the response data with the target assertion instruction, thereby improving the efficiency of assertion processing. The present application can be applied to various functional modules of smart cities such as smart government affairs and smart transportation, such as the assertion processing module of smart government affairs, etc., and can promote the rapid development of smart cities. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0049] Figure 1 This is a flowchart of the assertion processing method provided in Example 1 of the present application.

[0050] Figure 2 This is a structural diagram of the assertion processing device provided in Example 2 of the present application.

[0051] Figure 3 This is a structural diagram of the computer device provided in Example 3 of the present application.

[0052] The following specific implementation methods will further illustrate the present application in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION

[0053] In order to more clearly understand the above-mentioned objectives, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features therein can be combined with each other in the absence of conflict.

[0054] In the following description, many specific details are set forth to facilitate a full understanding of the present application. The described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application pertains. The terms used herein in the specification of this application are for the purpose of describing specific embodiments only and are not intended to limit this application.

[0056] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to achieve optimal results.

[0057] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.

[0058] The assertion processing method provided by the embodiment of the present invention is executed by a computer device. The assertion processing method can be applied in an interface testing process. Accordingly, the assertion processing device runs in the computer device. Figure 1 This is a flowchart of the assertion processing method provided in Example 1 of this application. Figure 1 As shown, the assertion processing method may include the following steps. According to different requirements, the order of the steps in the flowchart may be changed, and some steps may be omitted:

[0059] S11, acquiring and parsing a target sentence input by a user to obtain a hierarchical structure corresponding to the target sentence.

[0060] In at least one embodiment of the present application, the assertion processing method can be applied to the interface testing process. Interface testing refers to a test of the interface between system components. Interface testing is mainly used to detect whether there are anomalies in the interaction points between the external system and the system and between the internal subsystems. The focus of the test is to check the data exchange, transmission and control management process. In one embodiment, the target statement can be a statement in JSON format. The target statement contains several fields that need to be asserted. The number of fields can be 1 or more, and there is no limit here. The target statement can be a code language set by the system personnel for the target interface. The target interface is an interface of the application software that needs to be tested. The application software that needs to be tested can be installed in a computer device. The target statement is written according to a preset hierarchical structure. By deeply parsing the target statement, the hierarchical structure corresponding to the target statement can be obtained. The hierarchical structure is an organizational structure of each field in the target statement, which is used to isolate the hierarchical functions corresponding to each field.

[0061] Optionally, acquiring and parsing a target sentence input by a user to obtain a hierarchical structure corresponding to the target sentence includes:

[0062] Parsing the target sentence and detecting whether the target sentence contains preset level keywords;

[0063] When the detection result is that the target sentence contains the preset level keywords, obtaining the hierarchical order of the preset level keywords in the target sentence;

[0064] The preset hierarchical keywords are combined according to the hierarchical order to obtain a hierarchical structure corresponding to the target sentence.

[0065] The preset hierarchical keywords refer to keywords pre-set by system personnel to represent hierarchical relationships. For example, the preset hierarchical keywords may include, but are not limited to, keywords such as data, userInfo, and userName. The preset hierarchical keywords are stored in a preset database. Considering the reliability and privacy of data storage, the preset database may be a target node in the blockchain. The hierarchical order refers to the order in which the preset hierarchical keywords appear in the target sentence. Generally speaking, higher-level preset hierarchical keywords appear before lower-level preset hierarchical keywords. By extracting the preset hierarchical keywords according to the hierarchical order, the hierarchical structure corresponding to the target sentence can be obtained.

[0066] S12: Determine target matching logic corresponding to several target fields in the target sentence.

[0067] In at least one embodiment of the present application, the target statement may be a statement in JSON format, and the target statement may contain several fields that require assertion processing. The number of fields may be one or more, and is not limited here. The field value of the target field supports variable replacement, and the field value may be understood as the attribute value of the target field. For example, for the target field "userName": "Zhang San", "Zhang San" may be the field value of the target field. In one embodiment, the variable source may be configured as: database return value, request data, specified function return value, etc. The target field refers to the field that requires assertion processing, and for each target field, there is a corresponding target matching logic. In one embodiment, the target matching logic may include but is not limited to: contains, does not contain, equal to, not equal to, regular matching, etc. The target matching logic may be pre-set by system personnel for each field, or it may be predicted through deep learning. The target matching logic is text in string format, and the string format may be JSON string format.

[0068] Optionally, determining target matching logic corresponding to the target fields in the target sentence includes:

[0069] Obtaining several target fields in the target sentence;

[0070] Determining a set of historical fields whose similarity to the target field exceeds a preset similarity threshold;

[0071] Obtaining the initial matching logic corresponding to each historical field in the historical field set to obtain an initial matching logic set;

[0072] The matching logic with the highest occurrence frequency in the initial matching logic set is selected as the target matching logic.

[0073] The historical field set can be stored in a preset database, and the historical field set whose similarity with the target field exceeds a preset similarity threshold is also the historical field set whose similarity with the vector of the target field exceeds a preset similarity threshold. The historical field in the historical field set can be one or more. Each of the historical fields is correspondingly provided with matching logic, and the matching logic with the highest frequency in the initial matching logic set is selected as the target matching logic, which can avoid the high cost and low efficiency of manually setting matching logic.

[0074] In one embodiment, after selecting the matching logic with the highest frequency in the initial matching logic set as the target matching logic, the method further includes:

[0075] Outputting the target matching logic corresponding to the target field to a preset terminal;

[0076] Monitoring whether the preset terminal outputs a logically correct prompt;

[0077] When the monitoring result indicates that the preset terminal outputs a prompt indicating that the logic is correct, it is determined that the target matching logic is correct.

[0078] The preset terminal may be a terminal used to monitor whether the target matching logic is correct.

[0079] S13, combining the target matching logic according to the hierarchical structure to obtain an assertion instruction set.

[0080] In at least one embodiment of the present application, the target field refers to a field that needs to be asserted, and for each target field, there is a corresponding target matching logic. The target statement can be a statement in JSON format, and the target statement contains several fields that need to be asserted. There is a hierarchical structure between the target fields of the target statement, that is, there is a hierarchical structure between the target matching logics. The target matching logics are combined according to the hierarchical structure to obtain an assertion instruction set. The assertion instruction set contains an assertion instruction corresponding to each target field.

[0081] Optionally, combining the target matching logic according to the hierarchical structure to obtain an assertion instruction set includes:

[0082] Acquire the structural relationship between the target fields according to the hierarchical structure;

[0083] Traversing the mapping relationship between the preset fields and the matching logic according to the target field to obtain the target matching logic corresponding to the target field;

[0084] The target matching logic is combined according to the structural relationship to obtain an assertion instruction set.

[0085] In which, combining the structural relationships between the target fields can obtain the hierarchical structure, and a mapping relationship exists between the target fields and the target matching logic. By traversing the mapping relationship, the target matching logic corresponding to the target field can be obtained. The present application can achieve the same structural relationship between the target matching logic and the target fields by combining the target matching logic according to the structural relationship, that is, ensuring that the structural relationship of the target matching logic is consistent with the format of the response data, which can improve the efficiency of assertion processing. In one embodiment, the target fields all contain corresponding field values. Combining the field values with the target matching logic can obtain an assertion instruction, and multiple assertion instructions constitute an assertion instruction set. For example, for the target field "userName": "Zhang San", "Zhang San" can be the field value of the target field, and the target matching logic corresponding to the target field is equal to. Combining the field value with the target matching logic results in an assertion instruction that "userName" is equal to Zhang San. The target matching logic can include but is not limited to: contains, does not contain, equal to, not equal to, regular matching, etc.

[0086] S14, obtaining response data corresponding to the target field and a target assertion instruction corresponding to the target field.

[0087] In at least one embodiment of the present application, the response data refers to the data corresponding to the target field obtained from a preset database, and for each target field, there is corresponding response data. In one embodiment, the target field is a JSON string, and the JSON string input by the user is deeply traversed, and for each field in the user JSON string, the value in the corresponding response data JSON is obtained. Exemplarily, the parameter corresponding to the target field input by the user is user_json, and the response data is res_json, then the currently traversed value is user_json["data"]["userInfo"]["userName"], then the response data is res_json["data"]["userInfo"]["userName"], and the above two sets of data are compared.

[0088] In one embodiment, a mapping relationship exists between the target field and the response data. By querying the mapping relationship, the response data corresponding to the target field can be obtained from the preset database. The assertion instruction set includes a plurality of assertion instructions, each of which corresponds to a target field. In one embodiment, an association relationship also exists between the target field and the assertion instructions. By querying the association relationship, the target assertion instruction corresponding to the target field can be obtained.

[0089] Optionally, obtaining the response data corresponding to the target field and the target assertion instruction corresponding to the target field includes:

[0090] Obtaining a first mapping relationship between a preset field and response data;

[0091] Traversing the first mapping relationship according to the target field to obtain response data corresponding to the target field;

[0092] Obtaining a second mapping relationship between a preset field and an assertion instruction;

[0093] The second mapping relationship is traversed according to the target field to obtain a target predicate instruction corresponding to the target field.

[0094] S15, detecting whether the response data satisfies the target assertion instruction. When the detection result is that the response data does not satisfy the target assertion instruction, executing step S16.

[0095] In at least one embodiment of the present application, the target assertion instruction can be regarded as an expected value, and the response data can be regarded as an actual value. By comparing the target assertion instruction with the response data, the actual value is compared with the expected value. When the detection result is that the actual value is consistent with the expected value, an assertion success result is returned; when the detection result is that the actual value is inconsistent with the expected value, an assertion failure result is returned.

[0096] Optionally, detecting whether the response data satisfies the target assertion instruction includes:

[0097] Detecting whether the response data is identical to the target assertion instruction;

[0098] When the detection result is that the response data is identical to the target assertion instruction, it is determined that the response data satisfies the target assertion instruction, and an assertion success result is returned.

[0099] S16, output alarm prompt.

[0100] In at least one embodiment of the present application, when the detection result is that the response data meets the target assertion instruction, an assertion success result is returned; when the detection result is that the response data does not meet the target assertion instruction, an assertion failure result is returned, and an alarm prompt is output to the preset system personnel. The output method may include SMS, email or telephone. In one embodiment, the alarm prompt may be "Does not meet the target assertion instruction, failed", etc., which is not limited here.

[0101] The above-mentioned assertion processing method provided by the embodiment of the present application can reduce the maintenance cost of assertions and improve the efficiency of assertion processing by merging the target matching logic corresponding to each target field in the target statement into an assertion instruction set for processing; in addition, the present application obtains the hierarchical relationship corresponding to the target statement input by the user, and combines the target matching logic corresponding to several fields in the target statement according to the hierarchical relationship, thereby ensuring that the structural relationship of the target matching logic is consistent with the format of the response data, and can quickly compare the response data with the target assertion instruction, thereby improving the efficiency of assertion processing. The present application can be applied to various functional modules of smart cities such as smart government affairs and smart transportation, such as the assertion processing module of smart government affairs, etc., and can promote the rapid development of smart cities.

[0102] Figure 2 This is a structural diagram of the assertion processing device provided in Example 2 of the present application.

[0103] In some embodiments, the assertion processing device 20 may include a plurality of functional modules composed of computer program segments. The computer program of each program segment in the assertion processing device 20 may be stored in a memory of a computer device and executed by at least one processor to perform (see Figure 1 Description) assertion processing functionality.

[0104] In this embodiment, the assertion processing device 20 can be divided into multiple functional modules according to the functions it performs. The functional modules may include: a hierarchy acquisition module 201, a logic determination module 202, an assertion combination module 203, an assertion acquisition module 204, a result comparison module 205, and an alarm output module 206. The module referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can perform fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0105] The hierarchical acquisition module 201 is used to acquire and parse a target sentence input by a user to obtain a hierarchical structure corresponding to the target sentence.

[0106] In at least one embodiment of the present application, the assertion processing method can be applied to the interface testing process. Interface testing refers to a test of the interface between system components. Interface testing is mainly used to detect whether there are anomalies in the interaction points between the external system and the system and between the internal subsystems. The focus of the test is to check the data exchange, transmission and control management process. In one embodiment, the target statement can be a statement in JSON format. The target statement contains several fields that need to be asserted. The number of fields can be 1 or more, and there is no limit here. The target statement can be a code language set by the system personnel for the target interface. The target interface is an interface of the application software that needs to be tested. The application software that needs to be tested can be installed in a computer device. The target statement is written according to a preset hierarchical structure. By deeply parsing the target statement, the hierarchical structure corresponding to the target statement can be obtained. The hierarchical structure is an organizational structure of each field in the target statement, which is used to isolate the hierarchical functions corresponding to each field.

[0107] Optionally, acquiring and parsing a target sentence input by a user to obtain a hierarchical structure corresponding to the target sentence includes:

[0108] Parsing the target sentence and detecting whether the target sentence contains preset level keywords;

[0109] When the detection result is that the target sentence contains the preset level keywords, obtaining the hierarchical order of the preset level keywords in the target sentence;

[0110] The preset hierarchical keywords are combined according to the hierarchical order to obtain a hierarchical structure corresponding to the target sentence.

[0111] The preset hierarchical keywords refer to keywords pre-set by system personnel to represent hierarchical relationships. For example, the preset hierarchical keywords may include, but are not limited to, keywords such as data, userInfo, and userName. The preset hierarchical keywords are stored in a preset database. Considering the reliability and privacy of data storage, the preset database may be a target node in the blockchain. The hierarchical order refers to the order in which the preset hierarchical keywords appear in the target sentence. Generally speaking, higher-level preset hierarchical keywords appear before lower-level preset hierarchical keywords. By extracting the preset hierarchical keywords according to the hierarchical order, the hierarchical structure corresponding to the target sentence can be obtained.

[0112] The logic determination module 202 is used to determine target matching logic corresponding to several target fields in the target sentence.

[0113] In at least one embodiment of the present application, the target statement may be a statement in JSON format, and the target statement may contain several fields that need to be asserted. The number of fields may be one or more, and is not limited here. The field value of the target field supports variable replacement. In one embodiment, the variable source may be configured as: database return value, request data, specified function return value, etc. The target field refers to a field that needs to be asserted, and for each target field, there is a corresponding target matching logic. In one embodiment, the target matching logic may include but is not limited to: contains, does not contain, equal to, not equal to, regular matching, etc. The target matching logic may be pre-set by system personnel for each field, or it may be predicted by deep learning. The target matching logic is a text in a string format, and the string format may be a JSON string format.

[0114] Optionally, determining target matching logic corresponding to the target fields in the target sentence includes:

[0115] Obtaining several target fields in the target sentence;

[0116] Determining a set of historical fields whose similarity to the target field exceeds a preset similarity threshold;

[0117] Obtaining the initial matching logic corresponding to each historical field in the historical field set to obtain an initial matching logic set;

[0118] The matching logic with the highest occurrence frequency in the initial matching logic set is selected as the target matching logic.

[0119] The historical field set can be stored in a preset database, and the historical field set determined to have a similarity with the target field exceeding a preset similarity threshold is also the historical field set determined to have a vector similarity with the target field exceeding a preset similarity threshold. The historical fields in the historical field set can be one or more. Each of the historical fields is provided with a corresponding matching logic, and the matching logic with the highest frequency in the initial matching logic set is selected as the target matching logic, which can avoid the problems of high cost and low efficiency of manually setting matching logic. In one embodiment, after selecting the matching logic with the highest frequency in the initial matching logic set as the target matching logic, the method further includes: outputting the target matching logic corresponding to the target field to a preset terminal; monitoring whether the preset terminal outputs a prompt that the logic is correct; and when the monitoring result shows that the preset terminal outputs a prompt that the logic is correct, determining that the target matching logic is correct. The preset terminal can be a terminal used to monitor whether the target matching logic is correct.

[0120] The assertion combination module 203 is used to combine the target matching logic according to the hierarchical structure to obtain an assertion instruction set.

[0121] In at least one embodiment of the present application, the target field refers to a field that needs to be asserted, and for each target field, there is a corresponding target matching logic. The target statement can be a statement in JSON format, and the target statement contains several fields that need to be asserted. There is a hierarchical structure between the target fields of the target statement, that is, there is a hierarchical structure between the target matching logics. The target matching logics are combined according to the hierarchical structure to obtain an assertion instruction set. The assertion instruction set contains assertion instructions corresponding to each target field.

[0122] Optionally, combining the target matching logic according to the hierarchical structure to obtain an assertion instruction set includes:

[0123] Acquire the structural relationship between the target fields according to the hierarchical structure;

[0124] Traversing the mapping relationship between the preset fields and the matching logic according to the target field to obtain the target matching logic corresponding to the target field;

[0125] The target matching logic is combined according to the structural relationship to obtain an assertion instruction set.

[0126] Among them, combining the structural relationship between the target fields can obtain the hierarchical structure, and there is a mapping relationship between the target field and the target matching logic. By traversing the mapping relationship, the target matching logic corresponding to the target field can be obtained. The present application can achieve the same structural relationship between the target matching logic and the target field by combining the target matching logic according to the structural relationship, that is, ensuring that the structural relationship of the target matching logic is consistent with the format of the response data, which can improve the efficiency of assertion processing.

[0127] The assertion acquisition module 204 is configured to acquire response data corresponding to the target field and a target assertion instruction corresponding to the target field.

[0128] In at least one embodiment of the present application, the response data refers to the data corresponding to the target field obtained from a preset database, and for each target field, there is corresponding response data. In one embodiment, the target field is a JSON string, and the JSON string input by the user is deeply traversed, and for each field in the user JSON string, the value in the corresponding response data JSON is obtained. Exemplarily, the parameter corresponding to the target field input by the user is user_json, and the response data is res_json, then the currently traversed value is user_json["data"]["userInfo"]["userName"], then the response data is res_json["data"]["userInfo"]["userName"], and the above two sets of data are compared.

[0129] In one embodiment, a mapping relationship exists between the target field and the response data. By querying the mapping relationship, the response data corresponding to the target field can be obtained from the preset database. The assertion instruction set includes a plurality of assertion instructions, each of which corresponds to a target field. In one embodiment, an association relationship also exists between the target field and the assertion instructions. By querying the association relationship, the target assertion instruction corresponding to the target field can be obtained.

[0130] Optionally, obtaining the response data corresponding to the target field and the target assertion instruction corresponding to the target field includes:

[0131] Obtaining a first mapping relationship between a preset field and response data;

[0132] Traversing the first mapping relationship according to the target field to obtain response data corresponding to the target field;

[0133] Obtaining a second mapping relationship between a preset field and an assertion instruction;

[0134] The second mapping relationship is traversed according to the target field to obtain a target predicate instruction corresponding to the target field.

[0135] The result comparison module 205 is used to detect whether the response data satisfies the target assertion instruction.

[0136] In at least one embodiment of the present application, the target assertion instruction can be regarded as an expected value, and the response data can be regarded as an actual value. By comparing the target assertion instruction with the response data, the actual value is compared with the expected value. When the detection result is that the actual value is consistent with the expected value, an assertion success result is returned; when the detection result is that the actual value is inconsistent with the expected value, an assertion failure result is returned.

[0137] Optionally, detecting whether the response data satisfies the target assertion instruction includes:

[0138] Detecting whether the response data is identical to the target assertion instruction;

[0139] When the detection result is that the response data is identical to the target assertion instruction, it is determined that the response data satisfies the target assertion instruction, and an assertion success result is returned.

[0140] The alarm output module 206 is configured to output an alarm prompt when a detection result shows that the comparison result does not satisfy the target assertion instruction.

[0141] In at least one embodiment of the present application, when the detection result is that the response data meets the target assertion instruction, an assertion success result is returned; when the detection result is that the response data does not meet the target assertion instruction, an assertion failure result is returned, and an alarm prompt is output to the preset system personnel. The output method may include SMS, email or telephone. In one embodiment, the alarm prompt may be "Does not meet the target assertion instruction, failed", etc., which is not limited here.

[0142] See Figure 3 FIG. 3 is a schematic diagram of the structure of a computer device according to Embodiment 3 of the present application. In a preferred embodiment of the present application, the computer device 3 includes a memory 31 , at least one processor 32 , at least one communication bus 33 and a transceiver 34 .

[0143] Those skilled in the art should understand that Figure 3 The structure of the computer device shown does not constitute a limitation of the embodiments of the present application. It can be a bus structure or a star structure. The computer device 3 can also include more or less other hardware or software than shown in the figure, or a different component arrangement.

[0144] In some embodiments, the computer device 3 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices. The computer device 3 may also include client devices, which include, but are not limited to, any electronic product capable of human-computer interaction with a client via a keyboard, mouse, remote control, touchpad, or voice-controlled device, such as a personal computer, tablet computer, smartphone, digital camera, etc.

[0145] It should be noted that the computer device 3 is only an example. Other existing or future electronic products that are suitable for this application should also be included in the scope of protection of this application and included here by reference.

[0146] In some embodiments, the memory 31 stores a computer program that implements all or part of the steps in the assertion processing method when executed by the at least one processor 32. The memory 31 includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.

[0147] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.

[0148] The blockchain referred to in this application is a new application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.

[0149] In some embodiments, the at least one processor 32 is the control core (Control Unit) of the computer device 3, which uses various interfaces and lines to connect the various components of the entire computer device 3, and executes various functions and processes data of the computer device 3 by running or executing the program or module stored in the memory 31, and calling the data stored in the memory 31. For example, when the at least one processor 32 executes the computer program stored in the memory, it implements all or part of the steps of the assertion processing method described in the embodiment of the present application; or implements all or part of the functions of the assertion processing device. The at least one processor 32 can be composed of an integrated circuit, for example, it can be composed of a single packaged integrated circuit, or it can be composed of multiple integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors and a combination of various control chips.

[0150] In some embodiments, the at least one communication bus 33 is configured to implement connection and communication between the memory 31 and the at least one processor 32 .

[0151] Although not shown, the computer device 3 may also include a power supply (such as a battery) to power various components. Preferably, the power supply can be logically connected to the at least one processor 32 via a power management device, so that the power management device can manage charging, discharging, and power consumption. The power supply may also include one or more DC or AC power supplies, a recharging device, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components. The computer device 3 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.

[0152] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, computer device, or network device, etc.) or a processor to execute part of the method described in each embodiment of the present application.

[0153] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the module division is only a logical function division, and other division methods may be used in actual implementation.

[0154] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, and may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of this embodiment based on actual needs.

[0155] In addition, the functional modules in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0156] It is obvious to those skilled in the art that the present application is not limited to the details of the above-mentioned exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic characteristics of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes that fall within the meaning and scope of the equivalent elements of the claims are included in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "including" does not exclude other units or, and the singular does not exclude the plural. Multiple units or devices stated in the specification may also be implemented by one unit or device through software or hardware. Words such as first, second, etc. are used to indicate names and do not indicate any particular order.

[0157] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit the present application. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present application.

Claims

1. An assertion processing method, characterized in that: The assertion processing method includes: Obtain and parse the target sentence input by the user to obtain the hierarchical structure corresponding to the target sentence; Determine target matching logic corresponding to a plurality of target fields in the target sentence; Combining the target matching logic according to the hierarchical structure to obtain an assertion instruction set; Obtaining response data corresponding to the target field and a target assertion instruction corresponding to the target field; Detecting whether the response data satisfies the target assertion instruction; When the detection result is that the response data does not meet the target assertion instruction, output an alarm prompt; The determining of target matching logic corresponding to the target fields in the target sentence includes: Obtaining several target fields in the target sentence; Determining a set of historical fields whose similarity to the target field exceeds a preset similarity threshold; Obtaining the initial matching logic corresponding to each historical field in the historical field set to obtain an initial matching logic set; The matching logic with the highest occurrence frequency in the initial matching logic set is selected as the target matching logic.

2. The assertion processing method according to claim 1, characterized in that: Acquiring and parsing the target sentence input by the user to obtain the hierarchical structure corresponding to the target sentence includes: Parsing the target sentence and detecting whether the target sentence contains preset level keywords; When the detection result is that the target sentence contains the preset level keywords, obtaining the hierarchical order of the preset level keywords in the target sentence; The preset hierarchical keywords are combined according to the hierarchical order to obtain a hierarchical structure corresponding to the target sentence.

3. The assertion processing method according to claim 1, wherein: Combining the target matching logic according to the hierarchical structure to obtain an assertion instruction set includes: Acquire the structural relationship between the target fields according to the hierarchical structure; Traversing the mapping relationship between the preset fields and the matching logic according to the target field to obtain the target matching logic corresponding to the target field; The target matching logic is combined according to the structural relationship to obtain an assertion instruction set.

4. The assertion processing method according to claim 1, wherein: The obtaining of the response data corresponding to the target field and the target assertion instruction corresponding to the target field includes: Obtaining a first mapping relationship between a preset field and response data; Traversing the first mapping relationship according to the target field to obtain response data corresponding to the target field; Obtaining a second mapping relationship between a preset field and an assertion instruction; The second mapping relationship is traversed according to the target field to obtain a target predicate instruction corresponding to the target field.

5. The assertion processing method according to claim 1, characterized in that: The detecting whether the response data satisfies the target assertion instruction includes: Detecting whether the response data is identical to the target assertion instruction; When the detection result is that the response data is identical to the target assertion instruction, it is determined that the response data satisfies the target assertion instruction, and an assertion success result is returned.

6. The assertion processing method according to claim 1, characterized in that: After selecting the matching logic with the highest frequency in the initial matching logic set as the target matching logic, the method further includes: Outputting the target matching logic corresponding to the target field to a preset terminal; Monitoring whether the preset terminal outputs a logically correct prompt; When the monitoring result indicates that the preset terminal outputs a prompt indicating that the logic is correct, it is determined that the target matching logic is correct.

7. An assertion processing device, characterized in that: The assertion processing device comprises: A hierarchical acquisition module is used to acquire and parse the target sentence input by the user to obtain the hierarchical structure corresponding to the target sentence; A logic determination module, configured to determine target matching logic corresponding to a plurality of target fields in the target sentence; An assertion combination module, configured to combine the target matching logic according to the hierarchical structure to obtain an assertion instruction set; An assertion acquisition module, configured to acquire response data corresponding to the target field and a target assertion instruction corresponding to the target field; A result comparison module, configured to detect whether the response data satisfies the target assertion instruction; An alarm output module is used to output an alarm prompt when the detection result shows that the response data does not meet the target assertion instruction; The determining of target matching logic corresponding to the target fields in the target sentence includes: Obtaining several target fields in the target sentence; Determining a set of historical fields whose similarity to the target field exceeds a preset similarity threshold; Obtaining the initial matching logic corresponding to each historical field in the historical field set to obtain an initial matching logic set; The matching logic with the highest occurrence frequency in the initial matching logic set is selected as the target matching logic.

8. A computer device, characterized in that: The computer device includes a processor, and the processor is configured to implement the assertion processing method according to any one of claims 1 to 6 when executing a computer program stored in a memory.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the assertion processing method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Interface test method, device, equipment and storage medium

    CN110990250A

  • Test script assertion generation method and device

    CN112860585A