CN112783791B - Interface test case generation method and device - Google Patents

Interface test case generation method and device Download PDF

Info

Publication number
CN112783791B
CN112783791B CN202110171209.4A CN202110171209A CN112783791B CN 112783791 B CN112783791 B CN 112783791B CN 202110171209 A CN202110171209 A CN 202110171209A CN 112783791 B CN112783791 B CN 112783791B
Authority
CN
China
Prior art keywords
interface
field
java object
generating
layer java
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
CN202110171209.4A
Other languages
Chinese (zh)
Other versions
CN112783791A (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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202110171209.4A priority Critical patent/CN112783791B/en
Publication of CN112783791A publication Critical patent/CN112783791A/en
Application granted granted Critical
Publication of CN112783791B publication Critical patent/CN112783791B/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
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • 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
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

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)
  • Stored Programmes (AREA)

Abstract

The invention discloses a method and a device for generating an interface test case, wherein the method comprises the following steps: obtaining an interface definition document of a gateway server and a plurality of interface TRACE logs, wherein the interface definition document contains interface field definition information of a field group, and the interface TRACE logs comprise: interface field value corresponding to interface field definition information; generating a base layer JAVA object according to the interface field definition information; generating a data layer JAVA object according to each interface TRACE log, wherein the data layer JAVA object inherits a base layer JAVA object; comparing the plurality of interface TRACE logs, and generating a service layer JAVA object according to the comparison result, wherein the service layer JAVA object inherits the data layer JAVA object; and generating an interface test case according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object. The invention can improve the writing efficiency and reduce the cost.

Description

Interface test case generation method and device
Technical Field
The present invention relates to the field of software testing technologies, and in particular, to a method and an apparatus for generating an interface test case.
Background
The automatic test is a process of converting manual test behaviors into machine execution by constructing a test system corresponding to a tested system. The complete automated test process generally includes test environment preparation, data initialization, test execution, result verification, data cleaning, etc., and the entire process is repeatable and automated. In the process of automatic testing, an interface is used as an important component of up-and-down flow interaction, and important conservation is needed. The automated test engineers of the interface provider are faced with most work in daily life to write the automated test script of the interface, and how to write the automated test cases of the interface needs to be considered in the process of writing the interface.
Interface documents need to be defined before an interface is written, and interface documents can be tested by referring to the content of the interface documents. In writing an automated test case, a piece of interface class needs to be generated manually by referring to the definition of the document, and parameters in the interface may be many, and the more the parameters, the more time it takes. The test service scenes are different, different test cases are also required to be written, the workload of writing interface data and test scripts is very large, and the problems of high cost and low efficiency of writing the test cases exist.
Thus, there is a need for a solution for generating interface test cases that overcomes the above-mentioned problems.
Disclosure of Invention
The embodiment of the invention provides a method for generating an interface test case, which is used for generating the interface test case, improving writing efficiency and reducing cost, and comprises the following steps:
Obtaining an interface definition document of a gateway server and a plurality of interface TRACE logs, wherein the interface definition document comprises interface field definition information of a field group, and the interface field definition information comprises: interface field type, interface field length, interface field name, interface field description information; the interface TRACE log includes: interface field value corresponding to interface field definition information;
Generating a base layer JAVA object according to interface field definition information of a field group in the interface definition document;
Generating a data layer JAVA object according to each interface TRACE log, wherein the data layer JAVA object inherits a base layer JAVA object;
comparing the plurality of interface TRACE logs, and generating a service layer JAVA object according to a comparison result, wherein the service layer JAVA object inherits a data layer JAVA object;
and generating an interface test case according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object.
The embodiment of the invention provides a device for generating an interface test case, which is used for generating the interface test case, improving writing efficiency and reducing cost, and comprises the following steps:
The system comprises a log obtaining module, a gateway server and a plurality of gateway logs, wherein the log obtaining module is used for obtaining an interface definition document of the gateway server and a plurality of interface TRACE logs, the interface definition document comprises interface field definition information of a field group, and the interface field definition information comprises: interface field type, interface field length, interface field name, interface field description information; the interface TRACE log includes: interface field value corresponding to interface field definition information;
the base layer generating module is used for generating a base layer JAVA object according to interface field definition information of a field group in the interface definition document;
The data layer generating module is used for generating a data layer JAVA object according to each interface TRACE log, wherein the data layer JAVA object inherits the base layer JAVA object;
the service layer generating module is used for comparing the plurality of interface TRACE logs and generating a service layer JAVA object according to the comparison result, wherein the service layer JAVA object inherits the data layer JAVA object;
and the test case generation module is used for generating an interface test case according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object.
The embodiment of the invention also provides computer equipment, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the method for generating the interface test case.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program for executing the method for generating the interface test case.
The embodiment of the invention obtains an interface definition document of a gateway server and a plurality of interface TRACE logs, wherein the interface definition document comprises interface field definition information of a field group, and the interface field definition information comprises: interface field type, interface field length, interface field name, interface field description information; the interface TRACE log includes: interface field value corresponding to interface field definition information; generating a base layer JAVA object according to interface field definition information of a field group in the interface definition document; generating a data layer JAVA object according to each interface TRACE log, wherein the data layer JAVA object inherits a base layer JAVA object; comparing the plurality of interface TRACE logs, and generating a service layer JAVA object according to a comparison result, wherein the service layer JAVA object inherits a data layer JAVA object; and generating an interface test case according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object. According to the embodiment of the invention, the base layer JAVA object, the data layer JAVA object and the service layer JAVA object which have inheritance relations are generated according to the interface definition document and the plurality of interface TRACE logs of the gateway server, and further, the interface test cases are generated according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object, so that the interface test cases can be directly used for automatic testing of the interface, the multiplexing is convenient, the maintainability is higher, management and synchronization of case files are facilitated, further, the interface test cases are effectively generated, the writing efficiency is improved, and the cost is reduced.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art. In the drawings:
fig. 1 is a schematic diagram of a method for generating an interface test case according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a three-layer JAVA object inheritance relationship in an embodiment of the present invention;
FIGS. 3-5 are diagrams illustrating generation of transaction calling codes in accordance with embodiments of the present invention;
FIGS. 6-8 are diagrams illustrating the generation of assignment codes using interface definitions in an embodiment of the present invention;
fig. 9 to 15 are schematic diagrams of a method for generating an interface test case according to an embodiment of the present invention;
Fig. 16 is a diagram of a device for generating an interface test case according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention will be described in further detail with reference to the accompanying drawings. The exemplary embodiments of the present invention and their descriptions herein are for the purpose of explaining the present invention, but are not to be construed as limiting the invention.
In order to generate an interface test case, improve writing efficiency and reduce cost, an embodiment of the present invention provides a method for generating an interface test case, as shown in fig. 1, the method may include:
Step 101, obtaining an interface definition document of a gateway server and a plurality of interface TRACE logs, wherein the interface definition document contains interface field definition information of a field group, and the interface field definition information comprises: interface field type, interface field length, interface field name, interface field description information; the interface TRACE log includes: interface field value corresponding to interface field definition information;
102, generating a base layer JAVA object according to interface field definition information of a field group in an interface definition document;
step 103, generating a data layer JAVA object according to each interface TRACE log, wherein the data layer JAVA object inherits a base layer JAVA object;
step 104, comparing the plurality of interface TRACE logs, and generating a service layer JAVA object according to the comparison result, wherein the service layer JAVA object inherits the data layer JAVA object;
and 105, generating an interface test case according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object.
As can be seen from fig. 1, in the embodiment of the present invention, by obtaining an interface definition document of a gateway server and a plurality of interface TRACE logs, the interface definition document includes interface field definition information of a field group, where the interface field definition information includes: interface field type, interface field length, interface field name, interface field description information; the interface TRACE log includes: interface field value corresponding to interface field definition information; generating a base layer JAVA object according to interface field definition information of a field group in the interface definition document; generating a data layer JAVA object according to each interface TRACE log, wherein the data layer JAVA object inherits a base layer JAVA object; comparing the plurality of interface TRACE logs, and generating a service layer JAVA object according to a comparison result, wherein the service layer JAVA object inherits a data layer JAVA object; and generating an interface test case according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object. According to the embodiment of the invention, the base layer JAVA object, the data layer JAVA object and the service layer JAVA object which have inheritance relations are generated according to the interface definition document and the plurality of interface TRACE logs of the gateway server, and further, the interface test cases are generated according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object, so that the interface test cases can be directly used for automatic testing of the interface, the multiplexing is convenient, the maintainability is higher, management and synchronization of case files are facilitated, further, the interface test cases are effectively generated, the writing efficiency is improved, and the cost is reduced.
In an embodiment, an interface definition document of a gateway server and a plurality of interface track logs are obtained, wherein the interface definition document contains interface field definition information of a field group, and the interface field definition information includes: interface field type, interface field length, interface field name, interface field description information; the interface TRACE log includes: interface field definition information corresponds to an interface field value. And generating the JAVA object of the base layer according to the interface field definition information of the field group in the interface definition document. And generating a data layer JAVA object according to each interface TRACE log, wherein the data layer JAVA object inherits the base layer JAVA object. And comparing the plurality of interface TRACE logs, and generating a service layer JAVA object according to the comparison result, wherein the service layer JAVA object inherits the data layer JAVA object.
In this embodiment, in order to reduce the cost of case writing and reduce the time taken to first create the case script, the test case is written by automatically generating the case script, and then maintenance and modification are performed according to the case script. The generated case information is derived from the interface TRACE log and the interface definition document. The interface TRACE log records the log of the up-feed and down-feed of each interface call, and the log records the types, the lengths and the values of all the fields of the up-feed and the down-feed of the interface; the interface definition document has field names in addition to the type, length of each field. And generating base, data and service layer JAVA objects, namely base layer JAVA objects, data layer JAVA objects and service layer JAVA objects through interface TRACE logs and interface document definitions of the gateway server. The base layer JAVA object is used for defining the type, the length and the name of the interface field; the JAVA object of the data layer is used for assigning values to the data and generating field values of the TRACE log; the JAVA object of the service layer is applied to control service logic, and a plurality of logs are compared, and the field is assigned to the service layer as if the field value of the field is different from the field value of the log. The interface TRACE log is generally transaction data triggered by manual test and having practical business meaning, and the data are used for generating and assigning a value to a JAVA object. The base layer in the three layers generates default values through field types, the default values of the number types are 0, the default values of the character types are empty character strings, the data layer uses values of non-empty fields in the log to carry out assignment (the field and the log field values correspond to each other in sequence), and the fields and the values are related to each other in sequence through the sequence of the log and the interface fields. The service layer is a test service class, and extracts different values from the test cases by having different values for the same field in different logs. The embodiment of the invention generates the whole frame code of the case script, and generates the calling code of interaction with the gateway besides the assignment code for initiating the request to the gateway server. The generated case script can be directly used for automatic testing of the interface, and the efficiency of case writing can be improved by modifying the logic convenient increment test case of the business layer. The method has the characteristics of convenience in multiplexing, higher maintainability, convenience in managing and synchronizing the case files and the like. Support data layering. The user needs few concerned fields, only needs to pay attention to the exposed key service fields in the service scene class, and carries out assignment on the key service fields. Most of the other uploaded data is transparent to the user. The case resource has strong reusability, for example, the transaction which needs to be used in the scene can be directly called the business class corresponding to the transaction or the interface, and then the data source is properly configured. Serial execution of multiple transactions can be flexibly supported, and only data source input of the first case is concerned, and output results of the data source input can be provided for subsequent transaction references. The technical scheme of the invention is described in detail below.
The test case script generated by the invention has three layers of JAVA objects, the inheritance relationship of the test case script is shown in fig. 2, the interface definition class is automatically generated in the fixed catalog, if the interface field definition is unchanged, the user maintenance is not needed, the following two cases are object classes maintained by the user, and the functions of the four layers of objects are as follows: base layer: providing the capability of interacting with the host gateway, assembling the message and analyzing the returned message result. Definition layer: interface field definition, providing default value (0 or null, no traffic meaning) according to field type. Data layer: the default value with business meaning for the interface field is used as the interface basic data. Service layer: and assigning values to the important service fields, and connecting related interfaces in series to complete scene test.
If only the interface definition document is provided, no TRACE is provided, and only the definition layer has fields to perform default assignment in the three-layer JAVA object, the data layer and the service layer only generate codes, and no assignment is performed on the fields. The log includes input and output parameters of each field, and the input and output parameters are mainly used for assigning values to the fields in the generated case script. The log of the stock is typically either manually tested transaction data or data sent on the upstream caller interface, and typically most of the field sent values are close to the actual case.
In this embodiment, the field set includes: public field group and private field group, public field group is used for recording public processing result, and public processing result includes: and the private field group is used for recording the private processing result.
In specific implementation, the interface definition document contains definitions of all fields of the interface, field types, field lengths, field names and field descriptions. The field components are public field groups and private field groups, the public field groups are used for recording public processing result processing, such as system level processing, department level processing and application level processing public, for example, exception processing, error code processing, log registration, transaction sequence number and other fields which need to be used for processing are placed in the public field groups. The private field set is a field used by the interface, typically the input and output used by the interface. The caller can make a call through the definition of the fields by defining all the field definitions in the program in the calling program and assembling the uploading gateway server. After the interface is successfully called, the gateway records the field length and the field value of each field in the input and output process of each field of the call of the interface in sequence.
In this embodiment, comparing the plurality of interface TRACE logs, and generating a JAVA object of the service layer according to the comparison result includes: analyzing difference fields of private field groups in the TRACE logs of the plurality of interfaces; removing a time field and a sequence number field from the difference field; and generating the JAVA object of the service layer according to the residual difference fields.
In the implementation, if the same interface has a plurality of interface TRACE logs, the fields of the differences in the private field groups in the logs are analyzed, the fields without business significance such as time, serial numbers and the like are removed, and each field is combined to generate a test case script. User modification of maintenance test case scripts is a general direct modification of assignments in the business layer, if a scenario requires referencing multiple interfaces, then in the case method multiple data classes are concatenated into the scenario.
In an embodiment, according to the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object, an interface test case is generated.
In this embodiment, the method for generating an interface test case further includes: generating a two-dimensional character string array according to the interface field definition information, wherein the two-dimensional character string array is used for assembling and uploading a message of a gateway server and comprises the following components: the identification information is sent up and down, the interface field type, the interface field length, the field group name and the interface field name.
In specific implementation, the test script of the interface test case mainly includes:
1. Generating transaction call code
Generating transaction calling codes and codes for assisting in assertion, processing and generating field assignment parts, and enabling interfaces to cover different branches mainly through assignment control interfaces for modifying fields. The basis of the script generation is that all fields are converted into JAVA variables, and information such as the type length of the fields to be recorded is used for reading and assembling the information to form a report file. The interface call code is shown in fig. 4. The definition layer inherits DSRBase as shown in fig. 5, and can package the data to send to the gateway through Run method.
2. Generating assignment codes
The assignment part of the script generates the following modes according to different files:
1) Using interface TRACE log generation: and generating a JAVA variable for each field according to the length and the value of each field of the TRACE log of the interface. Because the interface TRACE log has no field name information, all fields will be distinguished by sequence numbers, e.g., one hundred fields, and the JAVA object definition layer will generate field 1, field 2 through field 100, and then assign values to the fields based on the input values of the records in the log. In this case, because the field cannot see business meaning, the field is difficult to maintain, and the generated case script is generally used for smoking test and testing the connectivity of the interface.
2) Using interface definition generation: the interface definition includes information such as field type, length, name, description, etc. Converted to JAVA variables in the definition layer as described above, as shown in fig. 6. The definition layer contains a two-dimensional array of field information and variables corresponding to each field. And each field is assigned a default value when the field type, the default value of the character type is an empty string, and the default value of the data type is 0. In order to facilitate assignment of characters, each field is sealed into an internal class according to field groups, a field group name+a field name can be used for assignment, and a corresponding field can be found more conveniently in combination with a prompt function of a code editor, as shown in fig. 7. In order to facilitate maintenance of field assignment, JAVA class of data layer is generated for field assignment, the class inherits definition class, field can be subjected to same value, annotation codes of all field assignment statement are generated, user copies corresponding assignment codes from assignment statement to obtain modified values, and assignment statement can be written according to code prompt, as shown in figure 8.
3) Using interface definition documents in combination with interface TRACE log generation: if there is an interface TRACE log based on the interface definition document, values input by fields of the TRACE file are generated in the data layer to generate assignment statements, and these assignments mainly solve connectivity problems of the interface, the interface program generally has some non-null or format checks of the fields, for example, some of these assignments are used to enable the interface to run through, for example, fields used in common processes such as exception processing, error code processing, log registration, transaction sequence number, etc. For some important fields, usually the fields in the private field of the interface that can control the key logic of the interface, the assignment statement needs to be extracted into the service class. In the process of generating, if the same interface has a plurality of interface TRACE logs, the fields of the differences in the private field groups in the logs are analyzed, the fields without business significance such as time, serial numbers and the like are removed, and each field is combined to generate a test case script. User modification of maintenance test case scripts is a general direct modification of assignments in the business layer, if a scenario requires referencing multiple interfaces, then in the case method multiple data classes are concatenated into the scenario.
A specific embodiment is given below to illustrate a specific application of the interface test case generating method in the embodiment of the present invention. In this embodiment, when the test case script is generated, an interface document definition and a TRACE log corresponding to the interface are needed, as shown in fig. 9, the interface definition document is a. Dsr suffix, and the interface TRACE log is the TRACE beginning. For ease of illustration, the interface file is simplified and some fields are reduced. There are three field sets COMMSTAT, COMECHAN, IMCHTR, COMMSTAT and COMECHAN at the beginning of COM are public field sets, IMCHTR are private field sets. The simplified interface definition document is shown in fig. 10. At the gateway server, the values of the fields up and down the interface are recorded, as follows for the fields up the three field sets COMMSTAT, COMECHAN, IMCHTR, and specific values can be used to aid in generating the test cases. The interface TRACE log is shown in fig. 11.
To facilitate the generation of test case scripts, the present disclosure developed eclipse plug-ins by clicking on the catalog that is to generate the case script, then clicking on the generate wizard menu, opening the wizard, as shown in FIG. 12. The wizard will place the definition class under a fixed directory by default, the data class will be placed under the dsr directory in the current (test case script) directory, dsr being the interface type abbreviation. Dragging the interface file into the generated list generates a row of records containing the interface name, interface description field networking message, and automatically fills in the interface related information, as shown in fig. 13. The second page of the wizard fills out test case related content is shown in fig. 14. As described above, the wizard will generate definition classes, data classes, and business classes, where the definition inherits the underlying class for the closed field upload to the host gateway server. The generated definition class does not need to be modified, encapsulates relevant fields in the interface file, maps the fields in the interface dsr file into JAVA fields, and simulates the concept of the region in the dsr file in an internal class mode. The class takes a default value for each field generated according to the type of dsr field of the interface document. The generated field is default m before the generated field group name, and the field name is default f.
The classes are defined in groups according to fields in the interface definition, one JAVA internal class per group object. Because of the definition of these internal classes, the fields can be more conveniently assigned when the business class and the data class assign the fields. The first layer prompts the internal class and the second layer prompts the fields in the internal class.
In the process of generating the data classes, an interface TRACE log is automatically connected to the gateway, field assignment in the log is analyzed, and one or more data classes are generated according to the limit of the number of the generated data classes set by a user. If the gateway server does not have an interface TRACE log, the fields of the data class are not assigned; if the gateway has 1 interface TRACE log, the field assignment of the data class is performed by using the field value sent in the file, and if the gateway has multiple interface TRACE logs, the combination types (excluding non-key fields such as date, serial number, etc.) in the private field group in the log are analyzed. If the number of combinations is less than or equal to the number limit set by the user, then all combinations generate a class of data, and sometimes the user can also select a class of data to be combined, extract the combinations of data into the test cases, one corresponding to each test case. If the number of combinations is greater than the number limit set by the user, then the most recent data combinations are selected for use in generating a plurality of data classes or test cases based on the temporal ordering of the data combinations. A test case in the test service class is shown in fig. 15, where the data class is referenced and the fields in the data class are assigned. Multiple data combinations (customer numbers and customer classifications) generate multiple test cases and may be further packaged or concatenated into scene cases.
The invention can be used for generating interface test case scripts and has the following advantages: support data layering. The user needs few concerned fields, only needs to pay attention to the exposed key service fields in the service scene class, and carries out assignment on the key service fields. Most of the other uploaded data is transparent to the user. Cases may be version managed, case shared, etc. directly on the CC. The case resource has strong reusability, for example, the transaction which needs to be used in the scene can be directly called the business class corresponding to the transaction or the interface, and then the data source is properly configured. Serial execution of multiple transactions can be flexibly supported, and only data source input of the first case is concerned, and output results of the data source input can be provided for subsequent transaction references. In the case writing process, common functions can be packaged and used as public functions, so that code redundancy is reduced.
Based on the same inventive concept, the embodiment of the invention also provides a device for generating the interface test case, as described in the following embodiment. Because the principles of solving the problems are similar to the method of generating the interface test cases, the implementation of the device can refer to the implementation of the method, and the repetition is omitted.
Fig. 16 is a block diagram of an apparatus for generating an interface test case according to an embodiment of the present invention, as shown in fig. 16, the apparatus includes:
The log obtaining module 161 is configured to obtain an interface definition document of the gateway server and a plurality of interface track logs, where the interface definition document includes interface field definition information of a field group, and the interface field definition information includes: interface field type, interface field length, interface field name, interface field description information; the interface TRACE log includes: interface field value corresponding to interface field definition information;
The base layer generating module 162 is configured to generate a base layer JAVA object according to interface field definition information of a field group in the interface definition document;
A data layer generating module 163, configured to generate a data layer JAVA object according to each interface TRACE log, where the data layer JAVA object inherits a base layer JAVA object;
A service layer generating module 164, configured to compare the plurality of interface TRACE logs, and generate a service layer JAVA object according to a comparison result, where the service layer JAVA object inherits the data layer JAVA object;
The test case generation module 165 is configured to generate an interface test case according to the base layer JAVA object, the data layer JAVA object, and the service layer JAVA object.
In one embodiment, the field set includes: public field group and private field group, public field group is used for recording public processing result, and public processing result includes: and the private field group is used for recording the private processing result.
In one embodiment, the business layer generation module 164 is further configured to:
Analyzing difference fields of private field groups in the TRACE logs of the plurality of interfaces;
removing a time field and a sequence number field from the difference field;
And generating the JAVA object of the service layer according to the residual difference fields.
In one embodiment, the device for generating an interface test case further includes:
the array generating module is used for generating a two-dimensional character string array according to the interface field definition information, and is used for assembling and uploading the message of the gateway server, and the two-dimensional character string array comprises: the identification information is sent up and down, the interface field type, the interface field length, the field group name and the interface field name.
In summary, the embodiment of the present invention obtains an interface definition document and a plurality of interface TRACE logs of a gateway server, where the interface definition document includes interface field definition information of a field group, and the interface field definition information includes: interface field type, interface field length, interface field name, interface field description information; the interface TRACE log includes: interface field value corresponding to interface field definition information; generating a base layer JAVA object according to interface field definition information of a field group in the interface definition document; generating a data layer JAVA object according to each interface TRACE log, wherein the data layer JAVA object inherits a base layer JAVA object; comparing the plurality of interface TRACE logs, and generating a service layer JAVA object according to a comparison result, wherein the service layer JAVA object inherits a data layer JAVA object; and generating an interface test case according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object. According to the embodiment of the invention, the base layer JAVA object, the data layer JAVA object and the service layer JAVA object which have inheritance relations are generated according to the interface definition document and the plurality of interface TRACE logs of the gateway server, and further, the interface test cases are generated according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object, so that the interface test cases can be directly used for automatic testing of the interface, the multiplexing is convenient, the maintainability is higher, management and synchronization of case files are facilitated, further, the interface test cases are effectively generated, the writing efficiency is improved, and the cost is reduced.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Finally, it should be noted that: the above examples are only specific embodiments of the present invention, and are not intended to limit the scope of the present invention, but it should be understood by those skilled in the art that the present invention is not limited thereto, and that the present invention is described in detail with reference to the foregoing examples: any person skilled in the art may modify or easily conceive of the technical solution described in the foregoing embodiments, or perform equivalent substitution of some of the technical features, while remaining within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (6)

1. A method for generating an interface test case, comprising:
Obtaining an interface definition document of a gateway server and a plurality of interface TRACE logs, wherein the interface definition document comprises interface field definition information of a field group, and the interface field definition information comprises: interface field type, interface field length, interface field name, interface field description information; the interface TRACE log includes: interface field value corresponding to interface field definition information; the interface TRACE log is transaction data triggered by manual test and having actual business significance;
Generating a base layer JAVA object according to interface field definition information of a field group in the interface definition document;
Generating a data layer JAVA object according to each interface TRACE log, wherein the data layer JAVA object inherits a base layer JAVA object;
comparing the plurality of interface TRACE logs, and generating a service layer JAVA object according to a comparison result, wherein the service layer JAVA object inherits a data layer JAVA object;
generating an interface test case according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object;
Wherein the field set includes: public field group and private field group, public field group is used for recording public processing result, and public processing result includes: the system level processing results, the department level processing results and one or any combination of the application level processing results, wherein the private field group is used for recording the private processing results;
Comparing the plurality of interface TRACE logs, generating a service layer JAVA object according to the comparison result, including:
Analyzing difference fields of private field groups in the TRACE logs of the plurality of interfaces;
removing a time field and a sequence number field from the difference field;
Generating a JAVA object of the service layer according to the residual difference field; wherein the service layer JAVA object is used to control the service logic.
2. The method of generating interface test cases of claim 1, further comprising:
generating a two-dimensional character string array according to the interface field definition information, wherein the two-dimensional character string array is used for assembling and uploading a message of a gateway server and comprises the following components: the identification information is sent up and down, the interface field type, the interface field length, the field group name and the interface field name.
3. An apparatus for generating interface test cases, comprising:
the system comprises a log obtaining module, a gateway server and a plurality of gateway logs, wherein the log obtaining module is used for obtaining an interface definition document of the gateway server and a plurality of interface TRACE logs, the interface definition document comprises interface field definition information of a field group, and the interface field definition information comprises: interface field type, interface field length, interface field name, interface field description information; the interface TRACE log includes: interface field value corresponding to interface field definition information; the interface TRACE log is transaction data triggered by manual test and having actual business significance;
the base layer generating module is used for generating a base layer JAVA object according to interface field definition information of a field group in the interface definition document;
The data layer generating module is used for generating a data layer JAVA object according to each interface TRACE log, wherein the data layer JAVA object inherits the base layer JAVA object;
the service layer generating module is used for comparing the plurality of interface TRACE logs and generating a service layer JAVA object according to the comparison result, wherein the service layer JAVA object inherits the data layer JAVA object;
the test case generation module is used for generating an interface test case according to the base layer JAVA object, the data layer JAVA object and the service layer JAVA object;
Wherein the field set includes: public field group and private field group, public field group is used for recording public processing result, and public processing result includes: the system level processing results, the department level processing results and one or any combination of the application level processing results, wherein the private field group is used for recording the private processing results;
the business layer generating module is further configured to:
Analyzing difference fields of private field groups in the TRACE logs of the plurality of interfaces;
removing a time field and a sequence number field from the difference field;
Generating a JAVA object of the service layer according to the residual difference field; wherein the service layer JAVA object is used to control the service logic.
4. The interface test case generation apparatus of claim 3, further comprising:
the array generating module is used for generating a two-dimensional character string array according to the interface field definition information, and is used for assembling and uploading the message of the gateway server, and the two-dimensional character string array comprises: the identification information is sent up and down, the interface field type, the interface field length, the field group name and the interface field name.
5. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of claims 1 to 2 when executing the computer program.
6. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program which, when executed by a processor, implements the method of any of claims 1 to 2.
CN202110171209.4A 2021-02-08 2021-02-08 Interface test case generation method and device Active CN112783791B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110171209.4A CN112783791B (en) 2021-02-08 2021-02-08 Interface test case generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110171209.4A CN112783791B (en) 2021-02-08 2021-02-08 Interface test case generation method and device

Publications (2)

Publication Number Publication Date
CN112783791A CN112783791A (en) 2021-05-11
CN112783791B true CN112783791B (en) 2024-05-24

Family

ID=75761249

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110171209.4A Active CN112783791B (en) 2021-02-08 2021-02-08 Interface test case generation method and device

Country Status (1)

Country Link
CN (1) CN112783791B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117251384B (en) * 2023-11-17 2024-01-30 南京掌控网络科技有限公司 Interface automation test case generation method and system

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104360920A (en) * 2014-12-02 2015-02-18 微梦创科网络科技(中国)有限公司 Automatic testing method and device for interface
CN104407976A (en) * 2014-11-28 2015-03-11 联动优势电子商务有限公司 Method and device for generating interface robustness test case
CN106815138A (en) * 2015-12-01 2017-06-09 北京奇虎科技有限公司 A kind of method and apparatus for generating interface testing use-case
CN110287069A (en) * 2019-05-21 2019-09-27 平安银行股份有限公司 ESB automatic interface testing method, server and computer readable storage medium
CN111045928A (en) * 2019-11-14 2020-04-21 用友网络科技股份有限公司 Interface data testing method, device, terminal and storage medium
CN111382074A (en) * 2020-03-09 2020-07-07 摩拜(北京)信息技术有限公司 Interface test method and device and electronic equipment
CN112241370A (en) * 2020-10-21 2021-01-19 网易(杭州)网络有限公司 Verification method, system and device for API (application program interface) interface class

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104407976A (en) * 2014-11-28 2015-03-11 联动优势电子商务有限公司 Method and device for generating interface robustness test case
CN104360920A (en) * 2014-12-02 2015-02-18 微梦创科网络科技(中国)有限公司 Automatic testing method and device for interface
CN106815138A (en) * 2015-12-01 2017-06-09 北京奇虎科技有限公司 A kind of method and apparatus for generating interface testing use-case
CN110287069A (en) * 2019-05-21 2019-09-27 平安银行股份有限公司 ESB automatic interface testing method, server and computer readable storage medium
CN111045928A (en) * 2019-11-14 2020-04-21 用友网络科技股份有限公司 Interface data testing method, device, terminal and storage medium
CN111382074A (en) * 2020-03-09 2020-07-07 摩拜(北京)信息技术有限公司 Interface test method and device and electronic equipment
CN112241370A (en) * 2020-10-21 2021-01-19 网易(杭州)网络有限公司 Verification method, system and device for API (application program interface) interface class

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
数据分层的接口自动化测试框架设计与应用;林萍;;信息技术(05);正文第1-4节 *

Also Published As

Publication number Publication date
CN112783791A (en) 2021-05-11

Similar Documents

Publication Publication Date Title
US8719784B2 (en) Assigning runtime artifacts to software components
CN108964968B (en) Service access management method and system in container cloud environment
US8707263B2 (en) Using a DSL for calling APIS to test software
CN110008113B (en) Test method and device and electronic equipment
CN106775744B (en) Method and device for generating static library
CN112394942B (en) Distributed software development compiling method and software development platform based on cloud computing
CN111090433A (en) Data processing method, device and storage medium
CN106227654B (en) A kind of test platform
CN107479866B (en) Method for realizing application data and functions of open terminal based on reconstruction technology
CN109739704A (en) A kind of interface test method, server-side and computer readable storage medium
CN116149747A (en) Interface arrangement method, device, electronic equipment and computer readable storage medium
CN112783791B (en) Interface test case generation method and device
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN108595656B (en) Data processing method and system
CN112379871A (en) Data processing method and device
JP2011515755A (en) Development method and apparatus for reserved component container base software
US20190317877A1 (en) Application state monitoring
US9996799B2 (en) Migrating a legacy system by inferring context-sensitive business rules from legacy source code
US20220365758A1 (en) Tool for Introspection in Object-Oriented Source Code
CN112596823B (en) Safety control method and device and electronic equipment
CN108762745B (en) Service script generation method and device
CN114115982A (en) Code issuing method, device, equipment and storage medium
CN111880775A (en) Multi-module layered architecture implementation method and device, electronic equipment and storage medium
CN111708526B (en) API writing method
Chagas et al. Kdm as the underlying metamodel in architecture-conformance checking

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