CN109614309B - Method, device, computer equipment and storage medium for comparing test results - Google Patents

Method, device, computer equipment and storage medium for comparing test results Download PDF

Info

Publication number
CN109614309B
CN109614309B CN201811229393.8A CN201811229393A CN109614309B CN 109614309 B CN109614309 B CN 109614309B CN 201811229393 A CN201811229393 A CN 201811229393A CN 109614309 B CN109614309 B CN 109614309B
Authority
CN
China
Prior art keywords
result
returned
data
expected result
expected
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811229393.8A
Other languages
Chinese (zh)
Other versions
CN109614309A (en
Inventor
庄晓雯
蓝剑锋
刘金萍
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN201811229393.8A priority Critical patent/CN109614309B/en
Publication of CN109614309A publication Critical patent/CN109614309A/en
Application granted granted Critical
Publication of CN109614309B publication Critical patent/CN109614309B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to an automatic test technology, and discloses a method, a device, computer equipment and a storage medium for comparing test results, wherein the method for comparing the test results comprises the following steps: respectively acquiring a return result and an expected result of the interface test from a database according to the keywords, wherein the database is used for storing test data after the interface test; confirming the types of character strings in the data types of the returned result and the expected result, wherein the data types of the returned result and the expected result are consistent, and the data types comprise the character strings; and selecting a corresponding preset comparison rule according to the type of the character string so as to compare the consistency of the returned result and the expected result. According to the application, by matching the comparison rules of different character string types, the automatic comparison of the interface test results is realized, the manual comparison is not needed to judge whether the test results are correct, a great amount of manual comparison time is saved, and the test efficiency and the judgment accuracy are improved.

Description

Method, device, computer equipment and storage medium for comparing test results
Technical Field
The present application relates to the field of testing, and in particular, to a method, apparatus, computer device, and storage medium for comparing test results.
Background
The result comparison of the current interface test is carried out manually to judge whether the test result is correct, the existing test tool does not have the function of automatically comparing and judging whether the actual return and the expected return of the interface are consistent, and when the interface return parameters and the hierarchy are too many, the manual comparison is time-consuming and labor-consuming, and errors are easy to occur. The formats of the returned data after the interface test is finished are various, including String character strings, json formats and the like, and the automatic identification comparison of various formats needs to be supported, wherein the Json formats have a multi-layer nested relation, the parameter sequence returned by each time of calling the interface is possibly inconsistent, and if the whole comparison is carried out, the comparison fails; the return values of some fields such as date and time in the interface return results will be different because the call time is different each time, and if the whole comparison is performed, the whole comparison will also fail. Thus, there is a need for a method that supports automatic comparison of various data types.
Disclosure of Invention
The application mainly aims to provide a method for comparing test results, which aims to solve the technical problems that the comparison of the results of the conventional interface test is carried out by manual comparison and the workload is very large.
The application provides a method for comparing test results, which comprises the following steps:
Respectively acquiring a return result and an expected result of the interface test from a database according to the keywords, wherein the database is used for storing test data after the interface test;
confirming the types of character strings in the data types of the returned result and the expected result, wherein the data types of the returned result and the expected result are consistent, and the data types comprise the character strings;
and selecting a corresponding preset comparison rule according to the type of the character string so as to compare the consistency of the returned result and the expected result.
Preferably, the step of selecting a corresponding preset comparison rule according to the type of the character string to compare the consistency of the returned result and the expected result includes:
respectively analyzing the composition forms of the returned result and the expected result, and judging whether the character String is a String type character String or not;
and if the character String is a String type character String, calling a regular expression to compare the consistency of the returned result and the expected result.
Preferably, the step of calling a regular expression to compare the consistency of the returned result and the expected result includes:
judging whether first data which are obtained after the return result and the expected result are respectively input into the regular expression and correspond to each other one by one is received or not;
If so, comparing whether the first data corresponding to the returned result and the expected result are the same or not;
if the returned result is the same as the expected result, the returned result is judged to be consistent with the expected result, otherwise, the returned result is judged to be inconsistent with the expected result.
Preferably, the step of calling a regular expression to compare the consistency of the returned result and the expected result includes:
judging whether first data which are obtained after the return result and the expected result are respectively input into the regular expression and correspond to each other one by one is received or not;
if not, directly comparing whether the character strings respectively corresponding to the returned result and the expected result are consistent;
if so, judging that the returned result is consistent with the expected result, otherwise, judging that the returned result is inconsistent with the expected result.
Preferably, the step of selecting a corresponding preset comparison rule according to the type of the character string to compare the consistency of the returned result and the expected result includes:
respectively analyzing whether the data structures of the returned result and the expected result have the identifier corresponding to the hierarchical structure of the Json format or not;
if the identifier corresponding to the hierarchical structure of the Json format is provided, judging that the returned result and the expected result are character strings of the Json format;
Converting the Json format corresponding to the returned result and the expected result into a Jsonobiect type;
and comparing the consistency of the returned result and the expected result by calling a recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer corresponding to the Jsonobifect type.
Preferably, the step of comparing the consistency of the returned result and the expected result by calling a recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer according to the Jsonobic type includes:
calling a recursion algorithm to respectively and simultaneously recursion a returned result and an expected result which correspond to the Jsonobifect type layer by layer;
respectively judging whether the type of the character string corresponding to the current recursion layer of the returned result and the expected result is a Jsonobifect type;
if the type of the character string corresponding to the current recursion layer is not Jsonobic type, terminating running the recursion algorithm;
comparing whether the second data corresponding to the current recursion layer respectively corresponding to the returned result and the expected result are the same or not;
if the returned result is the same as the expected result, the returned result is judged to be consistent with the expected result, otherwise, the returned result is judged to be inconsistent with the expected result.
Preferably, before the step of comparing the consistency of the returned result and the expected result by calling the recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer according to the Jsonobic type, the method comprises the following steps:
Judging whether the Jsonobicect type is a JsonARRAY type with data embedding, wherein the JsonARRAY type is an array formed by data of a plurality of Jsonobicect types;
if yes, acquiring data information of all Jsonobifect types in the Jsononarry types, wherein the data information comprises data contents respectively corresponding to the Jsonobifect types and arrangement position information respectively corresponding to the Jsonobifect types;
sorting all Jsonobic type data in the JsonARRAY type according to the arrangement position information and a preset rule;
and sequentially inputting the Jsonobic type data which are sequenced according to the preset rule according to the arrangement position information into the recursion algorithm.
Preferably, the step of obtaining the returned result and the expected result of the interface test from the database according to the keywords respectively includes:
receiving return data of the interface test;
selecting a specified field from the returned data as a returned result according to a task protocol, wherein the specified field is part of data or all data in the returned data;
and extracting an expected result corresponding to the returned result from the database according to the position information of the returned result in the returned data and the key words.
The application also provides a detection device of the scheduling table, which comprises:
the acquisition module is used for respectively acquiring a return result and an expected result of the interface test from a database according to the keywords, wherein the database is used for storing test data after the interface test;
the analysis module is used for confirming the types of the character strings in the data types of the returned result and the expected result, wherein the data types of the returned result and the expected result are consistent, and the data types comprise the character strings;
and the selection module is used for selecting a corresponding preset comparison rule according to the type of the character string so as to compare the consistency of the returned result and the expected result.
The application also provides a computer device comprising a memory storing a computer program and a processor implementing the steps of the above method when executing the computer program.
The application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the method described above.
According to the application, by matching the comparison rules of different character string types, the automatic comparison of the interface test results is realized, whether the test results are correct or not is judged without manual comparison, a great amount of manual comparison time is saved, and the test efficiency and judgment accuracy are improved; according to the application, when the JsonARRAY with the data embedding hierarchical structure is judged, the comparison problem that the parameter return sequence in the interface return result is inconsistent is solved by a method of sequencing and recursion; the application supports automatic comparison of the appointed data fields according to the task protocol user-defined configuration, and can only compare the parameter fields needing to be concerned, thereby improving the comparison efficiency of the test results.
Drawings
FIG. 1 is a flow chart of a method for comparing test results according to an embodiment of the application;
FIG. 2 is a schematic structural diagram of an apparatus for comparing test results according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a selection module according to another embodiment of the present application;
FIG. 4 is a schematic diagram of a call unit according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a call unit according to another embodiment of the present application;
FIG. 6 is a schematic diagram of a selection module according to another embodiment of the present application;
FIG. 7 is a schematic diagram of a comparing unit according to an embodiment of the present application;
FIG. 8 is a schematic diagram of a selection module according to another embodiment of the present application;
FIG. 9 is a schematic diagram of an acquisition module according to an embodiment of the present application;
FIG. 10 is a schematic diagram showing an internal structure of a computer device according to an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
Referring to fig. 1, a method for comparing test results according to an embodiment of the present application includes:
S1: and respectively acquiring a return result and an expected result of the interface test from a database according to the keywords, wherein the database is used for storing test data after the interface test.
After the interface test of the embodiment is completed, the test data are stored in the database, and the returned result and the expected result of the interface test are automatically called from the database according to the keywords, wherein the keywords comprise interface types corresponding to the test tasks, the configuration parameters of different interface types are different, and the test tasks are also different.
S2: and confirming the types of the character strings in the data types of the returned result and the expected result, wherein the data types of the returned result and the expected result are consistent, and the data types comprise the character strings.
The data type of the interface test return result in this embodiment includes multiple types of character strings, for example, if an abnormal condition occurs in the interface test, the return result is an abnormal throwing error or empty character string; the interface type is the state judgment of the test task, and if the interface test returns a result such as 'successful' or 'unsuccessful', the returned result is String type character strings; if the interface type is call data, such as calling bill codes, and the like, bill information with specific bill codes is returned, and the returned result is a character string in Json format.
S3: and selecting a corresponding preset comparison rule according to the type of the character string so as to compare the consistency of the returned result and the expected result.
According to the embodiment, according to the type of the character string for judging the returned result and the expected result, the corresponding comparison rule is called according to the type of the character string, the returned result and the expected result after the interface test are automatically compared, whether the test result is correct or not is judged without manual comparison, and the test efficiency and the judgment correctness are improved. The preset comparison rule in this embodiment is a comparison method that is matched one by one according to the types of various character strings in advance, and is stored in a preset table, and by calling different comparison methods, automatic comparison is performed on the returned results and the expected results of the types of the different character strings.
Further, step S3 of the present embodiment includes:
s31: and respectively analyzing the composition forms of the returned result and the expected result, and judging whether the character String is a String type character String.
The String type of this embodiment is a reference type, holds a reference on the stack, holds data in a String region, and is a series of strings. The embodiment judges whether the String is a String type String or not by the composition form of the returned result and the expected result.
S32: and if the character String is a String type character String, calling a regular expression to compare the consistency of the returned result and the expected result.
According to the embodiment, the data fields corresponding to the returned result and the expected result are respectively identified and extracted by calling the regular expression, so that the returned result and the expected result of the String type character String can be accurately and automatically compared.
Further, step S32 of the present embodiment includes:
s321: and judging whether first data which are obtained after the return result and the expected result are respectively input into the regular expression and correspond to each other one by one is received or not.
When the regular expression is called to compare the returned result and the expected result of the String type character String, the embodiment judges whether first data which is output by the regular expression and accords with the matching rule of the regular expression is received or not by inputting the returned result and the expected result of the String type character String into the regular expression, and if so, the returned result and the expected result of the String type character String accord with the matching rule of the regular expression, namely the filtering logic of the regular expression. The "first" and the like in this embodiment are used for distinction only, and are not limited, and the functions of other parts are the same, and are not repeated. The regular expression of this embodiment is a logic formula for operating on character strings, and a "regular character string" is formed by using specific characters defined in advance and combinations between the specific characters, so as to express filtering logic of the character strings to be compared. And if the character string to be compared accords with the filtering logic of the regular expression, acquiring a corresponding specific part from the character string to be compared through the regular expression to form first data.
S322: if so, comparing whether the first data corresponding to the returned result and the expected result are the same or not.
In this embodiment, for the returned result and the expected result of the String type String conforming to the matching rule of the regular expression, the comparison process may be simplified by comparing the first data output by the regular expression corresponding to the returned result and the expected result, respectively, and by comparing only whether specific portions of the regular expression output are identical.
S323: if the returned result is the same as the expected result, the returned result is judged to be consistent with the expected result, otherwise, the returned result is judged to be inconsistent with the expected result.
For example, if the specific portions of the output of the regular expression to which the returned result and the expected result respectively correspond are the same, the returned result and the expected result agree.
Further, step S32 of another embodiment of the present application includes:
s324: and judging whether first data which are obtained after the return result and the expected result are respectively input into the regular expression and correspond to each other one by one is received or not.
The principle and process of comparing regular expressions in this embodiment are the same as S321, and are not described in detail.
S325: if not, directly comparing whether the character strings of the returned result and the expected result are consistent.
After the returned result and the expected result are respectively input into the regular expression, if no output is received, the returned result and the expected result are indicated to be inconsistent with the matching rule of the regular expression, and whether the character strings corresponding to the returned result and the expected result respectively correspond to each other is directly compared, so that the String type returned result and the expected result which are inconsistent with the matching rule of the regular expression are solved. Or the subsequent one has output through the regular expression, and the other has no output, the returned result is directly judged to be different from the expected result.
S326: if so, judging that the returned result is consistent with the expected result, otherwise, judging that the returned result is inconsistent with the expected result.
According to the embodiment, whether the character strings corresponding to the returned result and the expected result are in one-to-one correspondence or not, including uniform correspondence of character content, character ordering and the like, is judged, if the character strings corresponding to the returned result and the expected result are consistent, the returned result is consistent with the expected result, and otherwise, the returned result is inconsistent.
Further, step S3 of still another embodiment of the present application includes:
s33: and respectively analyzing whether the data structures of the returned result and the expected result have the identifier corresponding to the hierarchical structure in the Json format.
The Json (JavaScript Object Notation, object profile) format is a lightweight data exchange format that stores and represents data in a text format that is completely independent of the programming language. The Json format has a concise and clear hierarchical structure, is easy to read and write, is easy to analyze and generate by a machine, effectively improves the network transmission efficiency, and is an ideal data exchange language. In this embodiment, by determining whether the data structures of the returned result and the expected result have the identifier that represents the hierarchical structure, if so, it is determined that the types of the character strings of the returned result and the expected result are in Json format.
S34: and if the identifier corresponding to the hierarchical structure of the Json format is provided, judging that the returned result and the expected result are character strings of the Json format.
S35: and converting the Json format corresponding to the returned result and the expected result into a Jsonobic type.
In the embodiment, the Json format is converted into the Jsonobic type so as to analyze the returned result and the expected result of the Json format, and required data is acquired so as to judge the consistency of the returned result and the expected result through recursive comparison. The Json format does not distinguish types such as integers, decimal numbers and the like, and the Number is used for storing the numbers uniformly; jsonobiect represents an object, similar to a structure in the C language, bracketed "{ }" and its elements require Key-Value pairs, including Key and Value, key must be of the String type, and Value can be of any type. The Key and the Value are mapped by ':', and the elements are separated by commas. In this embodiment, the data is written by directly constructing the Jsonobiect object and then calling the put method. The first parameter of the put method is Key Value, the String type is needed, the second parameter is Value, and the Json format is converted into Jsonobic type.
S36: and comparing the consistency of the returned result and the expected result by calling a recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer corresponding to the Jsonobifect type.
According to the method, the nodes are searched for in a layer-by-layer recursion mode through calling a recursion algorithm, whether corresponding data of recursion positions are identical or not is compared, whether storage information of the identical nodes is identical or not is compared, whether data of all hierarchical structures of a return result and an expected result are identical or not is compared in a one-to-one correspondence mode, and the consistency is indicated if the data of all hierarchical structures are identical.
Further, step S36 of the present embodiment includes:
s360: and calling a recursive algorithm to respectively and simultaneously recursively return a result and an expected result corresponding to the Jsonobic type layer by layer.
In the embodiment, the returned result and the expected result corresponding to the Jsonobifect type are synchronously recursively so as to simultaneously acquire the corresponding data of the same node of the returned result and the expected result, thereby facilitating comparison and analysis.
S361: and respectively judging whether the types of the character strings corresponding to the current recursion layers of the returned result and the expected result are Jsonobic types.
In this embodiment, when the expected result and the returned result are recursively performed layer by layer through the recursion algorithm, whether the type of the character string currently required to be recursively processed has the hierarchy of the Jsonobiect is determined, if not, the type of the character string is determined to be the Jsonobiect type, and if so, the type of the character string is determined to be the Jsonobiect type. For example, jsonobifect types are bracketed { }, inside are a number of key-value pairs, such as: { "address": "Beijing city west city", "age": "23", "name": "JSON" }, such as "age": "23" is a Key Value pair, age is the Key of the Key Value pair, and 23 is the Value of the Key Value pair.
S362: if the type of the character string corresponding to the current recursion layer is not Jsonobic type, terminating running the recursion algorithm.
In the present embodiment, whether to continue to input to the recursive algorithm for performing the recursive analysis again is determined by analyzing whether the recursive output data of the previous hierarchical structure has the hierarchical structure of the Jsonobic in the recursive process, and if the recursive output data does not have the hierarchical structure of the Jsonobic, the recursive operation is not required to be continued. If the Value is the Jsonobic format, continuing recursion until the Value of the layer corresponding to the Jsonobic format is obtained, and comparing whether the Value is the same or not to compare the returned result with the expected result. In this embodiment, in the running recursive algorithm, the returned result and the expected result are displayed in an unsynchronized manner, for example, one of the returned result and the expected result is terminated and the other is still recursively, and then it is directly determined that the returned result and the expected result are different.
S363: and comparing whether the second data corresponding to the current recursion layer nodes respectively corresponding to the returned result and the expected result are the same or not.
When the condition of ending the recursion is reached, the data output in the last recursion is the data value of the node positions corresponding to the returned result and the expected result respectively in the progressive recursion process. The consistency of the returned result and the expected result is achieved by comparing whether the second data of the same node location is the same. The embodiment compares the returned result with the expected result by comparing only whether the Value in the second data corresponding to the same node is the same.
S364: if the returned result is the same as the expected result, the returned result is judged to be consistent with the expected result, otherwise, the returned result is judged to be inconsistent with the expected result.
In this embodiment, the returned result is determined to be consistent with the expected result by the corresponding node of each level and the data stored by the node being uniform and identical, otherwise, the returned result is not consistent.
Further, before step S36 of the present embodiment, it includes:
s37: judging whether the Jsonobice type is a Jsonorray type with data embedding, wherein the Jsonorray type is an array formed by data of a plurality of Jsonobice types.
The JsonArray type of this embodiment is an array composed of a plurality of jsonobic type data, and is wrapped with brackets, and the inside of the brackets is the jsonobic type, for example: [ { "address": "Beijing city west city", "age": "23", "name": "JSOON" }, { "address": "Beijing city east city", "age": "24", "name": "JSOON" } ], the above mentioned JsonARRAy includes two Jsonobic types of data.
S38: if yes, acquiring all the data information of the Jsonobifect types in the Jsononarry, wherein the data information comprises data contents respectively corresponding to the Jsonobifect types and arrangement position information respectively corresponding to the Jsonobifect types.
All the data of the jsonobic type in the jsonargy of this embodiment includes specific data content of the jsonobic type, and arrangement position information of each jsonobic type, and the like.
S39: and ordering all the Jsonobic type data in the JsonARRAY type according to the arrangement position information and a preset rule.
The JSONArray and JSOnobiect types can be mutually nested, so that after the interface test is finished, the sequence of the actual returned results may not be consistent, the first JSOnobiect type may be returned before the second JSOnobiect type may be returned after the second JSOnobiect type may be returned before the first JSOnobiect type is returned after the second JSOnobiect type is also returned, and therefore the comparison problem of the returned results under different sequences needs to be solved, after all JSOnobiect types in the JSONArray are sequenced, the sequences are compared in a recursion mode, and the sequencing aims to sequence the expected returned results and all JSOnobiect types in the actual returned results consistently.
S40: and sequentially inputting the Jsonobic type data which are sequenced according to the preset rule according to the arrangement position information into the recursion algorithm.
The application determines whether the interface test result is correct or not by sequencing and recursing the expected result and the returned result through the same rule. The method solves the comparison problem of the data types with the nested structure, and solves the comparison problem that the original nested structure is that the data 1 is added to the first position 1, the data 2 is added to the second position 2, the data 2 is added to the second position 1, the data 1 is added to the second position, the expected result is the same as the return result, and the inconformity of the return sequence of the parameter data in the return result and the expected result exists after the interface test is finished. For example, the expected result and the actual returned result are regarded as two trees with the same structure, all leaf nodes of the two trees are traversed layer by layer through a recursion method, whether the data values of the same leaf node are consistent is automatically judged, when any node field is found to be unmatched in the process, an error result is fed back, interface test error information is fed back, and testers are automatically prompted to compare unmatched places, so that the investment time for large amount of manual judgment and comparison is saved.
Further, step S1 of the present embodiment includes:
s10: and receiving the return data of the interface test.
The return result of this embodiment is from the return data after the interface test is completed, and the return result is all or part of the return data.
S11: and selecting a designated field from the returned data as a returned result according to a task protocol, wherein the designated field is part of or all of the data in the returned data.
According to the embodiment, the appointed fields which are automatically compared according to the task protocol custom configuration are selected, only the appointed fields which are concerned with the tasks closely are selected as the returned results, and other fields which are not greatly related to the tasks are ignored, so that the comparison efficiency is improved.
S12: and extracting an expected result corresponding to the returned result from the database according to the position information of the returned result in the returned data and the key words.
When the designated field of the return data is selected, the corresponding field of the corresponding position in the expected data is screened according to the same screening rule to form the expected data, so that the expected data and the return data theoretically have one-to-one correspondence, and the purpose of comparing the whole return data with the expected data is achieved by comparing the return result with the expected result.
According to the embodiment, the automatic comparison of the interface test results is realized by matching the comparison rules of different character string types, and whether the test results are correct or not is judged without manual comparison, so that a great amount of manual comparison time is saved, and the test efficiency and judgment correctness are improved; according to the application, when the JsonARRAY with the data embedding hierarchical structure is judged, the comparison problem that the parameter return sequence in the interface return result is inconsistent is solved by a method of sequencing and recursion; the application supports automatic comparison of the appointed data fields according to the task protocol user-defined configuration, and can only compare the parameter fields needing to be concerned, thereby improving the comparison efficiency of the test results.
Referring to fig. 2, an apparatus for comparing test results according to an embodiment of the present application includes:
the acquisition module 1 is used for respectively acquiring a returned result and an expected result of the interface test from a database according to the keywords, wherein the database is used for storing test data after the interface test.
After the interface test of the embodiment is completed, the test data are stored in the database, and the returned result and the expected result of the interface test are automatically called from the database according to the keywords, wherein the keywords comprise interface types corresponding to the test tasks, the configuration parameters of different interface types are different, and the test tasks are also different.
And the analysis module 2 is used for confirming the types of the character strings in the data types of the returned result and the expected result, wherein the data types of the returned result and the expected result are consistent, and the data types comprise the character strings.
The data type of the interface test return result in this embodiment includes multiple types of character strings, for example, if an abnormal condition occurs in the interface test, the return result is an abnormal throwing error or empty character string; the interface type is the state judgment of the test task, and if the interface test returns a result such as 'successful' or 'unsuccessful', the returned result is String type character strings; if the interface type is call data, such as calling bill codes, and the like, bill information with specific bill codes is returned, and the returned result is a character string in Json format.
And the selection module 3 is used for selecting a corresponding preset comparison rule according to the type of the character string so as to compare the consistency of the returned result and the expected result.
According to the embodiment, according to the type of the character string for judging the returned result and the expected result, the corresponding comparison rule is called according to the type of the character string, the returned result and the expected result after the interface test are automatically compared, whether the test result is correct or not is judged without manual comparison, and the test efficiency and the judgment correctness are improved. The preset comparison rule in this embodiment is a comparison method that is matched one by one according to the types of various character strings in advance, and is stored in a preset table, and by calling different comparison methods, automatic comparison is performed on the returned results and the expected results of the types of the different character strings.
Referring to fig. 3, the selection module 3 of the present embodiment includes:
the first analysis unit 31 is configured to analyze the composition forms of the returned result and the expected result, and determine whether the String is String type String.
The String type of this embodiment is a reference type, holds a reference on the stack, holds data in a String region, and is a series of strings. The embodiment judges whether the String is a String type String or not by the composition form of the returned result and the expected result.
And a calling unit 32, configured to call a regular expression to compare the consistency of the returned result and the expected result if the String is String type String.
According to the embodiment, the data fields corresponding to the returned result and the expected result are respectively identified and extracted by calling the regular expression, so that the returned result and the expected result of the String type character String can be accurately and automatically compared.
Referring to fig. 4, the calling unit 32 of the present embodiment includes:
the first judging subunit 321 is configured to judge whether first data corresponding to one obtained after the return result and the expected result are respectively input into the regular expression is received.
When the regular expression is called to compare the returned result and the expected result of the String type character String, the embodiment judges whether first data which is output by the regular expression and accords with the matching rule of the regular expression is received or not by inputting the returned result and the expected result of the String type character String into the regular expression, and if so, the returned result and the expected result of the String type character String accord with the matching rule of the regular expression, namely the filtering logic of the regular expression. The "first" and the like in this embodiment are used for distinction only, and are not limited, and the functions of other parts are the same, and are not repeated. The regular expression of this embodiment is a logic formula for operating on character strings, and a "regular character string" is formed by using specific characters defined in advance and combinations between the specific characters, so as to express filtering logic of the character strings to be compared. And if the character string to be compared accords with the filtering logic of the regular expression, acquiring a corresponding specific part from the character string to be compared through the regular expression to form first data.
And the comparing subunit 322 is configured to compare whether the first data corresponding to the returned result and the expected result are the same, if so.
In this embodiment, for the returned result and the expected result of the String type String conforming to the matching rule of the regular expression, the comparison process may be simplified by comparing the first data output by the regular expression corresponding to the returned result and the expected result, respectively, and by comparing only whether specific portions of the regular expression output are identical.
A first determining subunit 323, configured to determine that the returned result is consistent with the expected result if the returned result is the same, and determine that the returned result is inconsistent with the expected result if the returned result is not the same.
For example, if the specific portions of the output of the regular expression to which the returned result and the expected result respectively correspond are the same, the returned result and the expected result agree.
Referring to fig. 5, a calling unit 32 of another embodiment of the present application includes:
and a second judging subunit 324, configured to judge whether one-to-one corresponding first data obtained after the return result and the expected result are respectively input into the regular expression is received.
The principle and process of comparing regular expressions in this embodiment are the same as the first determining subunit 321, and are not described in detail.
And the comparing subunit 325 is configured to directly compare whether the character strings of the returned result and the expected result are consistent if not received.
After the returned result and the expected result are respectively input into the regular expression, if no output is received, the returned result and the expected result are indicated to be inconsistent with the matching rule of the regular expression, and whether the character strings corresponding to the returned result and the expected result respectively correspond to each other is directly compared, so that the String type returned result and the expected result which are inconsistent with the matching rule of the regular expression are solved. Or the subsequent one has output through the regular expression, and the other has no output, the returned result is directly judged to be different from the expected result.
And a second determining subunit 326, configured to determine that the returned result is consistent with the expected result if the returned result is consistent with the expected result, and otherwise determine that the returned result is inconsistent with the expected result.
According to the embodiment, whether the character strings corresponding to the returned result and the expected result are in one-to-one correspondence or not, including uniform correspondence of character content, character ordering and the like, is judged, if the character strings corresponding to the returned result and the expected result are consistent, the returned result is consistent with the expected result, and otherwise, the returned result is inconsistent.
Referring to fig. 6, a selection module 3 of a further embodiment of the present application includes:
and a second analysis unit 33, configured to analyze whether the data structures of the returned result and the expected result have the identifier corresponding to the hierarchy structure in Json format.
The Json (JavaScript Object Notation, object profile) format is a lightweight data exchange format that stores and represents data in a text format that is completely independent of the programming language. The Json format has a concise and clear hierarchical structure, is easy to read and write, is easy to analyze and generate by a machine, effectively improves the network transmission efficiency, and is an ideal data exchange language. In this embodiment, by determining whether the data structures of the returned result and the expected result have the identifier that represents the hierarchical structure, if so, it is determined that the types of the character strings of the returned result and the expected result are in Json format.
And the judging unit 34 is configured to judge that the returned result and the expected result are character strings in the Json format if the character strings have the identifier corresponding to the hierarchical structure in the Json format.
And a conversion unit 35, configured to convert the Json format corresponding to the returned result and the expected result into a Jsonobiect type.
In the embodiment, the Json format is converted into the Jsonobic type so as to analyze the returned result and the expected result of the Json format, and required data is acquired so as to judge the consistency of the returned result and the expected result through recursive comparison. The Json format does not distinguish types such as integers, decimal numbers and the like, and the Number is used for storing the numbers uniformly; jsonobiect represents an object, similar to a structure in the C language, bracketed "{ }" and its elements require Key-Value pairs, including Key and Value, key must be of the String type, and Value can be of any type. The Key and the Value are mapped by ':', and the elements are separated by commas. In this embodiment, the data is written by directly constructing the Jsonobiect object and then calling the put method. The first parameter of the put method is Key Value, the String type is needed, the second parameter is Value, and the Json format is converted into Jsonobict type.
And a comparing unit 36, configured to compare the returned result and the expected result by calling the recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer.
According to the method, the nodes are searched for in a layer-by-layer recursion mode through calling a recursion algorithm, whether corresponding data of recursion positions are identical or not is compared, whether storage information of the identical nodes is identical or not is compared, whether data of all hierarchical structures of a return result and an expected result are identical or not is compared in a one-to-one correspondence mode, and the consistency is indicated if the data of all hierarchical structures are identical.
Referring to fig. 7, the comparing unit 36 of the present embodiment includes:
and the calling subunit 360 is configured to call the return result and the expected result corresponding to the recursive jsonobic type layer by layer at the same time respectively.
In the embodiment, the returned result and the expected result corresponding to the Jsonobifect type are synchronously recursively so as to simultaneously acquire the corresponding data of the same node of the returned result and the expected result, thereby facilitating comparison and analysis.
And a third judging subunit 361, configured to respectively judge whether the types of the character strings corresponding to the current recursion layer of the returned result and the expected result are jsonobic types.
In this embodiment, when the expected result and the returned result are recursively performed layer by layer through the recursion algorithm, whether the type of the character string currently required to be recursively processed has the hierarchy of the Jsonobiect is determined, if not, the type of the character string is determined to be the Jsonobiect type, and if so, the type of the character string is determined to be the Jsonobiect type. For example, jsonobifect types are bracketed { }, inside are a number of key-value pairs, such as: { "address": "Beijing city west city", "age": "23", "name": "JSON" }, such as "age": "23" is a Key Value pair, age is the Key of the Key Value pair, and 23 is the Value of the Key Value pair.
And the terminator unit 362 is configured to terminate running the recursive algorithm if the type of the string corresponding to the current recursive layer is not the jsonobic type.
In the present embodiment, whether to continue to input to the recursive algorithm for performing the recursive analysis again is determined by analyzing whether the recursive output data of the previous hierarchical structure has the hierarchical structure of the Jsonobic in the recursive process, and if the recursive output data does not have the hierarchical structure of the Jsonobic, the recursive operation is not required to be continued. If the Value is the Jsonobic format, continuing recursion until the Value of the layer corresponding to the Jsonobic format is obtained, and comparing whether the Value is the same or not to compare the returned result with the expected result. In this embodiment, in the running recursive algorithm, the returned result and the expected result are displayed in an unsynchronized manner, for example, one of the returned result and the expected result is terminated and the other is still recursively, and then it is directly determined that the returned result and the expected result are different.
And the comparing subunit 363 is configured to compare whether the second data corresponding to the current recursion layer node corresponding to the returned result and the expected result respectively are the same.
When the condition of ending the recursion is reached, the data output in the last recursion is the data value of the node positions corresponding to the returned result and the expected result respectively in the progressive recursion process. The consistency of the returned result and the expected result is achieved by comparing whether the second data of the same node location is the same. The embodiment compares the returned result with the expected result by comparing only whether the Value in the second data corresponding to the same node is the same.
And a third determining subunit 364, configured to determine that the returned result is consistent with the expected result if the returned result is the same, and determine that the returned result is inconsistent with the expected result if the returned result is not the same.
In this embodiment, the returned result is determined to be consistent with the expected result by the corresponding node of each level and the data stored by the node being uniform and identical, otherwise, the returned result is not consistent.
Referring to fig. 8, a selection module 3 of a further embodiment of the present application includes:
a judging unit 37, configured to judge whether the jsonalect type is a JsonArray type with data nesting, where the JsonArray type is an array composed of data of multiple jsonalect types.
The JsonArray type of this embodiment is an array composed of a plurality of jsonobic type data, and is wrapped with brackets, and the inside of the brackets is the jsonobic type, for example: [ { "address": "Beijing city west city", "age": "23", "name": "JSOON" }, { "address": "Beijing city east city", "age": "24", "name": "JSOON" } ], the above mentioned JsonARRAy includes two Jsonobic types of data.
And an obtaining unit 38, configured to obtain data information of all the JsonArray types in the JsonArray if the JsonArray type has the data nesting, where the data information includes data contents corresponding to the jsonabiact types respectively, and arrangement position information corresponding to the JsonArray types respectively.
All the data of the jsonobic type in the jsonargy of this embodiment includes specific data content of the jsonobic type, and arrangement position information of each jsonobic type, and the like.
And a sorting unit 39, configured to sort all data of the JsonArray type according to the arrangement position information and a preset rule.
The JSONArray and JSOnobiect types can be mutually nested, so that after the interface test is finished, the sequence of the actual returned results may not be consistent, the first JSOnobiect type may be returned before the second JSOnobiect type may be returned after the second JSOnobiect type may be returned before the first JSOnobiect type is returned after the second JSOnobiect type is also returned, and therefore the comparison problem of the returned results under different sequences needs to be solved, after all JSOnobiect types in the JSONArray are sequenced, the sequences are compared in a recursion mode, and the sequencing aims to sequence the expected returned results and all JSOnobiect types in the actual returned results consistently.
An input unit 40, configured to sequentially input the data of each jsonobifect type, which is sequenced according to a preset rule according to the arrangement position information, into the recursive algorithm.
The application determines whether the interface test result is correct or not by sequencing and recursing the expected result and the returned result through the same rule. The method solves the comparison problem of the data types with the nested structure, and solves the comparison problem that the original nested structure is that the data 1 is added to the first position 1, the data 2 is added to the second position 2, the data 2 is added to the second position 1, the data 1 is added to the second position, the expected result is the same as the return result, and the inconformity of the return sequence of the parameter data in the return result and the expected result exists after the interface test is finished. For example, the expected result and the actual returned result are regarded as two trees with the same structure, all leaf nodes of the two trees are traversed layer by layer through a recursion method, whether the data values of the same leaf node are consistent is automatically judged, when any node field is found to be unmatched in the process, an error result is fed back, interface test error information is fed back, and testers are automatically prompted to compare unmatched places, so that the investment time for large amount of manual judgment and comparison is saved.
Referring to fig. 9, the acquisition module 1 of the present embodiment includes:
and the receiving unit 10 is used for receiving the return data of the interface test.
The return result of this embodiment is from the return data after the interface test is completed, and the return result is all or part of the return data.
And a screening unit 11, configured to screen a specified field from the returned data according to a task protocol, where the specified field is part of or all of the data in the returned data, as a returned result.
According to the embodiment, the appointed fields which are automatically compared according to the task protocol custom configuration are selected, only the appointed fields which are concerned with the tasks closely are selected as the returned results, and other fields which are not greatly related to the tasks are ignored, so that the comparison efficiency is improved.
And the extracting unit 12 is used for extracting the expected result corresponding to the returned result in the database according to the position information of the returned result in the returned data and the keywords.
When the designated field of the return data is selected, the corresponding field of the corresponding position in the expected data is screened according to the same screening rule to form the expected data, so that the expected data and the return data theoretically have one-to-one correspondence, and the purpose of comparing the whole return data with the expected data is achieved by comparing the return result with the expected result.
Referring to fig. 10, a computer device is further provided in an embodiment of the present application, where the computer device may be a server, and the internal structure of the computer device may be as shown in fig. 10. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used to store all the data required for the process of comparing test results. The network interface of the computer device is for communicating with an external terminal via a network connection. The computer program is executed by a processor to implement a method of comparing test results.
The method for comparing test results by the processor comprises the following steps: respectively acquiring a return result and an expected result of the interface test from a database according to the keywords, wherein the database is used for storing test data after the interface test; confirming the types of character strings in the data types of the returned result and the expected result, wherein the data types of the returned result and the expected result are consistent, and the data types comprise the character strings; and selecting a corresponding preset comparison rule according to the type of the character string so as to compare the consistency of the returned result and the expected result.
According to the computer equipment, the automatic comparison of the interface test results is realized by matching the comparison rules of different data types, and whether the test results are correct or not is judged without manual comparison, so that a great amount of manual comparison time is saved, and the test efficiency and judgment correctness are improved; when the JsonARRAY with the data embedding hierarchical structure is judged, the method of sequencing and recursion is adopted, so that the problem of inconsistent comparison of parameter return sequences in an interface return result is solved; the automatic comparison of the specified data fields according to the task protocol custom configuration is supported, and only the parameter fields needing attention can be compared, so that the comparison efficiency of the test results is improved.
In one embodiment, the step of selecting, by the processor, a corresponding preset comparison rule according to the type of the character string to compare the consistency of the returned result and the expected result includes: respectively analyzing the composition forms of the returned result and the expected result, and judging whether the character String is a String type character String or not; and if the character String is a String type character String, calling a regular expression to compare the consistency of the returned result and the expected result.
In one embodiment, the step of the processor invoking a regular expression to compare the consistency of the returned result with the expected result includes: judging whether first data which are obtained after the return result and the expected result are respectively input into the regular expression and correspond to each other one by one is received or not; if so, comparing whether the first data corresponding to the returned result and the expected result are the same or not; if the returned result is the same as the expected result, the returned result is judged to be consistent with the expected result, otherwise, the returned result is judged to be inconsistent with the expected result.
In one embodiment, the step of the processor invoking a regular expression to compare the consistency of the returned result with the expected result includes: judging whether first data which are obtained after the return result and the expected result are respectively input into the regular expression and correspond to each other one by one is received or not; if not, directly comparing whether the character strings respectively corresponding to the returned result and the expected result are consistent; if so, judging that the returned result is consistent with the expected result, otherwise, judging that the returned result is inconsistent with the expected result.
In one embodiment, the step of comparing the consistency of the returned result and the expected result by selecting a corresponding preset comparison rule according to the type of the character string by the processor includes: respectively analyzing whether the data structures of the returned result and the expected result have the identifier corresponding to the hierarchical structure of the Json format or not; if the identifier corresponding to the hierarchical structure of the Json format is provided, judging that the returned result and the expected result are character strings of the Json format; converting the Json format corresponding to the returned result and the expected result into a Jsonobiect type; and comparing the consistency of the returned result and the expected result by calling a recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer corresponding to the Jsonobifect type.
In one embodiment, the step of comparing the consistency of the returned result and the expected result by calling a recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer according to the Jsonobic type by the processor includes: calling a recursion algorithm to respectively and simultaneously recursion a returned result and an expected result which correspond to the Jsonobifect type layer by layer; respectively judging whether the type of the character string corresponding to the current recursion layer of the returned result and the expected result is a Jsonobifect type; if the type of the character string corresponding to the current recursion layer is not Jsonobic type, terminating running the recursion algorithm; comparing whether the second data corresponding to the current recursion layer respectively corresponding to the returned result and the expected result are the same or not; if the returned result is the same as the expected result, the returned result is judged to be consistent with the expected result, otherwise, the returned result is judged to be inconsistent with the expected result.
In one embodiment, before the step of comparing the consistency of the returned result and the expected result by calling a recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer according to the Jsonobic type, the method includes: judging whether the Jsonobicect type is a JsonARRAY type with data embedding, wherein the JsonARRAY type is an array formed by data of a plurality of Jsonobicect types; if the JSONArray type is provided with the data embedding, acquiring data information of all JSONOBIect types in the JSONArray type, wherein the data information comprises data contents respectively corresponding to the JSONOBIect types and arrangement position information respectively corresponding to the JSONOBIect types; all Jsonobic type data in the JsonARRAY type are ordered according to the arrangement position information and a preset rule; and sequentially inputting the Jsonobic type data which are sequenced according to the preset rule according to the arrangement position information into the recursion algorithm.
In one embodiment, the step of obtaining, by the processor, the returned result and the expected result of the interface test from the database according to the key words, respectively, includes: receiving return data of the interface test; selecting a specified field from the returned data as a returned result according to a task protocol, wherein the specified field is part of data or all data in the returned data; and extracting an expected result corresponding to the returned result from the database according to the position information of the returned result in the returned data and the key words.
It will be appreciated by those skilled in the art that the architecture shown in fig. 10 is merely a block diagram of a portion of the architecture in connection with the present inventive arrangements and is not intended to limit the computer devices to which the present inventive arrangements are applicable.
An embodiment of the present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs a method of comparing test results, comprising: respectively acquiring a return result and an expected result of the interface test from a database according to the keywords, wherein the database is used for storing test data after the interface test; confirming the types of character strings in the data types of the returned result and the expected result, wherein the data types of the returned result and the expected result are consistent, and the data types comprise the character strings; and selecting a corresponding preset comparison rule according to the type of the character string so as to compare the consistency of the returned result and the expected result.
According to the computer readable storage medium, by matching the comparison rules of different data types, the automatic comparison of the interface test results is realized, whether the test results are correct or not is judged without manual comparison, a large amount of manual comparison time is saved, and the test efficiency and judgment correctness are improved; when the JsonARRAY with the data embedding hierarchical structure is judged, the method of sequencing and recursion is adopted, so that the problem of inconsistent comparison of parameter return sequences in an interface return result is solved; the automatic comparison of the specified data fields according to the task protocol custom configuration is supported, and only the parameter fields needing attention can be compared, so that the comparison efficiency of the test results is improved.
In one embodiment, the step of selecting, by the processor, a corresponding preset comparison rule according to the type of the character string to compare the consistency of the returned result and the expected result includes: respectively analyzing the composition forms of the returned result and the expected result, and judging whether the character String is a String type character String or not; and if the character String is a String type character String, calling a regular expression to compare the consistency of the returned result and the expected result.
In one embodiment, the step of the processor invoking a regular expression to compare the consistency of the returned result with the expected result includes: judging whether first data which are obtained after the return result and the expected result are respectively input into the regular expression and correspond to each other one by one is received or not; if so, comparing whether the first data corresponding to the returned result and the expected result are the same or not; if the returned result is the same as the expected result, the returned result is judged to be consistent with the expected result, otherwise, the returned result is judged to be inconsistent with the expected result.
In one embodiment, the step of the processor invoking a regular expression to compare the consistency of the returned result with the expected result includes: judging whether first data which are obtained after the return result and the expected result are respectively input into the regular expression and correspond to each other one by one is received or not; if not, directly comparing whether the character strings respectively corresponding to the returned result and the expected result are consistent; if so, judging that the returned result is consistent with the expected result, otherwise, judging that the returned result is inconsistent with the expected result.
In one embodiment, the step of comparing the consistency of the returned result and the expected result by selecting a corresponding preset comparison rule according to the type of the character string by the processor includes: respectively analyzing whether the data structures of the returned result and the expected result have the identifier corresponding to the hierarchical structure of the Json format or not; if the identifier corresponding to the hierarchical structure of the Json format is provided, judging that the returned result and the expected result are character strings of the Json format; converting the Json format corresponding to the returned result and the expected result into a Jsonobiect type; and comparing the consistency of the returned result and the expected result by calling a recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer corresponding to the Jsonobifect type.
In one embodiment, the step of comparing the consistency of the returned result and the expected result by calling a recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer according to the Jsonobic type by the processor includes: calling a recursion algorithm to respectively and simultaneously recursion a returned result and an expected result which correspond to the Jsonobifect type layer by layer; respectively judging whether the type of the character string corresponding to the current recursion layer of the returned result and the expected result is a Jsonobifect type; if the type of the character string corresponding to the current recursion layer is not Jsonobic type, terminating running the recursion algorithm; comparing whether the second data corresponding to the current recursion layer respectively corresponding to the returned result and the expected result are the same or not; if the returned result is the same as the expected result, the returned result is judged to be consistent with the expected result, otherwise, the returned result is judged to be inconsistent with the expected result.
In one embodiment, before the step of comparing the consistency of the returned result and the expected result by calling a recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer according to the Jsonobic type, the method includes: judging whether the Jsonobicect type is a JsonARRAY type with data embedding, wherein the JsonARRAY type is an array formed by data of a plurality of Jsonobicect types; if the JSONArray type is provided with the data embedding, acquiring data information of all JSONOBIect types in the JSONArray type, wherein the data information comprises data contents respectively corresponding to the JSONOBIect types and arrangement position information respectively corresponding to the JSONOBIect types; all Jsonobic type data in the JsonARRAY type are ordered according to the arrangement position information and a preset rule; and sequentially inputting the Jsonobic type data which are sequenced according to the preset rule according to the arrangement position information into the recursion algorithm.
In one embodiment, the step of obtaining, by the processor, the returned result and the expected result of the interface test from the database according to the key words, respectively, includes: receiving return data of the interface test; selecting a specified field from the returned data as a returned result according to a task protocol, wherein the specified field is part of data or all data in the returned data; and extracting an expected result corresponding to the returned result from the database according to the position information of the returned result in the returned data and the key words.
Those skilled in the art will appreciate that implementing all or part of the above-described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium provided by the present application and used in embodiments may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual speed data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, apparatus, article or method that comprises the element.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the scope of the application, and all equivalent structures or equivalent processes using the descriptions and drawings of the present application or directly or indirectly applied to other related technical fields are included in the scope of the application.

Claims (8)

1. A method of comparing test results, comprising:
respectively acquiring a return result and an expected result of the interface test from a database according to the keywords, wherein the database is used for storing test data after the interface test;
Confirming the types of character strings in the data types of the returned result and the expected result, wherein the data types of the returned result and the expected result are consistent, and the data types comprise the character strings;
selecting a corresponding preset comparison rule according to the type of the character string so as to compare the consistency of the returned result and the expected result;
the step of comparing the consistency of the returned result and the expected result includes:
respectively analyzing whether the data structures of the returned result and the expected result have the identifier corresponding to the hierarchical structure of the Json format or not;
if the identifier corresponding to the hierarchical structure of the Json format is provided, judging that the returned result and the expected result are character strings of the Json format;
converting the Json format corresponding to the returned result and the expected result into a Jsonobiect type;
the method comprises the steps of calling a recursion algorithm to recursion a returned result and an expected result corresponding to a Jsonobifect type layer by layer simultaneously so as to compare the consistency of the returned result and the expected result;
the step of comparing the consistency of the returned result and the expected result by calling a recursive algorithm and simultaneously recursively setting the returned result and the expected result layer by layer, wherein the step comprises the following steps:
Calling a recursion algorithm to respectively and simultaneously recursion a returned result and an expected result which correspond to the Jsonobifect type layer by layer;
respectively judging whether the type of the character string corresponding to the current recursion layer of the returned result and the expected result is a Jsonobifect type;
if the type of the character string corresponding to the current recursion layer is not Jsonobic type, terminating running the recursion algorithm;
comparing whether the second data corresponding to the current recursion layer respectively corresponding to the returned result and the expected result are the same or not;
if the returned result is the same as the expected result, the returned result is judged to be consistent with the expected result, otherwise, the returned result is judged to be inconsistent with the expected result.
2. The method of comparing test results according to claim 1, wherein the step of selecting a corresponding preset comparison rule according to the type of the character string to compare the consistency of the returned result with the expected result comprises:
respectively analyzing the composition forms of the returned result and the expected result, and judging whether the character String is a String type character String or not;
and if the character String is a String type character String, calling a regular expression to compare the consistency of the returned result and the expected result.
3. The method of comparing test results of claim 2, wherein the step of invoking a regular expression to compare the consistency of the returned result with the expected result comprises:
judging whether first data which are obtained after the return result and the expected result are respectively input into the regular expression and correspond to each other one by one is received or not;
if so, comparing whether the first data corresponding to the returned result and the expected result are the same or not;
if the returned result is the same as the expected result, the returned result is judged to be consistent with the expected result, otherwise, the returned result is judged to be inconsistent with the expected result.
4. The method of comparing test results of claim 2, wherein the step of invoking a regular expression to compare the consistency of the returned result with the expected result comprises:
judging whether first data which are obtained after the return result and the expected result are respectively input into the regular expression and correspond to each other one by one is received or not;
if not, directly comparing whether the character strings respectively corresponding to the returned result and the expected result are consistent;
if so, judging that the returned result is consistent with the expected result, otherwise, judging that the returned result is inconsistent with the expected result.
5. The method of comparing test results according to claim 1, wherein before the step of comparing the consistency of the returned result and the expected result by calling a recursive algorithm while recursively jsonobic-type-corresponding returned result and expected result layer by layer, comprising:
judging whether the Jsonobicect type is a JsonARRAY type with data embedding, wherein the JsonARRAY type is an array formed by data of a plurality of Jsonobicect types;
if yes, acquiring data information of all Jsonobifect types in the Jsononarry types, wherein the data information comprises data contents respectively corresponding to the Jsonobifect types and arrangement position information respectively corresponding to the Jsonobifect types;
sorting all Jsonobic type data in the JsonARRAY type according to the arrangement position information and a preset rule;
sequentially inputting the Jsonobic type data which are sequenced according to the preset rule according to the arrangement position information into the recursion algorithm.
6. An apparatus for comparing test results for implementing the method of any one of claims 1 to 5, comprising:
The acquisition module is used for respectively acquiring a return result and an expected result of the interface test from a database according to the keywords, wherein the database is used for storing test data after the interface test;
the analysis module is used for confirming the types of the character strings in the data types of the returned result and the expected result, wherein the data types of the returned result and the expected result are consistent, and the data types comprise the character strings;
and the selection module is used for selecting a corresponding preset comparison rule according to the type of the character string so as to compare the consistency of the returned result and the expected result.
7. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 5 when the computer program is executed.
8. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 5.
CN201811229393.8A 2018-10-22 2018-10-22 Method, device, computer equipment and storage medium for comparing test results Active CN109614309B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811229393.8A CN109614309B (en) 2018-10-22 2018-10-22 Method, device, computer equipment and storage medium for comparing test results

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811229393.8A CN109614309B (en) 2018-10-22 2018-10-22 Method, device, computer equipment and storage medium for comparing test results

Publications (2)

Publication Number Publication Date
CN109614309A CN109614309A (en) 2019-04-12
CN109614309B true CN109614309B (en) 2023-10-20

Family

ID=66002519

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811229393.8A Active CN109614309B (en) 2018-10-22 2018-10-22 Method, device, computer equipment and storage medium for comparing test results

Country Status (1)

Country Link
CN (1) CN109614309B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110209571A (en) * 2019-04-25 2019-09-06 深圳壹账通智能科技有限公司 Test method and device, storage medium, the computer equipment of more new interface
CN110377463A (en) * 2019-06-19 2019-10-25 深圳壹账通智能科技有限公司 Interface test method, device, terminal and computer readable storage medium
CN110908892A (en) * 2019-09-18 2020-03-24 泰康保险集团股份有限公司 Interface data testing method and device and readable storage medium
CN111078485B (en) * 2019-12-03 2023-06-13 广州西麦科技股份有限公司 Intelligent training result detection method
CN111159329B (en) * 2019-12-24 2023-09-08 深圳市优必选科技股份有限公司 Sensitive word detection method, device, terminal equipment and computer readable storage medium
CN111240928B (en) * 2020-01-06 2024-04-09 上海闻泰信息技术有限公司 Automatic detection method, device, equipment and storage medium for equipment drive
CN111382075B (en) * 2020-03-10 2023-09-26 北京同邦卓益科技有限公司 Automatic test data processing method and device
CN112214395A (en) * 2020-09-02 2021-01-12 浙江大搜车融资租赁有限公司 Interface testing method based on flow data, electronic device and storage medium
CN112667500A (en) * 2020-12-23 2021-04-16 北京焦点新干线信息技术有限公司 Regression testing method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2009144826A1 (en) * 2008-05-30 2009-12-03 富士通株式会社 Verification file generating program, verification file generating device, and verification file generating method
CN102694701A (en) * 2012-06-13 2012-09-26 青岛海信传媒网络技术有限公司 Testing method and system based on message
CN106598852A (en) * 2016-12-05 2017-04-26 广州唯品会信息科技有限公司 Software testing method and system
KR20180099241A (en) * 2017-02-28 2018-09-05 주식회사 스패로우 Method for performing test using test case and apparatus for the same

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2009144826A1 (en) * 2008-05-30 2009-12-03 富士通株式会社 Verification file generating program, verification file generating device, and verification file generating method
CN102694701A (en) * 2012-06-13 2012-09-26 青岛海信传媒网络技术有限公司 Testing method and system based on message
CN106598852A (en) * 2016-12-05 2017-04-26 广州唯品会信息科技有限公司 Software testing method and system
KR20180099241A (en) * 2017-02-28 2018-09-05 주식회사 스패로우 Method for performing test using test case and apparatus for the same

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
赵强.数字签名的验证技术.《中国优秀硕士学位论文全文数据库 (信息科技辑)》.2003,(第02期),I136-100. *

Also Published As

Publication number Publication date
CN109614309A (en) 2019-04-12

Similar Documents

Publication Publication Date Title
CN109614309B (en) Method, device, computer equipment and storage medium for comparing test results
CN109614310A (en) Management method, device, computer equipment and the storage medium of test interface
CN112148509A (en) Data processing method, device, server and computer readable storage medium
CN110221975B (en) Method and device for creating interface case automation test script
CN111090788B (en) json file comparison method and device, storage medium and computer equipment
CN109582563B (en) Test method, device, computer equipment and storage medium for test cases
CN112882974B (en) JSON data conversion method and device, computer equipment and storage medium
CN111324577B (en) Yml file reading and writing method and device
CN104657274B (en) software interface test method and device
CN110765741A (en) Data processing method and device, computer equipment and storage medium
CN113282498B (en) Method, device, equipment and storage medium for generating test cases
CN111581076A (en) System code testing method and device, computer equipment and storage medium
CN112286934A (en) Database table importing method, device, equipment and medium
CN109308258A (en) Building method, device, computer equipment and the storage medium of test data
CN114610635A (en) Interface test case generation method and device, computer equipment and storage medium
CN113505078B (en) Configuration file updating method, device, equipment and storage medium
CN113049935A (en) Semiconductor intelligent detection system, intelligent detection method and storage medium
CN113094617A (en) Web element positioning method and application and storage medium thereof
CN112527286A (en) Service code generation method and device, computer equipment and storage medium
CN113031835A (en) Menu data processing method and device
CN111506573B (en) Database table partitioning method, device, computer equipment and storage medium
CN113536762A (en) JSON text comparison method and device
CN110618979B (en) Nested loop data processing method and device and computer equipment
CN114996519B (en) Data processing method, device, electronic equipment, storage medium and product
CN109471960A (en) The method and device of intelligent recognition PCB data tool layer name

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant