REST interface consistency test result evaluation method and device

By evaluating the syntax and semantics of the REST interface test result file and using the target mapping relationship for automated evaluation, the problems of low accuracy and efficiency of manual evaluation in the existing technology are solved, multi-dimensional evaluation results are achieved, and the accuracy and efficiency of the evaluation are improved.

CN120803908APending Publication Date: 2025-10-17BEIJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510723292.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

The existing REST interface consistency test result evaluation method relies on manual judgment, resulting in low accuracy and efficiency, and uses a single dimension for evaluation, which is not comprehensive enough.

Method used

By parsing the test result files, performing syntax and semantic evaluation based on the target mapping relationship, generating multi-dimensional evaluation results, and using machine automation to execute the evaluation process.

Benefits of technology

A comprehensive evaluation of the REST interface consistency test results is achieved, which improves the accuracy and efficiency of the evaluation and reduces manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803908A_ABST
    Figure CN120803908A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of result judgment, and provides a REST interface consistency test result judgment method and device. The method comprises the following steps: analyzing a test result file of the REST interface to obtain an analysis result of the test result file; based on a target mapping relationship, judging a test result in the test result file analysis result to obtain a judgment result of the consistency test result of the REST interface; the target mapping relation is a mapping relation between a test result and an evaluation result generated based on grammatical evaluation and semantic evaluation of the test result. According to the method and the device, the evaluation process of the test result is obtained by superimposing semantic evaluation on the basis of grammar evaluation, so that multi-dimensional evaluation of the test result can be realized, the comprehensiveness of the evaluation is improved, the whole process is automatically executed by a machine, manual intervention is not needed, and the accuracy and efficiency of the evaluation are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of result evaluation, in particular to a REST interface consistency test result evaluation method and device. BACKGROUND

[0002] REST interface consistency testing is a test that verifies whether the interaction between system components is correct, mainly checking whether the data exchange between the system and external or internal modules meets expectations. It tests the requests and responses of the REST interface to ensure the functionality, reliability, performance and security of the system REST interface, so that the REST interface can work normally in different scenarios. The general process of automated testing includes four parts: preprocessing, test case generation, test case execution and test result evaluation. Among them, test result evaluation is crucial in REST interface testing, as it directly affects the judgment of the quality of the REST interface.

[0003] However, the current evaluation of test results, on the one hand, still relies largely on manual evaluation, which is usually time-consuming and susceptible to human factors, leading to inaccurate evaluation. In addition, as the complexity of the system and the number of REST interfaces increase, the efficiency of manual evaluation cannot meet the demand; on the other hand, it is limited to single-dimensional evaluation, resulting in incomplete evaluation.

[0004] In summary, the current test result evaluation method, on the one hand, has low accuracy and efficiency due to manual evaluation, and on the other hand, is not comprehensive enough due to single-dimensional evaluation. SUMMARY

[0005] The embodiments of the present application provide a REST interface consistency test result evaluation method and device to solve the technical problem of the current test result evaluation method, which is inaccurate and inefficient due to manual evaluation, and not comprehensive enough due to single-dimensional evaluation.

[0006] In a first aspect, the embodiments of the present application provide a REST interface consistency test result evaluation method, comprising: parsing a test result file of a REST interface to obtain a test result file parsing result; evaluating the test results in the test result file parsing result based on a target mapping relationship to obtain an evaluation result of the REST interface consistency test result; The target mapping relationship is a mapping relationship between the test result and the evaluation result generated based on syntax evaluation and semantic evaluation of the test result.

[0007] In one embodiment, the judging the test result in the test result file parsing result based on the target mapping relationship comprises: parsing the interface file and the semantic judgment rule file of the REST interface respectively to obtain an interface file parsing result and a semantic judgment rule file parsing result; judging the test result based on the interface file parsing result; when the syntax judgment is passed, judging the test result based on the semantic judgment rule file parsing result; when the semantic judgment is passed, determining that the judgment result of the REST interface consistency test result is passed.

[0008] In one embodiment, the interface file parsing result comprises response field information and response structure information, and the judging the test result based on the interface file parsing result comprises: determining whether the response code of the test result belongs to the response code defined in the response field information; determining whether the response body type of the test result is consistent with the response body type defined in the response structure information; determining whether the response body field of the test result is one-to-one corresponding to the response body field defined in the response structure information.

[0009] In one embodiment, the semantic judgment rule file parsing result comprises response field value information, response field association information and expected judgment result of a dependent test result, and the judging the test result based on the semantic judgment rule file parsing result comprises: determining whether the actual judgment result of the dependent test result of the test result is consistent with the expected judgment result thereof; determining whether the field value of the test result meets the field value requirement defined in the response field value information; determining whether the fields of the test result meet the association relationship defined in the response field association information.

[0010] In one embodiment, the semantic judgment rule file is generated based on the following steps: generating a semantic judgment rule file template according to the definition of the semantic judgment rule file for the test result based on the interface file parsing result; filling the self-defined modification content into the semantic judgment rule file template to obtain the semantic judgment rule file.

[0011] In one embodiment, the target mapping relationship is presented by introducing a directed graph structure to extend the push-down automaton state.

[0012] In a second aspect, the embodiments of the present application provide a REST interface consistency test result evaluation device, comprising: The file analysis module is configured to analyze the test result file of the REST interface to obtain a test result file analysis result. The result evaluation module is configured to evaluate the test result in the test result file analysis result based on the target mapping relationship to obtain an evaluation result of the consistency test result of the REST interface. The target mapping relationship is a mapping relationship between the test result and the evaluation result generated based on the syntax evaluation and the semantic evaluation of the test result.

[0013] In a third aspect, the embodiments of the present application provide an electronic device, comprising a processor and a memory storing a computer program, wherein the processor implements the steps of the REST interface consistency test result evaluation method of the first aspect when executing the program.

[0014] In a fourth aspect, the embodiments of the present application provide a computer program product, comprising a computer program, wherein the computer program implements the steps of the REST interface consistency test result evaluation method of the first aspect when executed by a processor.

[0015] In a fifth aspect, the embodiments of the present application provide a non-transitory computer readable storage medium, comprising a computer program, wherein the computer program implements the steps of the REST interface consistency test result evaluation method of the first aspect when executed by a processor.

[0016] The REST interface consistency test result evaluation method and device provided by the application analyze a test result file of a REST interface, obtain a test result file analysis result, evaluate a test result in the test result file analysis result based on a target mapping relationship, and obtain an evaluation result of a consistency test result of the REST interface, wherein the target mapping relationship is a mapping relationship between a test result and an evaluation result generated based on syntax evaluation and semantic evaluation of the test result. The application first analyzes the test result file, so that the specific test result can be obtained from the test result file analysis result, and then the test result is evaluated based on the target mapping relationship to obtain the evaluation result corresponding to the test result. The evaluation result is the evaluation result of the consistency test result of the REST interface corresponding to the test result. Since the target mapping relationship is generated based on the syntax evaluation and the semantic evaluation of the test result, the evaluation process of the test result is based on the syntax evaluation and the semantic evaluation, so that multi-dimensional evaluation of the test result can be realized, the comprehensiveness of the evaluation is improved, the whole process is automatically executed by a machine without human intervention, and the accuracy and efficiency of the evaluation are improved. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0018] Figure 1 FIG. 1 is one of the flow diagrams of the REST interface consistency test result evaluation method provided by the embodiments of the application; Figure 2 FIG. 2 is another of the flow diagrams of the REST interface consistency test result evaluation method provided by the embodiments of the application; Figure 3 FIG. 3 is a state transition diagram of a push-down automaton model based on state extension provided by the embodiments of the application; Figure 4 FIG. 4 is a structural diagram of the REST interface consistency test result evaluation device provided by the embodiments of the application; Figure 5 FIG. 5 is a structural diagram of the electronic device provided by the embodiments of the application. DETAILED DESCRIPTION

[0019] In order to make the objects, technical solutions and advantages of the present application clearer, the following will clearly and completely describe the technical solutions in the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall into the protection scope of the present application.

[0020] It should be noted that in the description of the embodiments of the present application, the terms "comprise", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment comprising a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or equipment. Without more limitation, the element defined by the sentence "comprises a" does not exclude the presence of other identical elements in the process, method, article or equipment comprising the element. The terms "upper", "lower" and the like indicate the orientation or positional relationship shown in the drawings, and are only used to facilitate the description of the present application and simplify the description, and do not indicate or imply that the indicated device or element must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation on the present application. Unless otherwise specified and limited, the terms "mount", "connect", "connect" should be understood broadly, for example, it can be fixedly connected, or it can be detachably connected, or integrally connected; it can be mechanically connected, or it can be electrically connected; it can be directly connected, or it can be indirectly connected through an intermediate medium, or it can be the communication between two elements. For those of ordinary skill in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.

[0021] The terms "first", "second" and the like in the present application are used to distinguish similar objects, and are not used to describe a particular order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than that illustrated or described herein, and the objects distinguished by "first", "second" and the like are generally of a kind and do not limit the number of objects, for example, the first object can be one or more. In addition, "and / or" means at least one of the connected objects, and the character " / ", generally means that the front and rear associated objects are in an "or" relationship.

[0022] REST (Representational State Transfer) is a software architecture style that defines design principles for communication between network systems, especially for web services. Its core idea is to abstract information resources in the network and operate resources through a unified interface. REST is based on HTTP (HyperText Transfer Protocol) and can effectively manage and transmit network resources, providing a simple and universal way to access resources. It uses HTTP methods (such as GET, POST, PUT, DELETE) to operate resources and requires stateless communication, so that each request contains necessary information. REST architecture has the characteristics of simplicity, efficiency, flexibility, and scalability, and has been widely applied in API (Application Programming Interface) design, web services, and distributed systems. The embodiments of the present application take REST interface as an example for illustration.

[0023] Figure 1 is one of the process diagrams of the REST interface consistency test result evaluation method provided by the embodiments of the present application; with reference to Figure 1 The embodiments of the present application provide a REST interface consistency test result evaluation method, which can include: 101. Analyzing the test result file of the REST interface to obtain a test result file analysis result; 102. Based on the target mapping relationship, evaluating the test results in the test result file analysis result to obtain an evaluation result of the consistency test result of the REST interface.

[0024] The target mapping relationship is a mapping relationship between the test result and the evaluation result generated based on the syntax evaluation and semantic evaluation of the test result.

[0025] In step 101, the test result file includes test results that need to be evaluated, but the test result file needs to be parsed first to obtain the test results.

[0026] In step 102, the target mapping relationship can be used to guide the evaluation of the test results, for example, first performing syntax evaluation and then performing semantic evaluation.

[0027] It should be noted that after the test result file is parsed, if there is only one test result in the parsing result, the test result is judged based on the target mapping relationship, the judgment result of the test result is obtained, and then the judgment result file is output. The judgment result is the judgment result of the consistency test result of the REST interface corresponding to the test result; if there are multiple test results in the parsing result, each test result is judged in turn based on the target mapping relationship until the judgment results of all test results are obtained, and then the judgment result file is output. The judgment result is the judgment result of the consistency test result of the REST interface corresponding to all test results; the judgment result includes pass or fail, which is represented as pass or failed respectively.

[0028] The REST interface consistency test result judgment method provided by the embodiment analyzes the test result file to obtain a test result file parsing result, judges the test result in the test result file parsing result based on a target mapping relationship, and obtains a judgment result of the consistency test result of the REST interface. The target mapping relationship is a mapping relationship between the test result and the judgment result generated based on the syntax judgment and the semantic judgment of the test result. The test result file is first parsed in the application, and then the specific test result can be obtained from the test result file parsing result. The test result is judged based on the target mapping relationship to obtain the judgment result corresponding to the test result. The judgment result is the judgment result of the consistency test result of the REST interface corresponding to the test result. Since the target mapping relationship is generated based on the syntax judgment and the semantic judgment of the test result, the judgment process of the test result is based on the syntax judgment and the semantic judgment. Therefore, the multi-dimensional judgment of the test result can be realized, the comprehensiveness of the judgment is improved, the whole process is automatically executed by the machine, and manual intervention is not required, thereby improving the accuracy and efficiency of the judgment.

[0029] Figure 2 is a flowchart of the REST interface consistency test result judgment method provided by the embodiment of the application; refer to Figure 2 In one embodiment, the test result in the test result file parsing result is judged based on the target mapping relationship to obtain the judgment result of the consistency test result of the REST interface, which can include: 201, respectively analyze the interface file and the semantic judgment rule file of the REST interface to obtain the interface file parsing result and the semantic judgment rule file parsing result; 202, judging the syntax of the test result based on the interface file parsing result; 203, when the syntax judgment is passed, the semantic judgment of the test result is performed based on the semantic judgment rule file parsing result; 204、In the case of passing the semantic judgment, the judgment result of the REST interface consistency test result is determined as passing.

[0030] In step 201, the interface file is a REST interface file conforming to the OpenAPI 3.0 specification, which provides REST interface information of the system under test, and the semantic judgment rule file covers various rule definitions for semantic judgment of the test result.

[0031] In steps 202 to 204, the test result is checked for syntax by using the interface file parsing result. If the syntax check fails, the judgment result of the test result is directly determined as failing, i.e., the judgment result of the REST interface consistency test result is determined as failing. If the syntax check passes, the test result is checked for semantics based on the semantic judgment rule file parsing result. If the semantic check fails, the judgment result of the test result is determined as failing, i.e., the judgment result of the REST interface consistency test result is determined as failing. If the semantic check passes, the judgment result of the test result is determined as passing, i.e., the judgment result of the REST interface consistency test result is determined as passing.

[0032] In this embodiment, the interface file and the semantic judgment rule file are parsed first, and then the test result is checked for syntax and semantics in sequence by using the parsing results. Since the syntax check is relatively simple compared with the semantic check, the syntax check is performed first, and the judgment result of the test result that fails the syntax check is directly determined as failing, so that subsequent semantic check is not needed. Only the test result that passes the syntax check is checked for semantics, and the judgment result of the test result that also passes the semantic check is determined as passing. Since the syntax check filters out a part of the test results that fail, the efficiency of the overall judgment of the test result is improved.

[0033] In one embodiment, the interface file parsing result includes response field information and response structure information. Based on the interface file parsing result, the test result is checked for syntax, which can include: 1. determining whether the response code of the test result belongs to the response code defined in the response field information; 2. determining whether the response body type of the test result is consistent with the response body type defined in the response structure information; 3. determining whether the response body fields of the test result one by one correspond to the response body fields defined in the response structure information.

[0034] The response code of the test result can be checked first. If the response code is not one of the response code defined in the response field information, it is determined that the syntax check fails. If the response code is one of the response code defined in the response field information, the response body type of the test result is checked. If the response body type is not consistent with the response body type defined in the response structure information, it is determined that the syntax check fails. If the response body type is consistent with the response body type defined in the response structure information, the response body field of the test result is checked. If the response body field is not one-to-one corresponding to the response body field defined in the response structure information, it is determined that the syntax check fails. If the response body field is one-to-one corresponding to the response body field defined in the response structure information, it is determined that the syntax check passes, and the semantic check stage is entered.

[0035] In the syntax check of the test result, the response code check, the response body type check and the response body field check are sequentially performed, so that the comprehensive syntax check of the test result is realized, and when each syntax check fails, the subsequent syntax check is not performed, so that the efficiency of the syntax check is improved.

[0036] In an embodiment, the semantic judgment rule file parsing result includes response field value information, response field association information and expected judgment result of the dependent test result, and the semantic judgment of the test result based on the semantic judgment rule file parsing result can include: 1. determining whether the actual judgment result of the dependent test result of the test result is consistent with the expected judgment result thereof; 2. determining whether the field value of the test result meets the field value requirement defined in the response field value information; 3. determining whether the fields of the test result meet the association relationship defined in the response field association information.

[0037] The actual judgment result of the dependent test result of the test result can be checked first. If the actual judgment result is not equal to the expected judgment result, it is determined that the semantic check fails. If the actual judgment result is equal to the expected judgment result, the field value of the test result is checked. If the field value does not meet the field value requirement defined in the response field value information, such as the format requirement, the range requirement, the enumeration value requirement and the like, it is determined that the semantic check fails. If the field value meets the field value requirement defined in the response field value information, the association relationship between the fields of the test result defined in the response field association information is checked. If the association relationship does not exist, it is determined that the semantic check fails. If the association relationship exists, it is determined that the semantic check passes, and the judgment result of the test result is determined to pass, that is, the judgment result of the consistency test result of the corresponding REST interface is determined to pass.

[0038] In the semantic check of the test result, the judgment result check of the dependent test result, the field value check of the test result itself and the association relationship check between the fields of the test result are sequentially performed, so that the comprehensive semantic check of the test result is realized, and when each semantic check fails, the subsequent semantic check is not performed, so that the efficiency of the semantic check is improved.

[0039] In one embodiment, the semantic judgment rule file can be generated based on the following steps: Based on the interface file parsing result, a semantic judgment rule file template is generated according to the definition of the semantic judgment rule file for the test result, and the custom modification content is filled into the semantic judgment rule file template to obtain the semantic judgment rule file.

[0040] Specifically, the semantic judgment rule file includes response code rule definition and data semantic rule definition for the test result.

[0041] 1. Response code rule: The rule determines whether the returned response code meets the expectation by verifying the dependency relationship between multiple test results.

[0042] If each REST interface is regarded as a unit, the dependency relationship can be the dependency relationship between methods (within the unit) and interfaces (between units). The core is to determine which method or interface execution result may affect the behavior of other methods or interfaces. Usually, such dependency relationship affects the execution order of test cases and the expected response code returned by subsequent REST interfaces.

[0043] The inter-method dependency relationship refers to the dependency relationship between different methods within the same REST interface. For example, a GET request of a REST interface may depend on the result of a previously executed POST request, and the return result of the GET request may need the POST request to be successful and return certain data to be executed correctly.

[0044] The inter-interface dependency relationship refers to the dependency relationship between different REST interfaces. In REST interface testing, the execution result of some REST interfaces may affect the behavior of other REST interfaces.

[0045] 2. Data semantic rule: The rule includes field value rule and data association relationship rule, mainly describing the semantics of each attribute field in the response body of the test result and the association relationship between the attribute fields, to ensure that the data meets the expected standard and has logical consistency.

[0046] The field value rule is mainly used to describe the semantics of each attribute field in the response body of the test result, mainly including format requirements, range requirements, and enumeration value requirements, etc. Common format requirements include date format, mailbox format, number format, and string format, etc. Range requirements limit the legal range of field values, including numerical range and string range, etc. Numerical range refers to that the field value should be an integer or floating number within a given range, such as 0<=age<=120. String range refers to that the length of the string of the field value must be within a specified range, such as 5<=name.length<=50. Enumeration value requirement refers to that the field value must be selected from a predefined value set, for example, a certain field value can only be "male" or "female", or some specific states such as "unprocessed", "processing", and "completed".

[0047] The data association relationship rule mainly describes the logical association relationship between attribute fields, mainly including linear relationship, multivariate equation set relationship, simple function relationship, set relationship, conditional dependency relationship, and probability relationship, etc. Among them, the linear relationship usually refers to the mathematical dependency relationship between two or more fields, which can be represented by a simple addition or multiplication formula, such as y = ax + b, where a and b are constants, and x and y are field variables. The multivariate equation set relationship involves the mutual dependency of multiple fields, which is usually constrained by multiple equations for multiple field variables, such as x + y = z and ab + c = d, where x, y, z, a, b, c, and d are field variables. The simple function relationship describes the dependency relationship between fields through a certain function, such as square, logarithm, etc., such as or where x and y are field variables. The set relationship focuses on whether the field value belongs to a specific set or the relationship between sets, such as field1 in {1, 2, 3}, which means the value of field field1 must be an element in the set {1, 2, 3}. The conditional dependency relationship describes the logical dependency between fields under certain conditions, for example, when status = "processing", the processingTime field cannot be null. The probability relationship involves the probabilistic dependency between fields, which is usually represented as conditional probability or distributed probability relationship, for example, P(y>10 | x = 1) = 0.9, which means the probability of y being greater than 10 under the condition of x = 1 is 0.9, where x and y are field variables.

[0048] The semantic evaluation rules of the REST interface test results can be defined formally using BNF (Backus-Naur Form). The formal definition is mainly divided into lexical definition and grammar definition. The lexical definition part mainly defines the fixed composition method of the lexicon, including the composition form of uppercase and lowercase letters, numbers, etc., and some fixed symbol representation, as shown in Table 1: Table 1 Lexical definition of semantic evaluation rules On the basis of the lexical definition, the semantic evaluation rules are defined grammatically. The test results of all REST interfaces are composed of test results of specific REST interfaces, and the test results of a specific REST interface are composed of test results of all methods contained in the REST interface. For the test results of a specific method under a specific REST interface, the definition of response code and data semantics is included, as shown in Table 2: Table 2 Grammar definition of semantic evaluation rules For the definition of the dependent relationship in the response code rule, including the definition of the inter-method dependent relationship and the inter-interface dependent relationship and their contents, as shown in Table 3: Table 3 Grammar definition of dependent relationship in response code rule

[0049] For the field value rule definition in the data semantic rule, including the data model of the attribute field itself, such as value range, value rule, special value, etc., as shown in Table 4: Table 4 Grammar definition of field value rule in data semantic rule

[0050] For the data association relationship rule definition in the data semantic rule, including the regular operations of addition, subtraction, multiplication, division, remainder, absolute value, etc., trigonometric function operations, exponential and logarithmic operations, etc., all of which are expanded with basic elements such as letters, numbers, variable names, etc., as shown in Table 5: Table 5 Grammar definition of data association relationship rule in data semantic rule The embodiment defines a plurality of semantic judgment rules of test results, including response code rule definition and data semantic rule definition. Through formal definition, the response code semantics and data semantics of the test results can be accurately and concisely described when the syntax check of the test results may cause misjudgment, so as to ensure the accuracy of the semantic check, and further improve the accuracy of the test result judgment.

[0051] In one embodiment, the target mapping relationship is presented by introducing a directed graph structure to expand the push-down automaton state. Specifically, the push-down automaton model can be defined as EVA, and the following is obtained: ; The following explains each symbol in the model one by one: 1、 Definition: is a finite state set, which is defined as follows: ; wherein, is the initial state, is the state for obtaining the parsing result of the test result file, is the state for obtaining the parsing result of the REST interface file, is the state for obtaining the parsing result of the semantic judgment rule file, is the test result judgment state, is the terminal state.

[0052] When the test result is judged, the syntax check is first performed according to the parsing result of the REST interface file. After the syntax check is passed, the semantic check is performed according to the parsing result of the semantic judgment rule file. Therefore, the state is further divided into two states, i.e., the syntax check state and the semantic check state : ; In the semantic check state, it is further divided into the response code check state and the data semantic check state , i.e.: The ordinary push-down automaton model cannot describe the dependency relationship between the test results. Therefore, the simple state of the push-down automaton model is expanded to describe the dependency relationship between the test results, which is realized by introducing a directed graph structure. The state transition of the state-expanded push-down automaton model can describe the judgment process of the test results, and the state-expanded dependency relationship graph can describe the dependency relationship between the test results. The state transition graph is shown in FIG. 3.

[0053] In the state-expanded push-down automaton model, each state contains the following content: ; Among them, represents the current state, , represents the top symbol of the stack, , used to store relevant information in the evaluation process, such as the parsed file of the current file, context information, etc. represents the current input, , is a directed graph introduced when expanding the state, used to describe the dependency relationship between test results, The definition of is as follows: ; Among them, is a node set, representing a node in the directed graph, i.e. each test result, is an edge set, as the evaluation of test results needs to combine the response results and evaluation results of dependent test results to evaluate the response code, the edge set needs to be expanded so that it can not only represent the dependency relationship but also carry additional information such as the expected evaluation result of the dependent test result and the type of dependency relationship.

[0054] ; Among them, , represents the dependency relationship from node to node ; , represents the expected evaluation result (pass or fail) of the dependent test result; , represents the type of dependency relationship (inter-method dependency or inter-interface dependency).

[0055] 2、 Definition: is an input set, defined as follows: ; It includes three inputs, namely test result file , REST interface file and semantic evaluation rule file , and also includes a hash table to store the evaluation results of completed test results.

[0056] 3、 Definition: is the stack alphabet of the pushdown automaton model, which contains the information obtained from various inputs during the verification process, including: (1) the test results in the test result file parsing results, denoted as RE; (2) the response field information and response structure information in the REST interface file parsing results, denoted as RP and SC, respectively.

[0057] (3) the response code of the dependent test results in the semantic evaluation rule file parsing results, denoted as CD, the expected evaluation result of the dependent test results, denoted as preRes, the dependency relationship type of the dependent test results, denoted as depType, the response field value information, denoted as VE, and the response field association information, denoted as RL.

[0058] In addition, the initial content of the stack is defined as .

[0059] For the four commonly used request methods, the classification of dependency relationships is shown in Table 6: Table 6 Dependency relationship classification of commonly used request methods

[0060] Among them, the commonly used response codes returned by POST and DELETE and their corresponding expected evaluation results are shown in Table 7: Table 7 Expected evaluation results of dependent methods

[0061] 4、 Definition: is the transition rule between states, which accepts four parameters, namely the current state , the current input , the stack symbol set required for the transition from the current state to the next state , , the directed graph , then The definition of is: ; Based on the above definitions, the rules for syntax checking can be shown in Table 8: Table 8 Syntax checking derivation rules After syntax checking, set RP_check = 1 and SC_check = 1.

[0062] Further, the rules for semantic detection can be shown in Table 9: Table 9 Semantic checking derivation rules Finally, the syntax check and semantic check are combined to obtain the target mapping relationship, as shown in Table 10: Table 10 Mapping relationship of the push-down automaton model based on state expansion The embodiment introduces a directed graph structure to expand the state of the push-down automaton model. In the expanded push-down automaton model, the state transition can describe the judgment process of the test result, and the directed graph can describe the dependency relationship between the test results, so as to adapt to the complexity of the REST interface consistency test result judgment, and to formalize the definition and theoretical derivation of the mapping from the test result to the judgment result, so as to guide the judgment of the test result and improve the accuracy of the judgment.

[0063] In one embodiment, the user order model is used to illustrate the scheme of the present application. The test result in the embodiment is a test response.

[0064] The five operations of POST user (user_id = user_1), POST order (order_id = order_1), GET order (order_id = order_1), PUT order commodity quantity (order_id = order_1), and DELETE order (order_id = order_1) are sequentially executed. Assuming that the information of all test cases is correct, a test response file is obtained; According to the formal definition of the test response semantic judgment rule file, a test response related semantic judgment rule file is obtained in the embodiment; According to the foregoing target mapping relationship, the test response of the GET request is judged: Referring to Figure 3 , the state starts from , which represents inputting the test response file and parsing, and pushing RE in the test response file parsing result into the stack. Then, the node set of the directed graph G can be constructed according to the ID of the test response, for example, test_01 to test_05 , and the state enters , wherein: ; , which represents continuing to input the REST interface file and parsing, and pushing RP and SC in the interface file parsing result into the stack, and the state enters ; ​ Indicates that the input is empty, pop RP and SC from the stack, and enter Status, based on RP and SC pairs Perform syntax checking. At this time, RE is at the top of the stack and can be used without popping it. It can be expressed as , that is, the input is empty, Keep it in the stack; If the syntax check fails, Indicates that the input is empty and pops from the stack , the stack is empty at this time, enter Status: If the syntax check passes, as shown in Table 11, set RP_check = 1 and SC_check = 1; Table 11 Syntax check derivation process for the test response of a GET request Input semantic judgment rule file And parse to get the semantic judgment rule file parsing results, including , VE, RL, preRes and depType, Indicates that the input Obtained Push into the stack, enter State, construct the edge set E of the directed graph G according to preRes and depType to obtain a complete directed graph, where: ; Indicates that the input is empty, pop CD from the stack and enter State, based on CD's semantic check of the response code of the RE's dependent test response, at this time RE is at the top of the stack and can be used without popping it, which can be expressed as , that is, the input is empty, Keep it in the stack; Response code check is to use the complete directed graph to judge Whether the actual evaluation result of the dependent test response is equal to its expected evaluation result preRes, if not, the response code check fails. Indicates that the input is empty and pops from the stack , the stack is empty at this time, enter Status, if yes, the response code check passed, Indicates that the input The obtained VE and RL are pushed into the stack, Indicates popping VE and RL from the stack and entering State, using VE and RL Data semantic check is performed, at this time, the flow is close to the end, and thus the RE needs to be popped out, which can be represented as , that is, the input is empty, and the RE is popped out from the stack , the semantic check is completed, and the state of is entered. The derivation process of the semantic check of the test response of the GET request is shown in Table 12. Table 12 Derivation process of semantic check of test response of GET request At this time, the judgment of one test response is completed, if there are other test responses that need to be judged, the above steps are repeated until the judgment of all test responses is completed, and the judgment result file is output.

[0065] The REST interface consistency test result judgment device provided in the embodiments of the present application is described below. The REST interface consistency test result judgment device described below can be correspondingly referred to the REST interface consistency test result judgment method described above.

[0066] Figure 4 is a structural schematic diagram of the REST interface consistency test result judgment device provided in the embodiments of the present application. Referring to Figure 4 , the REST interface consistency test result judgment device provided in the embodiments of the present application can include: The file analysis module 401 is configured to: analyze the test result file of the REST interface to obtain a test result file analysis result. It should be noted that the file analysis module 401 is further configured to analyze the interface file and the semantic judgment rule file of the REST interface respectively to obtain an interface file analysis result and a semantic judgment rule file analysis result.

[0067] The result judgment module 402 is configured to: based on a target mapping relationship, judge the test result in the test result file analysis result to obtain a judgment result of the consistency test result of the REST interface. The target mapping relationship is a mapping relationship between the test result and the judgment result generated based on the syntax judgment and the semantic judgment of the test result.

[0068] The REST interface consistency test result evaluation device provided in this embodiment parses the test result file of the REST interface to obtain the test result file parsing result, and based on the target mapping relationship, evaluates the test result in the test result file parsing result to obtain the evaluation result of the consistency test result of the REST interface, wherein the target mapping relationship is a mapping relationship between the test result and the evaluation result generated based on the grammatical evaluation and semantic evaluation of the test result. The present application first parses the test result file, and then obtains the specific test result from the test result file parsing result, and then evaluates the test result based on the target mapping relationship to obtain the evaluation result corresponding to the test result. The evaluation result is the evaluation result of the consistency test result of the REST interface corresponding to the test result. Since the target mapping relationship is generated based on the grammatical evaluation and semantic evaluation of the test result, the evaluation process of the test result is to superimpose the semantic evaluation on the grammatical evaluation, thereby realizing multi-dimensional evaluation of the test result and improving the comprehensiveness of the evaluation. The entire process is automatically executed by the machine without manual intervention, thereby improving the accuracy and efficiency of the evaluation.

[0069] Figure 5 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other via the communication bus 540. The processor 510 may call a computer program in the memory 530 to execute the steps of the REST interface consistency test result evaluation method, for example, including: Parse the test result file of the REST interface to obtain the test result file parsing result; Based on the target mapping relationship, the test results in the test result file parsing result are evaluated to obtain the evaluation result of the consistency test result of the REST interface; The target mapping relationship is a mapping relationship between a test result and an evaluation result generated based on a grammatical evaluation and a semantic evaluation of the test result.

[0070] Further, the logic instructions in the memory 530 described above can be implemented in the form of software functional units and sold or used as independent products, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts of the prior art that make contributions or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0071] In another aspect, the embodiments of the present application also provide a computer program product, which comprises a computer program, the computer program can be stored on a non-transitory computer readable storage medium, and the computer program is executed by a processor, so that the computer can execute the steps of the REST interface consistency test result evaluation method provided by the above-mentioned embodiments, for example, including: parsing a test result file of the REST interface to obtain a test result file parsing result; evaluating the test result in the test result file parsing result based on a target mapping relationship to obtain an evaluation result of the consistency test result of the REST interface; The target mapping relationship is a mapping relationship between the test result and the evaluation result generated based on the syntax evaluation and the semantic evaluation of the test result.

[0072] In another aspect, the embodiments of the present application also provide a non-transitory computer readable storage medium, which stores a computer program, and the computer program is used to make the processor execute the steps of the REST interface consistency test result evaluation method provided by the above-mentioned embodiments, for example, including: parsing a test result file of the REST interface to obtain a test result file parsing result; evaluating the test result in the test result file parsing result based on a target mapping relationship to obtain an evaluation result of the consistency test result of the REST interface; The target mapping relationship is a mapping relationship between the test result and the evaluation result generated based on the syntax evaluation and the semantic evaluation of the test result.

[0073] The non-transitory computer-readable storage medium can be any available medium or data storage device that a processor can access, including but not limited to a magnetic storage (e.g., floppy disks, hard disks, tape, MO, etc.), optical storage (e.g., CD, DVD, BD, HVD, etc.), and semiconductor storage (e.g., ROM, EPROM, EEPROM, NAND FLASH, SSD, etc.), etc.

[0074] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place or distributed to multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment scheme according to actual needs. Those skilled in the art can understand and implement without creative labor.

[0075] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be realized by means of software and necessary general hardware platform, and of course can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of software product, which can be stored in a computer readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including a plurality of instructions to make a computer device (which can be a personal computer, server, or network device, etc.) execute the method described in each embodiment or some part of the embodiment.

[0076] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for judging REST interface consistency test results, characterized in that: include: Parse the test result file of the REST interface to obtain the test result file parsing result; Based on the target mapping relationship, the test results in the test result file parsing result are evaluated to obtain the evaluation result of the consistency test result of the REST interface; The target mapping relationship is a mapping relationship between a test result and an evaluation result generated based on a grammatical evaluation and a semantic evaluation of the test result.

2. The REST interface consistency test result evaluation method according to claim 1, characterized in that: The step of evaluating the test results in the test result file parsing result based on the target mapping relationship to obtain the evaluation result of the consistency test result of the REST interface includes: Parsing the interface file and the semantic evaluation rule file of the REST interface respectively to obtain the interface file parsing result and the semantic evaluation rule file parsing result; Based on the parsing result of the interface file, performing grammatical evaluation on the test result; When the grammatical evaluation passes, performing semantic evaluation on the test result based on the parsing result of the semantic evaluation rule file; When the semantic evaluation is passed, it is determined that the evaluation result of the consistency test result of the REST interface is passed.

3. The REST interface consistency test result evaluation method according to claim 2, characterized in that: The interface file parsing result includes response field information and response structure information. The grammatical evaluation of the test result based on the interface file parsing result includes: Determining whether the response code of the test result belongs to the response code defined in the response field information; Determining whether the response body type of the test result is consistent with the response body type defined in the response structure information; Determine whether the response body fields of the test result correspond one-to-one with the response body fields defined in the response structure information.

4. The REST interface consistency test result evaluation method according to claim 2, characterized in that: The semantic evaluation rule file parsing result includes response field value information, response field association information, and expected evaluation results of dependent test results. The semantic evaluation of the test results based on the semantic evaluation rule file parsing result includes: Determining whether the actual evaluation result of the test result on which the test result is dependent is consistent with the expected evaluation result; Determining whether the field value of the test result meets the field value requirements defined in the response field value information; Determine whether the fields of the test result conform to the association relationship defined in the response field association information.

5. The REST interface consistency test result evaluation method according to claim 2, characterized in that: The semantic evaluation rule file is generated based on the following steps: Based on the parsing result of the interface file, a semantic evaluation rule file template is generated according to the definition of the semantic evaluation rule file for the test result; The custom modified content is filled into the semantic evaluation rule file template to obtain the semantic evaluation rule file.

6. The REST interface consistency test result evaluation method according to claim 1, characterized in that: The target mapping relationship is presented by introducing a directed graph structure to extend the push-down automaton state.

7. A REST interface consistency test result evaluation device, characterized in that: include: The file parsing module is used to: parse the test result file of the REST interface to obtain the test result file parsing result; A result evaluation module is configured to: evaluate the test results in the test result file parsing result based on the target mapping relationship to obtain an evaluation result of the consistency test result of the REST interface; The target mapping relationship is a mapping relationship between a test result and an evaluation result generated based on a grammatical evaluation and a semantic evaluation of the test result.

8. An electronic device comprising a processor and a memory storing a computer program, characterized in that: When the processor executes the computer program, the steps of the REST interface consistency test result evaluation method according to any one of claims 1 to 6 are implemented.

9. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the REST interface consistency test result evaluation method according to any one of claims 1 to 6 are implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the REST interface consistency test result evaluation method according to any one of claims 1 to 6 are implemented.