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

Interface test case generation method and device Download PDF

Info

Publication number
CN112783791A
CN112783791A CN202110171209.4A CN202110171209A CN112783791A CN 112783791 A CN112783791 A CN 112783791A CN 202110171209 A CN202110171209 A CN 202110171209A CN 112783791 A CN112783791 A CN 112783791A
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.)
Pending
Application number
CN202110171209.4A
Other languages
Chinese (zh)
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/CN112783791A/en
Publication of CN112783791A publication Critical patent/CN112783791A/en
Pending legal-status Critical Current

Links

Images

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 and a plurality of interface TRACE logs of a gateway server, wherein the interface definition document comprises interface field definition information of field groups, and the interface TRACE logs comprise: interface field definition information is corresponding to the interface field value; generating a basic layer JAVA object according to the interface field definition information; generating a data layer JAVA object according to the TRACE log of each interface, wherein the data layer JAVA object inherits the basic layer JAVA object; comparing the TRACE logs of the plurality of interfaces, and generating a service layer JAVA object according to a comparison result, wherein the service layer JAVA object inherits the data layer JAVA object; and generating an interface test case according to the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object. The invention can improve the compiling efficiency and reduce the cost.

Description

Interface test case generation method and device
Technical Field
The invention relates to the technical field of software testing, in particular to a method and a device for generating an interface testing case.
Background
The automatic test is a process of converting manual test behavior into machine execution by building a test system corresponding to a tested system. The complete automated testing process generally includes test environment preparation, data initialization, test execution, result checking, data cleaning, and the like, and the whole process is repeatable and automated. In the process of automatic testing, an interface is used as an important component of up-down flow interaction, and important protection is needed. An automated test engineer of an interface provider needs to write an interface automated test script in daily life, and how to write an automated test case of an interface needs to be considered in the interface writing process.
Before programming the interface, the interface document needs to be defined, and the content of the interface document is referred to, so that the interface can be tested. In writing an automated test case, an interface class needs to be generated by manually referring to the definition of a document, parameters in the interface can be many, and more parameters take more time. Different test cases need to be compiled due to different test service scenes, the workload of compiling interface data and test scripts is very large, and the problems of high cost and low efficiency of compiling the test cases exist.
Therefore, a solution for generating interface test cases that can overcome the above problems is needed.
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 the compiling efficiency and reducing the cost, and comprises the following steps:
obtaining an interface definition document and a plurality of interface TRACE logs of a gateway server, 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 and interface field description information; the interface TRACE log comprises: interface field definition information is corresponding to the interface field value;
generating a basic layer JAVA object according to interface field definition information of a field group in an 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 TRACE logs of the plurality of interfaces, 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 basic layer JAVA object, the data layer JAVA object and the service layer JAVA object.
The embodiment of the invention provides a generating device of an interface test case, which is used for generating the interface test case, improving the compiling efficiency and reducing the cost, and comprises the following components:
a log obtaining module, configured to obtain an interface definition document and multiple 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 and interface field description information; the interface TRACE log comprises: interface field definition information is corresponding to the interface field value;
the basic layer generating module is used for generating a basic layer JAVA object according to the interface field definition information of the 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 a basic layer JAVA object;
the service layer generating module is used for comparing the TRACE logs of the plurality of interfaces and generating a service layer JAVA object according to a comparison result, wherein the service layer JAVA object inherits the data layer JAVA object;
and the test case generating module is used for generating an interface test case according to the basic 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 which is stored on the memory and can run on the processor, wherein the processor executes the generation method of the interface test case.
The embodiment of the invention also provides a computer readable storage medium, which stores a computer program for executing the interface test case generation method.
The embodiment of the invention obtains an interface definition document and a plurality of interface TRACE logs of a gateway server, 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 and interface field description information; the interface TRACE log comprises: interface field definition information is corresponding to the interface field value; generating a basic layer JAVA object according to interface field definition information of a field group in an 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 TRACE logs of the plurality of interfaces, 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 basic layer JAVA object, the data layer JAVA object and the service layer JAVA object. According to the embodiment of the invention, the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object with inheritance relationship are generated according to the interface definition document and the plurality of interface TRACE logs of the gateway server, and then the interface test case is generated according to the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts. In the drawings:
FIG. 1 is a schematic diagram illustrating a method for generating an interface test case according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating an inheritance relationship between three layers of JAVA objects according to an embodiment of the present invention;
FIGS. 3-5 are schematic diagrams of generation of transaction invocation code in an embodiment of the present invention;
FIGS. 6-8 are diagrams illustrating the generation of assignment codes using interface definitions in embodiments of the present invention;
FIGS. 9-15 are schematic diagrams illustrating a method for generating an interface test case according to an embodiment of the present invention;
fig. 16 is a structural diagram of an interface test case generation apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present 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, where as shown in fig. 1, the method may include:
step 101, obtaining an interface definition document and a plurality of interface TRACE logs of a gateway server, 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 and interface field description information; the interface TRACE log comprises: interface field definition information is corresponding to the interface field value;
102, generating a basic 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 the TRACE log of each interface, wherein the data layer JAVA object inherits a basic layer JAVA object;
step 104, comparing the TRACE logs of the plurality of interfaces, 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 105, generating an interface test case according to the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object.
As shown in fig. 1, it can be known that, in the embodiment of the present invention, an interface definition document and a plurality of interface TRACE logs of a gateway server are obtained, 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 and interface field description information; the interface TRACE log comprises: interface field definition information is corresponding to the interface field value; generating a basic layer JAVA object according to interface field definition information of a field group in an 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 TRACE logs of the plurality of interfaces, 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 basic layer JAVA object, the data layer JAVA object and the service layer JAVA object. According to the embodiment of the invention, the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object with inheritance relationship are generated according to the interface definition document and the plurality of interface TRACE logs of the gateway server, and then the interface test case is generated according to the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object.
In an embodiment, an interface definition document and a plurality of interface TRACE logs of a gateway server are obtained, 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 and interface field description information; the interface TRACE log comprises: the interface field defines the interface field value corresponding to the information. And generating a basic layer JAVA object 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 the TRACE log of each interface, wherein the data layer JAVA object inherits the base layer JAVA object. Comparing the TRACE logs of the plurality of interfaces, and generating a service layer JAVA object according to a comparison result, wherein the service layer JAVA object inherits the data layer JAVA object.
In the embodiment, in order to reduce the case writing cost and reduce the time taken for making the case script for the first time, the test case is written by using a mode of 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 uploading and downloading of each interface call, and the log records the types, lengths and values of all fields of the interface uploading and downloading; the interface definition document has field names in addition to the type, length, and so on of each field. And generating three-layer JAVA objects of a base layer, data and a service layer, namely a JAVA object of the base layer, a JAVA object of the data layer and a JAVA object of the service layer, through the definition of an interface TRACE log and an interface document of the gateway server. The basic layer JAVA object is used for defining the type, the length and the name of an interface field; the data layer JAVA object is used for assigning values to data and generating the data by using a field value of an interface TRACE log; the JAVA object of the service layer is correspondingly applied to control service logic, a plurality of logs are compared, and a field is assigned to the service layer as if the field value of the log is different when the field is different. The interface TRACE log is generally transaction data with actual service significance triggered by manual test, and the data is used for generating JAVA objects and assigning values to the JAVA objects. The basic layer in the three layers generates default values through field types, the default value of the number type is 0, the default value of the character type is a null character string, the data layer uses the values of non-null fields in the log to assign values (the fields and the log field values correspond in sequence), and the fields and the values are related in sequence through the sequence of the log and the interface fields. The service layer is a test service class, and different values are extracted into 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 interactive calling code with the gateway for initiating the request to the gateway server besides the assignment code. The generated case script can be directly used for the automatic test of the interface, and the case compiling efficiency can be improved by modifying the logic convenient incremental test case of the service layer. The method has the characteristics of convenient reuse, higher maintainability, convenience for managing and synchronizing case files and the like. Data layering is supported. The fields which need to be concerned by the user are few, and only the key service fields exposed in the service scene class need to be concerned and assigned. Most of the other data uploaded is transparent to the user. The case resources have strong reusability, and if the transaction needs to be used in a scene, the business class corresponding to the transaction or the interface can be directly called, and then the data source is properly configured. The serial execution of a plurality of transactions can be flexibly supported, only the data source input of the first case needs to be concerned, and the output result can be provided for the reference of the subsequent transaction. The technical solution of the present invention will be explained in detail below.
The test case script generated by the invention has three layers of JAVA objects, the inheritance relationship of the JAVA objects is shown in FIG. 2, the interface definition class is automatically generated in the fixed directory, 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 four layers of object functions are as follows: base layer: providing the capability of interacting with the host gateway, assembling the message and analyzing the returned message result. Defining a layer: interface field definitions, providing default values (0 or null, no business meaning) depending on the field type. And (3) a data layer: the default value of the interface field with service significance is used as the interface basic data. And (4) a service layer: and (5) assigning values to the important service fields, and connecting the related interfaces in series to complete scene testing.
It should be noted that, if only the interface definition document is available and there is no TRACE, in generating a three-layer JAVA object, only the definition layer has fields to perform default assignment, and the data layer and the service layer only generate codes and do not perform assignment on the fields. The log comprises 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 inventory is typically transaction data that is manually tested or data sent on the upstream caller interface, and most of the fields are typically sent with values close to actual.
In this embodiment, the field group includes: the method comprises the following steps of a public field group and a private field group, wherein the public field group is used for recording a public processing result, and the public processing result comprises: and the private field group is used for recording the private processing result.
In specific implementation, the interface definition document includes definitions of all fields of the interface, field types, field lengths, field names and field descriptions. The field groups are divided into public field groups and private field groups, the public field groups are used for recording fields required by public processing result processing, such as system level processing, department level processing and application level processing, for example exception processing, error code processing, log registration, transaction sequence number and the like, and the fields are placed in the public field groups. The private field set is the field used by the interface, typically the input and output used with the interface. The caller can call through the definition of the field, define all field definitions in the procedure and assemble and send to the gateway server in the calling procedure. After the interface TRACE log is successfully called, the gateway can record the field length and the field value of each field in the input and output process of each field called by the interface in sequence.
In this embodiment, comparing the interface TRACE logs, and generating a service layer JAVA object according to a comparison result includes: analyzing the difference fields of the 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 a service layer JAVA object according to the residual difference fields.
In specific implementation, if the same interface has a plurality of interface TRACE logs, different fields in a private field group in the logs are analyzed, fields without service significance such as time, sequence numbers and the like are excluded, and each field is combined to generate a test case script. The user modifies the maintenance test case script to generally directly modify the assignment in the business layer, and if one scene needs to refer to a plurality of interfaces, a plurality of data classes are connected in series to form the scene in the case method.
In the embodiment, the interface test case is generated according to the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object.
In this embodiment, the method for generating the 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 the message which is sent to a gateway server, and comprises the following components: and sending identification information, interface field types, interface field lengths, field group names and interface field names up and down.
In specific implementation, the test script of the interface test case mainly comprises:
1. generating transaction invocation code
Generating a transaction calling code and an auxiliary assertion code, processing and generating a field assignment part, wherein the interface mainly covers different branches by modifying the assignment control interface of the field. The basis of generating the script is to convert all fields into JAVA variables, and the information such as the type length of the fields needs to be recorded and is used for reading and assembling the messages into the report file, the scheme is to store the relevant information of the fields into a two-dimensional character string array, as shown in figure 3, the two-dimensional array comprises a report identification, a field type, a field length, a field group name and a field name, and the two-dimensional array is used for reading and assembling the message and sending the message to the gateway server. The interface call code is shown in fig. 4. Definition layer as shown in fig. 5, it inherits DSRBase, and can pack data by Run method and send it to gateway.
2. Generating assignment code
The assignment part of the script is generated according to different files as follows:
1) using interface TRACE log generation: and generating a JAVA variable according to the length and the value of each field of the interface TRACE log. Since the interface TRACE log has no field name information, all fields are distinguished by sequence numbers, if there are one hundred fields, the JAVA object definition layer will generate field 1, field 2 to field 100, and then assign values to the fields according to the input values of the records in the log. In this case, the fields cannot see the business significance and are difficult to maintain, and the case script is generated and generally used for smoking test and testing the connectivity of the interface.
2) Generating using the interface definition: the interface definition includes information such as field type, length, name, description, etc. The conversion into JAVA variables in the definition layer is as described above, as shown in fig. 6. And a two-dimensional array containing field information in the definition layer and a variable corresponding to each field. And when the field type of each field is assigned with a default value, the default value of the character type is a null character string, and the default value of the data type is 0. In order to facilitate assignment of characters, fields are enclosed into an internal class according to field groups, field group names + field names can be used for assignment, and corresponding fields can be found more conveniently by combining with a prompt function of a code editor, as shown in fig. 7. In order to more conveniently maintain the assignment of the field, a JAVA class of the data layer is generated for assigning the field, the class inherits the definition class, the field can be homomorphic, annotation codes of assignment statements of all fields are generated, a user copies the corresponding assignment codes from the assignment statements to modify the values, and the assignment statements can also be written according to code prompts, as shown in fig. 8.
3) Using the interface definition document in conjunction with interface TRACE log generation: if there is also interface TRACE log on the basis of interface definition document, it will generate assignment statements for the values input by the TRACE file fields in the data layer, these assignments mainly solve the connectivity problem of the interface, and the interface program generally has some non-empty or format checks of the fields, for example, some fields that have these assignments, can make the interface go through, such as fields for common processing, e.g. 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 generating process, if the same interface has a plurality of interface TRACE logs, different fields in a private field group in the logs are analyzed, fields without service significance such as time, sequence numbers and the like are excluded, and each field is combined to generate a test case script. The user modifies the maintenance test case script to generally directly modify the assignment in the business layer, and if one scene needs to refer to a plurality of interfaces, a plurality of data classes are connected in series to form the scene in the case method.
A specific embodiment is given below to illustrate a specific application of the interface test case generation method in the embodiment of the present invention. In this embodiment, when generating the test case script, the interface document definition and the 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 beginning of TRACE. For ease of illustration, the interface file is simplified, with some fields reduced. There are three field groups COMMSTAT, COMECHAN, IMCHTR, COMMSTAT and COMECHAN at the beginning of COM being public field groups and IMCHTR being private field groups. The simplified interface definition document is shown in fig. 10. On the gateway server, the values of the fields sent up and down by the interface are recorded, as follows, the fields sent up by the three field groups COMMSTAT, COMECHAN and IMCHTR, and the specific values can be used to generate the test case with assistance. The interface TRACE log is shown in FIG. 11.
To facilitate the generation of test case scripts, the present inventor developed an eclipse plug-in that opens the wizard by clicking on the directory where the case scripts are to be generated, and then clicking on the generate wizard menu, as shown in fig. 12. The wizard will default the definition class to a fixed directory and the data class will be placed in the current (test case script) directory in the dsr directory, the dsr is the interface type for short. Dragging the interface file into the generated list generates a line of record containing the interface name, and the interface description field is networked to retrieve the relevant information of the interface and automatically fill in the information, as shown in fig. 13. The second page in the guide fills out the content related to the test case as shown in fig. 14. As described above, the wizard may generate a definition class, a data class, and a business class, where the definition inherits the base class for closed field uploading to the host gateway server. The generated definition class does not need to be modified, the class encapsulates relevant fields in the interface file, maps the fields in the interface dsr file into JAVA fields, and simulates the concept of distinguishing the regions in the dsr file in the mode of internal classes. The class takes default values for each field generated according to the type of the dsr field of the interface document. The fields are generated to avoid the names beginning with numbers, the default is m before the field group name is generated, and f is added to the field name by default.
The definition classes are grouped by fields in the interface definition, each grouping object being a JAVA inner class. As these inner classes are defined, assignment of fields can be more conveniently performed when service classes and data classes assign fields. The first layer suggests inner classes and the second layer suggests fields in inner classes.
In the process of generating the data classes, the gateway is automatically connected to obtain the TRACE log of the interface, the field assignment in the log is analyzed, and one or more data classes are generated according to the quantity limit of the generated data classes set by a user. If the gateway server does not have an interface TRACE log, assigning no value to the field of the data class; if the gateway has 1 interface TRACE log, the uploading field value in the file is used for field assignment of data class, if the gateway has a plurality of interface TRACE logs, the combination type (excluding non-key fields such as date, sequence number and the like) in a private field group in the log is analyzed. If the number of the combinations is less than or equal to the number limit set by the user, all the combinations generate data classes, and the user can select the combined data classes to extract the data combinations into the test cases, wherein one data combination corresponds to one test case. If the number of combinations is greater than the number limit set by the user, the latest several data combinations are selected for generating the plurality of data classes or test cases according to the time ordering of the data combinations. FIG. 15 illustrates a test case in a test business class, referencing a data class, and assigning values to fields in the data class. Multiple data combinations (customer number and customer classification) generate multiple test cases and can be further packaged or concatenated into a scenario case.
The invention can be used for generating the interface test case script, and has the following advantages: data layering is supported. The fields which need to be concerned by the user are few, and only the key service fields exposed in the service scene class need to be concerned and assigned. Most of the other data uploaded is transparent to the user. Cases may be versioning, case sharing, etc. directly on the CC. The case resources have strong reusability, and if the transaction needs to be used in a scene, the business class corresponding to the transaction or the interface can be directly called, and then the data source is properly configured. The serial execution of a plurality of transactions can be flexibly supported, only the data source input of the first case needs to be concerned, and the output result can be provided for the reference of the subsequent transaction. In the case writing process, a common function can be packaged and used as a common function, and the code redundancy is reduced.
Based on the same inventive concept, the embodiment of the present invention further provides a device for generating an interface test case, as described in the following embodiments. Because the principles of solving the problems are similar to the generation method of the interface test case, the implementation of the device can refer to the implementation of the method, and repeated details are not repeated.
Fig. 16 is a structural diagram of an apparatus for generating an interface test case according to an embodiment of the present invention, and as shown in fig. 16, the apparatus includes:
a log obtaining module 161, configured to obtain an interface definition document of a gateway server and a plurality of interface TRACE 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 and interface field description information; the interface TRACE log comprises: interface field definition information is corresponding to the interface field value;
the base layer generating module 162 is configured to generate a base layer JAVA object according to the interface field definition information of the 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 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;
and the test case generating 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 set of fields includes: the method comprises the following steps of a public field group and a private field group, wherein the public field group is used for recording a public processing result, and the public processing result comprises: and the private field group is used for recording the private processing result.
In one embodiment, the business layer generating module 164 is further configured to:
analyzing the difference fields of the 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 a service layer JAVA object according to the residual difference fields.
In one embodiment, the apparatus for generating an interface test case further includes:
an array generating module, configured to generate a two-dimensional string array according to the interface field definition information, where the two-dimensional string array is used to assemble a packet that is uploaded to a gateway server, and the two-dimensional string array includes: and sending identification information, interface field types, interface field lengths, field group names and interface field names up and down.
In summary, in the embodiment of the present invention, an interface definition document and a plurality of interface traue logs of a gateway server are obtained, 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 and interface field description information; the interface TRACE log comprises: interface field definition information is corresponding to the interface field value; generating a basic layer JAVA object according to interface field definition information of a field group in an 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 TRACE logs of the plurality of interfaces, 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 basic layer JAVA object, the data layer JAVA object and the service layer JAVA object. According to the embodiment of the invention, the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object with inheritance relationship are generated according to the interface definition document and the plurality of interface TRACE logs of the gateway server, and then the interface test case is generated according to the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object.
As will be appreciated by one skilled in the art, 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 flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams 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-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A method for generating an interface test case is characterized by comprising the following steps:
obtaining an interface definition document and a plurality of interface TRACE logs of a gateway server, 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 and interface field description information; the interface TRACE log comprises: interface field definition information is corresponding to the interface field value;
generating a basic layer JAVA object according to interface field definition information of a field group in an 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 TRACE logs of the plurality of interfaces, 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 basic layer JAVA object, the data layer JAVA object and the service layer JAVA object.
2. The method for generating an interface test case of claim 1, wherein the field set comprises: the method comprises the following steps of a public field group and a private field group, wherein the public field group is used for recording a public processing result, and the public processing result comprises: and the private field group is used for recording the private processing result.
3. The method for generating interface test cases according to claim 2, wherein comparing the plurality of interface TRACE logs and generating a business layer JAVA object according to the comparison result comprises:
analyzing the difference fields of the 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 a service layer JAVA object according to the residual difference fields.
4. The method for generating interface test cases according to 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 the message which is sent to a gateway server, and comprises the following components: and sending identification information, interface field types, interface field lengths, field group names and interface field names up and down.
5. An apparatus for generating interface test cases, comprising:
a log obtaining module, configured to obtain an interface definition document and multiple 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 and interface field description information; the interface TRACE log comprises: interface field definition information is corresponding to the interface field value;
the basic layer generating module is used for generating a basic layer JAVA object according to the interface field definition information of the 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 a basic layer JAVA object;
the service layer generating module is used for comparing the TRACE logs of the plurality of interfaces and generating a service layer JAVA object according to a comparison result, wherein the service layer JAVA object inherits the data layer JAVA object;
and the test case generating module is used for generating an interface test case according to the basic layer JAVA object, the data layer JAVA object and the service layer JAVA object.
6. The apparatus for generating interface test cases of claim 5, wherein the field sets comprise: the method comprises the following steps of a public field group and a private field group, wherein the public field group is used for recording a public processing result, and the public processing result comprises: and the private field group is used for recording the private processing result.
7. The apparatus for generating interface test cases of claim 6, wherein the business layer generation module is further configured to:
analyzing the difference fields of the 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 a service layer JAVA object according to the residual difference fields.
8. The apparatus for generating interface test cases of claim 5, further comprising:
an array generating module, configured to generate a two-dimensional string array according to the interface field definition information, where the two-dimensional string array is used to assemble a packet that is uploaded to a gateway server, and the two-dimensional string array includes: and sending identification information, interface field types, interface field lengths, field group names and interface field names up and down.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 4 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for executing the method of any one of claims 1 to 4.
CN202110171209.4A 2021-02-08 2021-02-08 Interface test case generation method and device Pending CN112783791A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110171209.4A CN112783791A (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 CN112783791A (en) 2021-02-08 2021-02-08 Interface test case generation method and device

Publications (1)

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

Family

ID=75761249

Family Applications (1)

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

Country Status (1)

Country Link
CN (1) CN112783791A (en)

Cited By (1)

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

Citations (5)

* 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
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

Patent Citations (5)

* 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
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

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
林萍;: "数据分层的接口自动化测试框架设计与应用", 信息技术, no. 05, pages 1 - 4 *

Cited By (2)

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

Similar Documents

Publication Publication Date Title
CN108279902B (en) Lua script technology based multi-terminal sharing bottom layer framework generation and application method
CN109783388B (en) UI (user interface) automatic testing method and device and electronic equipment
CN106775744B (en) Method and device for generating static library
US20110258600A1 (en) Using a dsl for calling apis to test software
CN112835560A (en) WEB multi-terminal low-code intelligent software development platform
CN111090433A (en) Data processing method, device and storage medium
CN108845940A (en) A kind of enterprise information system automated function test method and system
CN110532182B (en) Automatic testing method and device for virtualization platform
CN112363953B (en) Interface test case generation method and system based on crawler technology and rule engine
CN107479866B (en) Method for realizing application data and functions of open terminal based on reconstruction technology
CN110069259A (en) Analytic method, device, electronic equipment and storage medium based on idl file
CN109739704A (en) A kind of interface test method, server-side and computer readable storage medium
CN114064213A (en) Kubernets container environment-based rapid arranging service method and system
CN116149747A (en) Interface arrangement method, device, electronic equipment and computer readable storage medium
CN117112060A (en) Component library construction method and device, electronic equipment and storage medium
CN112783791A (en) Interface test case generation method and device
CN114416547A (en) Test case based test method
CN115525534A (en) Test case generation method and platform based on swagger interface test
CN117370203A (en) Automatic test method, system, electronic equipment and storage medium
CN112241625A (en) Method and system for automatically generating contract document based on java language
CN112379871A (en) Data processing method and device
CN115934093A (en) Applet cross-terminal application method, related device and computer storage medium
US9996799B2 (en) Migrating a legacy system by inferring context-sensitive business rules from legacy source code
CN114895880A (en) Code generation method and device and computer readable medium
CN114281341A (en) Compiling method and device of data structure definition file, computer equipment and medium

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