[go: up one dir, main page]

CN119938501A - Interface testing method and device - Google Patents

Interface testing method and device Download PDF

Info

Publication number
CN119938501A
CN119938501A CN202311434421.0A CN202311434421A CN119938501A CN 119938501 A CN119938501 A CN 119938501A CN 202311434421 A CN202311434421 A CN 202311434421A CN 119938501 A CN119938501 A CN 119938501A
Authority
CN
China
Prior art keywords
interface
message
scene
request
scene classification
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
CN202311434421.0A
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.)
Beijing Jd Yuansheng Technology Co ltd
Original Assignee
Beijing Jd Yuansheng Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jd Yuansheng Technology Co ltd filed Critical Beijing Jd Yuansheng Technology Co ltd
Priority to CN202311434421.0A priority Critical patent/CN119938501A/en
Publication of CN119938501A publication Critical patent/CN119938501A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

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)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses an interface testing method and device, and relates to the technical field of computers. The method comprises the steps of collecting a plurality of interface request messages of a target system in a statistics period, carrying out scene classification and marking processing on the plurality of interface request messages, dividing the plurality of interface request messages into a plurality of request packets, determining a scene calling sequence of each scene classification corresponding to the request packets for each request packet, determining the scene classification of each interface request message in the request packets, and assembling each interface request message in the request packets according to the scene calling sequence and the scene classification of each interface request message in the request packets to generate test cases corresponding to the request packets so as to carry out interface test on the target system. According to the embodiment, the interface test of the full link can be performed according to the actual operation condition of the user, so that the test range of the interface test is more comprehensive.

Description

Interface testing method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for testing an interface.
Background
Interface testing is a test that tests interfaces between components of a system. Interface testing is mainly used for detecting interaction points between external systems and between internal subsystems. The key point of interface test is to check the exchange of data, transfer and control management process, and the mutual logic dependency relationship between systems. The existing interface test scheme generally only tests scattered interfaces, and cannot test the interfaces of all links according to the actual operation condition of users, so that the test range of the interface test is not comprehensive enough.
Disclosure of Invention
In view of this, the embodiment of the invention provides an interface testing method and device, which can simulate the actual operation condition of a user and perform the interface test of a full link, so that the testing range of the interface test is more comprehensive.
In a first aspect, an embodiment of the present invention provides an interface testing method, including:
collecting a plurality of interface request messages of a target system in a statistical period;
Performing scene classification on the plurality of interface request messages, and performing marking processing on the interface request messages according to the scene classification of the interface request messages;
dividing the plurality of interface request messages into a plurality of request packets;
Determining scene calling sequence of each scene classification corresponding to the request packet according to the mark in the interface request message, determining scene classification of each interface request message in the request packet, assembling each interface request message in the request packet according to the scene calling sequence and the scene classification of each interface request message in the request packet, and generating a test case corresponding to the request packet;
and performing interface test on the target system by using the test cases corresponding to the request packets.
Optionally, the scene classification of the plurality of interface request messages includes:
determining a current interface request message from the plurality of interface request messages;
determining message attribute values of the current interface request message corresponding to all target attributes;
combining the message attribute values to generate a message sample corresponding to the current interface request message;
Determining a decision sample corresponding to each scene classification, wherein the decision sample is generated by combining decision attribute values of the scene classifications corresponding to each target attribute;
determining the correlation degree value of the message sample and each decision sample respectively;
And determining the scene classification of the current interface request message according to the correlation degree value of the message sample and each decision sample.
Optionally, the determining the correlation degree value of the message sample and each decision sample includes:
Determining a current scene classification from a plurality of scene classifications;
Determining a current decision sample corresponding to the current scene classification;
Determining, for each of the target attributes, a current decision value of the current decision sample corresponding to the target attribute; calculating a certainty degree value between a message attribute value corresponding to the target attribute and a current decision value;
And determining the correlation degree value of the message sample and the current decision sample according to the certainty degree value between the message attribute value corresponding to each target attribute and the current decision value.
Optionally, the scene classification of the plurality of interface request messages includes:
Obtaining a mapping relation between keywords and scene classification;
determining a current interface request message from the plurality of interface request messages;
traversing the current interface request message, and determining whether the current interface request message contains a target keyword, wherein the target keyword is a keyword contained in the mapping relation;
Responding to the current interface request message containing the target keywords, and determining target scene classification corresponding to the target keywords according to the mapping relation;
classifying the current interface message into the target scene classification.
Optionally, the determining the scene call sequence of each scene classification corresponding to the request packet includes:
displaying each scene classification corresponding to the request packet in a target page;
receiving a drag operation aiming at the displayed scene classification;
according to the dragging operation, adjusting the display position of the displayed scene classification in the target page;
And determining a scene calling sequence of each scene classification corresponding to the request packet according to the display position of each scene classification corresponding to the request packet in the target page.
Optionally, the determining the scene call sequence of each scene classification corresponding to the request packet includes:
Determining tracking identifiers corresponding to all interface request messages in the request packet, wherein the tracking identifiers are used for representing the calling sequence of the interface request messages;
And determining a scene calling sequence of each scene classification corresponding to the request packet according to the tracking identification corresponding to each interface request message in the request packet and the scene classification to which the request packet belongs.
Optionally, the assembling each interface request message in the request packet according to the scene call sequence and the scene classification to which each interface request message in the request packet belongs, and generating a test case corresponding to the request packet includes:
Assembling each interface request message in the request packet according to the scene call sequence and scene classification of each interface request message in the request packet, and generating an assembly case corresponding to the request packet;
identifying at least one parameter to be replaced in the assembly case;
Extracting replacement values corresponding to the parameters to be replaced from the test document;
And replacing each parameter to be replaced in the assembly case with a corresponding replacement value to generate a test case corresponding to the request packet.
In a second aspect, an embodiment of the present invention provides an interface testing apparatus, including:
The message collection module is used for collecting a plurality of interface request messages of the target system in the statistical period;
the message marking module is used for classifying scenes of the plurality of interface request messages and marking the interface request messages according to the scene classification of the interface request messages;
the message grouping module is used for dividing the plurality of interface request messages into a plurality of request groups;
The system comprises a request packet, a case generation module, a test case generation module and a test case generation module, wherein the request packet comprises a plurality of interface request messages, a scene calling sequence and a scene calling sequence, wherein the interface request messages correspond to the interface request messages;
And the interface test module is used for carrying out interface test on the target system by utilizing the test cases corresponding to the request packets.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
One or more processors;
storage means for storing one or more programs,
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the methods of any of the embodiments described above.
In a fourth aspect, embodiments of the present invention provide a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a method as described in any of the above embodiments.
One embodiment of the invention has the advantages or beneficial effects of classifying and marking the acquired multiple interface request messages of the target system. The plurality of interface request messages are divided into a plurality of request packets. The request packet corresponds to a set of interface request messages involved in the continuous operation by the user, i.e. a set of interface request messages involved in the full link operation. And determining a scene call sequence of each scene category corresponding to the request packet. And determining the scene classification of each interface request message according to the mark in the interface request message. According to the scene calling sequence and the scene classification of each interface request message in the request packet, each interface request message in the request packet is assembled, and a test case corresponding to the request packet is generated, so that the interface test of the target system is completed.
Because the request packet corresponds to a group of interface request messages related to the full-link operation of the user, the actual operation condition of the user can be simulated based on the test case generated by the request packet, and the full-link interface test can be performed, so that the test range of the interface test is more comprehensive.
In addition, according to the scene calling sequence corresponding to the request packet, each interface request message in the request packet is assembled to generate a test case, so that the sending sequence of each interface request message in the test case is consistent with the actual service, the risk of generating an invalid case is reduced, and the test effect of the interface test is better.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of a flow of an interface testing method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a flow of an interface testing method according to another embodiment of the present invention;
FIG. 3 is a schematic diagram of a flow of an interface testing method according to another embodiment of the present invention;
FIG. 4 is a schematic diagram of a flow of an interface testing method according to still another embodiment of the present invention;
FIG. 5 is a schematic diagram of an interface testing apparatus according to an embodiment of the present invention;
Fig. 6 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that, in the technical solution of the embodiment of the present invention, the acquisition, storage, use, processing, etc. of the data all conform to the relevant regulations of the national laws and regulations.
Fig. 1 is a schematic diagram of a flow of an interface testing method according to an embodiment of the present invention. As shown in fig. 1, the method includes:
Step 101, collecting a plurality of interface request messages of a target system in a statistical period.
102, Classifying scenes of the interface request messages, and marking the interface request messages according to the scene classification of the interface request messages.
The scene classification can be set according to the architecture design of the target system, the application scene and specific requirements. As for e-commerce systems, the scene classification may include placing orders, modifying orders, confirming orders, querying orders, paying, etc.
The preset field of the interface request message can be set as the identification of the scene classification corresponding to the interface request message, or the prefix or the suffix for representing the scene classification can be added into the preset field. For example, a "-od" suffix may be added to the end of the host field value of the request header of the interface request packet, to characterize the scenario to which the interface request packet belongs, and classify the scenario as an order.
Step 103, dividing the plurality of interface request messages into a plurality of request packets.
The request packet corresponds to a set of interface request messages involved in the continuous operation by the user, i.e. a set of interface request messages involved in the full link operation. Each interface request message has an execution sequence. Such as the order placing process for the user, may correspond in turn to the business scenario of placing an order, modifying an order, confirming an order, and paying. Therefore, each interface request message corresponding to the order placing, order modifying, order confirming and payment can be formed into a request group. And testing the whole process of the user order by the test case corresponding to the request packet.
And carrying out request grouping according to the configured rule information. For example, a plurality of interface request messages with the same order number in the statistics period may be divided into one request packet. Multiple interface request messages with the same order number and user identification in the statistical period can be divided into a request packet and the like.
Step 104, determining a scene call sequence of each scene classification corresponding to the request packet according to each request packet.
Each scene classification corresponding to the request packet has a calling order. For example, the user performs an order modification operation, places an order first, and then modifies the order. If the order is modified and then placed, execution will fail.
The scene call sequence of each scene class corresponding to the request packet can be determined manually, or can be determined according to the execution time, tracking mark and the like of the interface request message corresponding to each scene class.
Step 105, determining scene classification of each interface request message in the request packet according to the mark in the interface request message.
And 106, assembling each interface request message in the request packet according to the scene calling sequence and the scene classification of each interface request message in the request packet, and generating a test case corresponding to the request packet.
And according to the scene call sequence, sequentially assembling each interface request message in the request packet to generate a test case corresponding to the request packet. The test case is a simulation of the user's operational scenario. The parameters to be replaced in the test cases can be identified, and the parameters to be replaced are reset to generate the test cases meeting the sequencing requirements.
And 107, performing interface test on the target system by using test cases corresponding to the request packets.
External parameters such as execution environment parameters, interface call intervals, etc. are set. And calling the interface message request in each test case according to the external parameters to realize the interface test of the target system.
In the scheme of the embodiment of the invention, scene classification and marking are carried out on a plurality of collected interface request messages of the target system. The plurality of interface request messages are divided into a plurality of request packets. The request packet corresponds to a set of interface request messages involved by the user during continuous operation, i.e. a set of interface request messages for full link operation. And determining a scene call sequence of each scene category corresponding to the request packet. And determining the scene classification of each interface request message according to the mark in the interface request message. According to the scene calling sequence and the scene classification of each interface request message in the request packet, each interface request message in the request packet is assembled, and a test case corresponding to the request packet is generated, so that the interface test of the target system is completed.
Because the request packet corresponds to a group of interface request messages of the full-link operation of the user, the interface test of the full link can be performed according to the actual operation condition of the user based on the test case generated by the request packet, so that the test range of the interface test is more comprehensive.
In one embodiment of the invention, scene classification is carried out on a plurality of interface request messages, wherein the scene classification comprises the steps of determining a current interface request message from the plurality of interface request messages, determining message attribute values of the current interface request message corresponding to all target attributes, combining all message attribute values to generate message samples corresponding to the current interface request message, determining decision samples corresponding to all scene classifications, wherein the decision samples are generated by combining the decision attribute values of the scene classifications corresponding to all target attributes, respectively determining the correlation degree values of the message samples and the decision samples, and determining the scene classification to which the current interface request message belongs according to the correlation degree values of the message samples and the decision samples.
The target attribute may be set according to specific requirements. The value of the target attribute is used for representing the characteristic information of the interface request message. And classifying the interface request message by taking the value of each target attribute. The target attributes may include a request call chain ID, interface information, request header, request parameters, response parameters, and the like.
And each decision attribute value corresponding to the scene classification is a typical value of the target attribute corresponding to the scene classification. The decision attribute values may be empirically set by the relevant personnel. For example, scene classification includes females and males, and target attributes include hair length and height. The decision attribute value corresponding to the female classification is long hair or less than 165. The decision attribute value corresponding to the male classification is short hair and more than 165. The sample corresponds to the long hair and 160, so that the sample has a higher correlation value with the female decision sample, and the sample can be classified into the female classification.
The correlation degree value is used for representing the correlation degree between the message sample and each decision sample. The correlation value may be a euclidean distance, a manhattan distance, a hamming distance, etc. between the message sample and each decision sample. The correlation value may also be determined using fuzzy rough set techniques.
The scene classification corresponding to the decision sample with the largest correlation degree value can be used as the scene classification to which the message sample belongs. If the correlation degree value corresponding to each decision sample is smaller than the preset threshold value, the scene classification corresponding to the message sample cannot be determined, and the interface request message corresponding to the message sample is discarded.
In one embodiment of the invention, the method for determining the correlation degree value of the message sample and each decision sample respectively comprises the steps of determining a current scene classification from a plurality of scene classifications, determining a current decision sample corresponding to the current scene classification, determining a current decision value corresponding to a target attribute of each target decision sample, calculating the certainty degree value between the message attribute value corresponding to the target attribute and the current decision value, and determining the correlation degree value of the message sample and the current decision sample according to the certainty degree value between the message attribute value corresponding to each target attribute and the current decision value.
The certainty value is used for representing the association degree between the message attribute value and the decision value. The certainty value may be a euclidean distance, a manhattan distance, a hamming distance, etc. between the message attribute value and the decision value. The certainty level value may also be determined using fuzzy rough set techniques.
And taking the statistical value of the certainty degree value between the message attribute value and the decision value corresponding to each target attribute as the correlation degree value between the message sample and the decision sample. The statistics may be mean, mode, maximum, etc.
In one embodiment of the invention, scene classification is carried out on a plurality of interface request messages, wherein the scene classification comprises the steps of obtaining mapping relation between keywords and scene classification, determining a current interface request message from the plurality of interface request messages, traversing the current interface request message, determining whether the current interface request message contains target keywords which are keywords contained in the mapping relation, responding to the fact that the current interface request message contains the target keywords, determining target scene classification corresponding to the target keywords according to the mapping relation, and classifying the current interface message into the target scene classification.
The mapping relation between the keywords and the scene classification is preset in the system, and the mapping relation between the keywords, the message fields and the scene classification can also be preset. Traversing each interface request message, and searching keywords in the interface request message or message fields of the interface request message by using regular expressions. If the search is successful, the interface request message is classified into the scene classification corresponding to the keyword.
In one embodiment of the invention, determining a scene call sequence of each scene classification corresponding to a request packet comprises displaying each scene classification corresponding to the request packet in a target page, receiving a drag operation aiming at the displayed scene classification, adjusting a display position of the displayed scene classification in the target page according to the drag operation, and determining the scene call sequence of each scene classification corresponding to the request packet according to the display position of each scene classification corresponding to the request packet in the target page.
The user can adjust the calling sequence of each scene classification through the drag operation. And determining the scene calling sequence of each scene category corresponding to the request group according to the display rule and the display position of each scene category. The display rule may be such that the order of calls corresponding to scene classifications that are more left in the horizontal direction is more forward, the order of calls corresponding to scene classifications that are more right in the vertical direction is more forward, and so on.
Fig. 2 is a schematic diagram of a flow of an interface testing method according to another embodiment of the present invention. As shown in fig. 2, the method includes:
Step 201, collecting a plurality of interface request messages of a target system in a statistical period.
Step 202, classifying scenes of a plurality of interface request messages, and marking each interface request message according to the scene classification of each interface request message.
Step 203, dividing the plurality of interface request messages into a plurality of request packets.
Step 204, for each request packet, determining the tracking identifier corresponding to each interface request message in the request packet.
The trace identifies the order of invocation for characterizing the interface request message, such as traceId. Since the interface traceId which is called first is smaller, the calling sequence corresponding to each scene classification can be determined from small to large according to traceId. The tracking identifier may also be a transfer time, an execution sequence, etc. of the interface request message.
Step 205, determining scene classification of each interface request message in the request packet according to the mark in the interface request message.
Step 206, determining scene calling sequence of each scene classification corresponding to the request packet according to the tracking identification corresponding to each interface request message in the request packet and the scene classification to which the request packet belongs.
Step 207, assembling each interface request message in the request packet according to the scene call sequence, and generating a test case corresponding to the request packet.
And step 208, performing interface test on the target system by using the test cases corresponding to the request packets.
In the scheme of the embodiment of the invention, the scene calling sequence of each scene classification corresponding to the request packet is determined according to the tracking identification corresponding to each interface request message in the request packet and the scene classification to which the request packet belongs. The request packet of the same service can be executed subsequently, and the scene calling sequence can be directly utilized to generate the corresponding test case. The generated test case is a simulation of the actual operation of the user, and can better evaluate the running condition of the target system.
Fig. 3 is a schematic diagram of a flow of an interface testing method according to another embodiment of the present invention. As shown in fig. 3, the method includes:
Step 301, collecting a plurality of interface request messages of a target system in a statistical period.
Step 302, performing scene classification on the plurality of interface request messages, and performing marking processing on the interface request messages according to the scene classification of the interface request messages.
Step 303, dividing the plurality of interface request messages into a plurality of request packets.
Step 304, determining a scene call sequence of each scene classification corresponding to the request packet according to each request packet.
Step 305, determining scene classification of each interface request message in the request packet according to the mark in the interface request message.
Step 306, according to the scene calling sequence and the scene classification of each interface request message in the request packet, each interface request message in the request packet is assembled, and an assembly case corresponding to the request packet is generated.
Step 307, identifying at least one parameter to be replaced in the assembly case, and extracting the replacement value corresponding to each parameter to be replaced from the test document.
The parameters to be replaced may be saved in a table of parameters to be identified or in a text of parameters to be identified. At least one parameter to be replaced is identified from the assembly case by JsonPath, xmlPath or regular expressions or the like. And extracting the replacement values corresponding to the parameters to be replaced from the test document in JsonPath, xmlPath or regular expression modes and the like.
And 308, replacing each parameter to be replaced in the assembly case with a corresponding replacement value to generate a test case corresponding to the request packet.
Parameter substitution can be achieved through MockJs, freemarker, regular expressions and other related modes.
And 309, performing interface test on the target system by using the test cases corresponding to the request packets.
In the scheme of the embodiment of the invention, at least one parameter to be replaced in the assembly case is identified, and each parameter to be replaced in the assembly case is replaced to generate each test case meeting the test requirement. When the same parameter to be tested corresponds to a plurality of replacement values, a plurality of test cases corresponding to a request packet can be generated, so that the test cases meet the test requirements, and meanwhile, the execution efficiency of the test cases is improved.
Fig. 4 is a schematic diagram of a flow of an interface testing method according to still another embodiment of the present invention. As shown in FIG. 4, the method comprises the following steps of user real flow collection, full-link automation, intelligent flow analysis and dyeing, interface automation scene assembly and keyword parameterization.
And collecting the real flow of the user, and recording all the requests sent by the related users on a certain server in a certain statistical time period.
And full link automation, wherein in a certain time period, interface call requests recorded on the system are assembled into an automation scene according to the call sequence of the actual operation of the user, and the assembled automation scene is consistent with the actual operation of the user.
The message collection module provides a flow recording function, one flow recording comprises one entry call and a plurality of sub-calls, and the flow recording process is to bind the entry call and the sub-call into one complete record.
And (3) intelligently analyzing and dyeing the flow, and analyzing the collected flow by a keyword matching algorithm and calling a chain tracking technology. The method comprises the steps of carrying out scene classification on a request message through a keyword matching algorithm, and firstly defining a group of keywords such as interface names and methods, request parameters, call chain IDs, request heads, response contents and the like in a configuration library. Then, each interface request message is traversed, and whether the interface request message contains any one keyword is checked. If the key words are included, the interface request message is classified into the corresponding scene classification.
The mapping relation between the predefined keywords and scene classification can be obtained, then the interface request message list is traversed, and classification and dyeing are carried out on each interface request message. The key words can be searched in each field of the interface request message by using the regular expression, and if the key words are successfully searched, the interface request message is classified into the corresponding scene classification.
The interface automatic scene assembly and the keyword parameterization are responsible for carrying out the automatic scene assembly and the parameterization on the categorized interfaces. The scene assembly can assemble the interface use cases into end-to-end full-link service scene use cases according to the service scene. The sequence between the interface use case steps can be adjusted by dragging. Parameterization, assertion and inter-case parameter of interface are referenced with each other, and are extracted rapidly. Parameter identification can be performed by JsonPath, xmlPath modes, regular expressions and the like. Parameter setting is achieved through MockJs, freemarker and related modes.
Recording the interface through the flow collection, and identifying the key words of the service scene for the recorded flow. And identifying different scene classifications according to the interface definition and the interface message keywords. The implementation principle of the scene classification algorithm model is introduced by taking the e-commerce system as a target system.
For ease of description, "recording traffic" is defined as a dataset. Attribute set c= { C1, C2,..ci } in the dataset. c1, c2,..ci are different properties. Attributes may include request call chain ID, interface information, request header, request parameters, response parameters, etc. Message sample set x= { X1, X2,..xi }. Each message sample consists of different attribute values, i.e., x1= { c11, c21,..ci 1}. In the e-commerce system, a decision sample set d= { D1, D2,..di } corresponding to scene classification. Scene classification may include placing orders, modifying orders, querying orders, confirming orders, and the like.
The data preprocessing comprises the steps of sample set division, invalid data rejection, noise data rejection, rule setting of decision attribute set and the like.
Sample set division, namely dividing sample sets according to the request call chain ID, wherein the data information belonging to the same request call chain ID is the same sample.
And invalid data rejection, namely rejecting the interface flow request which cannot be successfully divided by the sample set.
Noise data eliminating, namely processing the sample set according to the noise data rule and carrying out noise data eliminating processing.
The classification algorithm is realized by adopting a fuzzy rough set technology. From the concepts approximated above and below the fuzzy rough set, a boundary field of the fuzzy concept X in the fuzzy rough set can be defined:
thus, the uncertainty calculation formula for the concept X in the feature subset P is defined as follows:
From the above, the total uncertainty about all concepts based on the fuzzy equivalence relation on the argument U caused between the attribute set P and the attribute Q is:
the proposal of the embodiment of the invention is realized by adopting the fuzzy rough set technology, and the algorithm flow is as follows:
and (01) calculating certainty values 1-rho C (D) of each message sample xi { c1i, c2i,. Cii } and the decision sample aiming at each target attribute. And calculating the certainty degree value of the target attribute in the message sample and the certainty degree value of the target attribute in the decision sample aiming at each target attribute, and constructing a similarity matrix of the message sample. The following table is an example of a similarity matrix for one message sample.
Table 1 example of similarity matrix for message samples
Kd InF header Rep Scene classification
0.01 0.8 0.75 0.85 Od
0.01 0.01 0.3 0.02 Md
0.01 0 0.1 0.01 Qy
As shown in Table 1, kd represents the request call chain ID, inF represents interface information, header represents the request header, and Req represents the request parameters. Od corresponds to the order scenario classification, md corresponds to the modification order scenario classification, and Qy corresponds to the query order scenario classification.
And judging scene classification of the message sample according to the similarity matrix. For the decision samples corresponding to each scene classification, the statistical value of the certainty degree value corresponding to each target attribute can be used as the correlation degree value between the message samples and the decision samples. The statistics may be mean, mode, maximum, etc.
For the message samples shown in table 1, under the condition that the statistical value is the mean value, the correlation degree value between the message sample and the decision sample of the next scene classification (Od) is calculated to be 0.6, the correlation degree value between the message sample and the decision sample of the modified order scene classification (Md) is calculated to be 0.085, and the correlation degree value between the message sample and the decision sample of the query order scene classification (Qy) is calculated to be 0.03. Therefore, the scene to which the message sample belongs is classified into a lower single scene classification, and the keyword Od is marked for the message sample. And repeating the algorithm flow by other message samples to obtain scene classification corresponding to all interface request messages.
And 02, automatically assembling an automation scene according to the key words of the interface message and the scene configuration rules, and dividing a plurality of related interface request messages into a request packet. Request grouping can be performed according to configured rule information, such as a unique primary key such as an order number.
Step 03, determining the calling sequence of the request message in the request packet according to the calling chain tracking technology. Because the interface traceId which is called earlier is smaller, the interface request messages in the packet can be called and sequenced from small to large according to traceId, and the sequenced scene is the actual operation scene of the user, and the test case is generated.
And 04, setting external parameters in a call configuration library, such as an execution environment, an interface call interval and the like, calling test cases corresponding to each request packet, and performing interface test on the target system. The test case is a simulation of the user's operational scenario.
The scheme of the embodiment of the invention can solve the problem that in the prior art, only an independent interface unit can be simulated, and the pain point of real business on a line cannot be simulated. For example, the order modification service has the actual service scene that an order is generated through an order placing interface and then modified. In the existing scheme, because the real service scene cannot be identified, when the order modification service is verified, the modification interface is possibly called first, and then the order placing interface is called, so that the automatic execution fails. The test case generated by the scheme simulates the operation scene of the user, and can ensure the validity and the authenticity of the test case.
Fig. 5 is a schematic structural diagram of an interface testing device according to an embodiment of the present invention. As shown in fig. 5, the apparatus includes:
A message collection module 501, configured to collect a plurality of interface request messages of a target system in a statistics period;
The message Wen Biaoji module 502 is configured to perform scene classification on a plurality of interface request messages, and perform marking processing on each interface request message according to the scene classification to which each interface request message belongs;
a packet grouping module 503, configured to divide a plurality of interface request packets into a plurality of request packets;
The case generation module 504 is used for determining a scene call sequence of each scene classification corresponding to the request packet for each request packet, determining the scene classification of each interface request message in the request packet according to the mark in the interface request message, assembling each interface request message in the request packet according to the scene call sequence and the scene classification of each interface request message in the request packet, and generating a test case corresponding to the request packet;
The interface test module 505 is configured to perform an interface test on the target system by using test cases corresponding to each request packet.
Optionally, the report Wen Biaoji module 502 is specifically configured to:
determining a current interface request message from a plurality of interface request messages;
determining message attribute values of the current interface request message corresponding to all target attributes;
combining the attribute values of the messages to generate a message sample corresponding to the current interface request message;
determining a decision sample corresponding to each scene classification, wherein the decision sample is generated by combining decision attribute values of the scene classifications corresponding to each target attribute;
determining the correlation degree value of the message sample and each decision sample respectively;
And determining the scene classification of the current interface request message according to the correlation degree value of the message sample and each decision sample.
Optionally, the report Wen Biaoji module 502 is specifically configured to:
determining a current scene classification from a plurality of scene classifications;
Determining a current decision sample corresponding to the current scene classification;
Determining a current decision value of the current decision sample corresponding to the target attribute aiming at each target attribute;
and determining the correlation degree value of the message sample and the current decision sample according to the certainty degree value between the message attribute value corresponding to each target attribute and the current decision value.
Optionally, the report Wen Biaoji module 502 is specifically configured to:
Obtaining a mapping relation between keywords and scene classification;
determining a current interface request message from a plurality of interface request messages;
Traversing the current interface request message, and determining whether the current interface request message contains a target keyword which is a keyword contained in a mapping relation;
Responding to the fact that the current interface request message contains target keywords, and determining target scene classification corresponding to the target keywords according to the mapping relation;
classifying the current interface message into the target scene classification.
Optionally, the use case generation module 504 is specifically configured to:
In the target page, each scene classification corresponding to the request packet is displayed;
receiving a drag operation aiming at the displayed scene classification;
According to the drag operation, adjusting the display position of the displayed scene classification in the target page;
And determining a scene calling sequence of each scene category corresponding to the request packet according to the display position of each scene category corresponding to the request packet in the target page.
Optionally, the use case generation module 504 is specifically configured to:
Determining tracking identifiers corresponding to the interface request messages in the request packet, wherein the tracking identifiers are used for representing the calling sequence of the interface request messages;
and determining a scene calling sequence of each scene classification corresponding to the request packet according to the tracking identification corresponding to each interface request message in the request packet and the scene classification to which the request packet belongs.
Optionally, the use case generation module 504 is specifically configured to:
Assembling each interface request message in the request packet according to the scene calling sequence and scene classification of each interface request message in the request packet, and generating an assembly case corresponding to the request packet;
identifying at least one parameter to be replaced in the assembly case;
Extracting replacement values corresponding to parameters to be replaced from the test document;
And replacing each parameter to be replaced in the assembly case with a corresponding replacement value to generate a test case corresponding to the request packet.
The embodiment of the invention provides electronic equipment, which comprises:
One or more processors;
storage means for storing one or more programs,
When the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the methods of any of the embodiments described above.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 6 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Connected to the I/O interface 605 are an input section 606 including a keyboard, a mouse, and the like, an output section 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like, a storage section 608 including a hard disk, and the like, and a communication section 609 including a network interface card such as a LAN card, a modem, and the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 601.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of a computer-readable storage medium may include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, and may be described as, for example, a message collection module, a message marking module, a message grouping module, a use case generation module, and an interface test module. The names of these modules do not limit the module itself in some cases, for example, the message collection module may also be described as "a module that collects multiple interface request messages of the target system in a statistical period".
As a further aspect, the invention also provides a computer readable medium which may be comprised in the device described in the above embodiments or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include:
collecting a plurality of interface request messages of a target system in a statistical period;
Performing scene classification on the plurality of interface request messages, and performing marking processing on the interface request messages according to the scene classification of the interface request messages;
dividing the plurality of interface request messages into a plurality of request packets;
Determining scene calling sequence of each scene classification corresponding to the request packet according to the mark in the interface request message, determining scene classification of each interface request message in the request packet, assembling each interface request message in the request packet according to the scene calling sequence and the scene classification of each interface request message in the request packet, and generating a test case corresponding to the request packet;
and performing interface test on the target system by using the test cases corresponding to the request packets.
According to the technical scheme of the embodiment of the invention, scene classification and marking are carried out on a plurality of collected interface request messages of the target system. The plurality of interface request messages are divided into a plurality of request packets. The request packet corresponds to a set of interface request messages involved by the user during continuous operation, i.e. a set of interface request messages for full link operation. And determining a scene call sequence of each scene category corresponding to the request packet. And determining the scene classification of each interface request message according to the mark in the interface request message. According to the scene calling sequence and the scene classification of each interface request message in the request packet, each interface request message in the request packet is assembled, and a test case corresponding to the request packet is generated, so that the interface test of the target system is completed.
Because the request packet corresponds to a group of interface request messages of the full-link operation of the user, the interface test of the full link can be performed according to the actual operation condition of the user based on the test case generated by the request packet, so that the test range of the interface test is more comprehensive.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. An interface testing method, comprising:
collecting a plurality of interface request messages of a target system in a statistical period;
Performing scene classification on the plurality of interface request messages, and performing marking processing on the interface request messages according to the scene classification of the interface request messages;
dividing the plurality of interface request messages into a plurality of request packets;
Determining scene calling sequence of each scene classification corresponding to the request packet according to the mark in the interface request message, determining scene classification of each interface request message in the request packet, assembling each interface request message in the request packet according to the scene calling sequence and the scene classification of each interface request message in the request packet, and generating a test case corresponding to the request packet;
and performing interface test on the target system by using the test cases corresponding to the request packets.
2. The method of claim 1, wherein the scene classification of the plurality of interface request messages comprises:
determining a current interface request message from the plurality of interface request messages;
determining message attribute values of the current interface request message corresponding to all target attributes;
combining the message attribute values to generate a message sample corresponding to the current interface request message;
Determining a decision sample corresponding to each scene classification, wherein the decision sample is generated by combining decision attribute values of the scene classifications corresponding to each target attribute;
determining the correlation degree value of the message sample and each decision sample respectively;
And determining the scene classification of the current interface request message according to the correlation degree value of the message sample and each decision sample.
3. The method according to claim 2, wherein determining the correlation value of the message sample and each of the decision samples respectively comprises:
Determining a current scene classification from a plurality of scene classifications;
Determining a current decision sample corresponding to the current scene classification;
Determining, for each of the target attributes, a current decision value of the current decision sample corresponding to the target attribute; calculating a certainty degree value between a message attribute value corresponding to the target attribute and a current decision value;
And determining the correlation degree value of the message sample and the current decision sample according to the certainty degree value between the message attribute value corresponding to each target attribute and the current decision value.
4. The method of claim 1, wherein the scene classification of the plurality of interface request messages comprises:
Obtaining a mapping relation between keywords and scene classification;
determining a current interface request message from the plurality of interface request messages;
traversing the current interface request message, and determining whether the current interface request message contains a target keyword, wherein the target keyword is a keyword contained in the mapping relation;
Responding to the current interface request message containing the target keywords, and determining target scene classification corresponding to the target keywords according to the mapping relation;
classifying the current interface message into the target scene classification.
5. The method of claim 1, wherein determining a scene call order for each scene classification corresponding to the request packet comprises:
displaying each scene classification corresponding to the request packet in a target page;
receiving a drag operation aiming at the displayed scene classification;
according to the dragging operation, adjusting the display position of the displayed scene classification in the target page;
And determining a scene calling sequence of each scene classification corresponding to the request packet according to the display position of each scene classification corresponding to the request packet in the target page.
6. The method of claim 1, wherein determining a scene call order for each scene classification corresponding to the request packet comprises:
Determining tracking identifiers corresponding to all interface request messages in the request packet, wherein the tracking identifiers are used for representing the calling sequence of the interface request messages;
And determining a scene calling sequence of each scene classification corresponding to the request packet according to the tracking identification corresponding to each interface request message in the request packet and the scene classification to which the request packet belongs.
7. The method according to claim 1, wherein the assembling each interface request message in the request packet according to the scene call sequence and the scene classification to which each interface request message in the request packet belongs, and generating the test case corresponding to the request packet, includes:
Assembling each interface request message in the request packet according to the scene call sequence and scene classification of each interface request message in the request packet, and generating an assembly case corresponding to the request packet;
identifying at least one parameter to be replaced in the assembly case;
Extracting replacement values corresponding to the parameters to be replaced from the test document;
And replacing each parameter to be replaced in the assembly case with a corresponding replacement value to generate a test case corresponding to the request packet.
8. An interface testing apparatus, comprising:
The message collection module is used for collecting a plurality of interface request messages of the target system in the statistical period;
the message marking module is used for classifying scenes of the plurality of interface request messages and marking the interface request messages according to the scene classification of the interface request messages;
the message grouping module is used for dividing the plurality of interface request messages into a plurality of request groups;
The system comprises a request packet, a case generation module, a test case generation module and a test case generation module, wherein the request packet comprises a plurality of interface request messages, a scene calling sequence and a scene calling sequence, wherein the interface request messages correspond to the interface request messages;
And the interface test module is used for carrying out interface test on the target system by utilizing the test cases corresponding to the request packets.
9. An electronic device, comprising:
One or more processors;
storage means for storing one or more programs,
When executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-7.
10. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-7.
CN202311434421.0A 2023-10-31 2023-10-31 Interface testing method and device Pending CN119938501A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311434421.0A CN119938501A (en) 2023-10-31 2023-10-31 Interface testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311434421.0A CN119938501A (en) 2023-10-31 2023-10-31 Interface testing method and device

Publications (1)

Publication Number Publication Date
CN119938501A true CN119938501A (en) 2025-05-06

Family

ID=95533381

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311434421.0A Pending CN119938501A (en) 2023-10-31 2023-10-31 Interface testing method and device

Country Status (1)

Country Link
CN (1) CN119938501A (en)

Similar Documents

Publication Publication Date Title
CN110210227B (en) Risk detection method, device, equipment and storage medium
WO2021159834A1 (en) Abnormal information processing node analysis method and apparatus, medium and electronic device
CN111427974A (en) Data quality evaluation management method and device
CN113656686B (en) Task report generation method and service system based on production and teaching fusion
CN115221337A (en) Data weaving processing method, device, electronic device and readable storage medium
CN116739408A (en) Power grid dispatching safety monitoring method and system based on data tag and electronic equipment
CN117424794A (en) Root cause positioning method, communication device and computer readable storage medium
Ashraf et al. WeFreS: weighted frequent subgraph mining in a single large graph
CN116739605A (en) Transaction data detection method, device, equipment and storage medium
CN116881430A (en) Industrial chain identification method and device, electronic equipment and readable storage medium
CN111078512A (en) Alarm record generation method and device, alarm equipment and storage medium
WO2023029065A1 (en) Method and apparatus for evaluating data set quality, computer device, and storage medium
CN113987186B (en) Method and device for generating marketing scheme based on knowledge graph
CN110765100B (en) Label generation method and device, computer readable storage medium and server
CN109684198B (en) Method, device, medium and electronic equipment for acquiring data to be tested
CN111460315A (en) Social portrait construction method, device and equipment and storage medium
CN109034392A (en) The selection and system of a kind of Tilapia mossambica corss combination system
CN113282686A (en) Method and device for determining association rule of unbalanced sample
CN114297516A (en) A method and system for event discovery and presentation based on knowledge graph
CN119938501A (en) Interface testing method and device
CN114841132A (en) Mainframe business analysis model training method, business analysis method and device
CN113504973A (en) Service data concurrent processing method, device and system
CN112750047A (en) Behavior relation information extraction method and device, storage medium and electronic equipment
CN119623615B (en) Corpus delivery and application rule management method and system
CN113901349B (en) Strong relation analysis method, system and storage 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