CN113051171B - Interface testing method, device, equipment and storage medium - Google Patents

Interface testing method, device, equipment and storage medium Download PDF

Info

Publication number
CN113051171B
CN113051171B CN202110380190.4A CN202110380190A CN113051171B CN 113051171 B CN113051171 B CN 113051171B CN 202110380190 A CN202110380190 A CN 202110380190A CN 113051171 B CN113051171 B CN 113051171B
Authority
CN
China
Prior art keywords
interface
flow
scene
test
diagram
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110380190.4A
Other languages
Chinese (zh)
Other versions
CN113051171A (en
Inventor
张洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Saiante Technology Service Co Ltd
Original Assignee
Shenzhen Saiante Technology Service 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 Shenzhen Saiante Technology Service Co Ltd filed Critical Shenzhen Saiante Technology Service Co Ltd
Priority to CN202110380190.4A priority Critical patent/CN113051171B/en
Publication of CN113051171A publication Critical patent/CN113051171A/en
Application granted granted Critical
Publication of CN113051171B publication Critical patent/CN113051171B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • User Interface Of Digital Computer (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to research and development management technology, and discloses an interface testing method, which comprises the following steps: classifying interface sets to be detected according to interface keywords to obtain a flow interface set and a scene interface set, creating a flow interface diagram according to the flow interface set, generating a flow test case by utilizing the flow interface diagram and a preset flow control diagram, generating the flow interface set and the scene test case of the interface in the scene interface set according to a preset scene rule, and detecting the flow test case and the scene test case respectively to obtain an interface test result. In addition, the invention also relates to a blockchain technology, and the interface test result can be stored in a node of the blockchain. The invention also provides an interface testing device, electronic equipment and a computer readable storage medium. The invention can solve the problem of lower interface test efficiency.

Description

Interface testing method, device, equipment and storage medium
Technical Field
The present invention relates to the field of research and development management technologies, and in particular, to an interface testing method, an apparatus, an electronic device, and a computer readable storage medium.
Background
Interface testing is an important link in the software testing process, and occupies a large proportion in layering testing. At present, as the input and output of interface test are relatively high, the interface test is more and more paid attention to by various companies and testers, and is widely applied to smoke test, regression test and background monitoring.
The interface test case is written in the prior art and mainly comprises the following steps: 1. knowing the interface, 2, designing the interface use case, 3, writing the interface script, 4, debugging the interface script. When the interface use cases are compiled and written, a tester needs to know the interface first, then design the use cases according to the functions and parameters of the interface from three aspects of service flow, request content structure and parameter validity, and finally convert the designed use cases into interface scripts. If a certain interface (including a structure, parameters and a request type) after writing is changed, a script needs to be run at the moment, the script can be known through manual analysis failure, great inconvenience is brought to maintenance of the script, meanwhile, the interface and the interface script are separately managed in the existing interface test, writing and maintenance of the interface script and test data are inconvenient, and the step of writing the interface test case is complex, tedious and tedious, so that the interface test efficiency is low.
Disclosure of Invention
The invention provides an interface testing method, device, equipment and storage medium, and mainly aims to solve the problem of low interface testing efficiency.
In order to achieve the above object, the present invention provides an interface testing method, including:
classifying the interface sets to be detected according to the interface keywords to obtain a flow interface set and a scene interface set;
creating a flow interface diagram according to the flow interface set;
generating a flow test case by using the flow interface diagram and a preset flow control diagram;
generating a scene test case of the flow interface set and the scene interface set interface according to a preset scene rule;
and respectively detecting the flow test case and the scene test case to obtain an interface test result.
Optionally, the classifying the interface set to be detected according to the interface keywords to obtain a flow interface set and a scene interface set includes:
extracting keywords of interfaces to be detected in the interfaces to be detected set to obtain the interface keywords;
sequentially calculating the similarity between the interface keywords and keywords in a preset business process library;
if the similarity is greater than or equal to a preset similarity threshold, determining that the interface to be detected corresponding to the interface keyword is a flow interface, and summarizing the flow interface to obtain the flow interface set;
And if the similarity is smaller than a preset similarity threshold, determining that the interface to be detected corresponding to the interface keyword is a scene interface, and summarizing the scene interface to obtain the scene interface set.
Optionally, the sequentially calculating the similarity between the interface keywords and keywords in a preset business process library includes:
and sequentially calculating the similarity between the interface keywords and keywords in a preset business process library by using the following formula:
wherein j (A, B) is the similarity, A is an interface keyword, and B is a keyword in the business process library.
Optionally, the creating a flow interface diagram according to the flow interface set includes:
acquiring a flow interface template diagram, wherein the flow interface template diagram comprises extraction fields;
extracting the fields of the interfaces in the process interface set by using the extraction fields to obtain process interface fields;
and filling the flow interface field into the flow interface template diagram to obtain the flow interface diagram.
Optionally, the generating the flow test case by using the flow interface diagram and the preset flow control diagram includes:
receiving a business process instruction of a user;
Performing flow arrangement on the flow interface diagram and the flow control diagram according to the business flow instruction to obtain an original flow diagram;
and adding a parameter extraction diagram into the original flow chart to obtain the flow test case.
Optionally, the generating the flow interface set and the scene test case of the interface in the scene interface set according to the preset scene rule includes:
acquiring a preset scene rule, wherein the scene rule comprises a request content scene rule and a field type scene rule;
generating a request content scene use case of each interface in the flow interface set and the scene interface set by using the request content scene rule, and generating a field type scene use case of each interface in the flow interface set and the scene interface set by using the field type scene rule;
and summarizing the scene use cases of the request content and the scene use cases of the field type to obtain the scene test use cases.
Optionally, the detecting the flow test case and the scene test case respectively to obtain an interface test result includes:
generating a flow test script according to the flow test case, and generating a scene test script according to the scene test case;
And respectively running the flow test script and the scene test script to obtain a flow test result and a scene test result, and summarizing the flow test result and the scene test result to obtain the interface test result.
In order to solve the above problems, the present invention also provides an interface testing apparatus, the apparatus comprising:
the interface classification module is used for classifying the interface set to be detected according to the interface keywords to obtain a flow interface set and a scene interface set;
the interface diagram creation module is used for creating a flow interface diagram according to the flow interface set;
the flow case generation module is used for generating a flow test case by utilizing the flow interface diagram and a preset flow control diagram;
the scene case generation module is used for generating the flow interface set and the scene test cases of the interfaces in the scene interface set according to preset scene rules;
and the interface detection module is used for respectively detecting the flow test case and the scene test case to obtain an interface test result.
In order to solve the above-mentioned problems, the present invention also provides an electronic apparatus including:
a memory storing at least one instruction; and
And the processor executes the instructions stored in the memory to realize the interface testing method.
In order to solve the above-mentioned problems, the present invention also provides a computer-readable storage medium having stored therein at least one instruction that is executed by a processor in an electronic device to implement the above-mentioned interface test method.
According to the method and the device, the interfaces to be detected are classified to obtain the flow interfaces and the scene interfaces, so that the flow test and the scene test of the interfaces are separated, and the complexity of interface test case design is reduced. The flow interface is utilized to create a flow interface diagram, a flow test case is generated according to the flow interface diagram and a preset flow control diagram, the interface to be detected can be used as an object to be imported into the test case through graphic modeling of the interface, the complicated and visual manual writing is avoided, meanwhile, the interface is associated with the case, the case needing to be adjusted can be pushed in time if the interface is changed, and the efficiency of interface test is improved. And the flow interface and the scene test cases of the scene interface are generated according to the preset scene rules, and all the scene test cases can be modified only by modifying the scene rules, so that the overall maintenance capability and detection efficiency of the scene cases are improved. Therefore, the interface testing method, the device, the electronic equipment and the computer readable storage medium can solve the problem of low interface testing efficiency.
Drawings
FIG. 1 is a flow chart of an interface testing method according to an embodiment of the invention;
FIG. 2 is a detailed flow chart of one of the steps shown in FIG. 1;
FIG. 3 is a detailed flow chart of another step of FIG. 1;
FIG. 4 is a detailed flow chart of another step of FIG. 1;
FIG. 5 is a detailed flow chart of another step of FIG. 1;
FIG. 6 is a functional block diagram of an interface testing apparatus according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device for implementing the interface testing method according to an embodiment of the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The embodiment of the application provides an interface testing method. The execution body of the interface testing method includes, but is not limited to, at least one of a server, a terminal, and the like, which can be configured to execute the method provided by the embodiment of the application. In other words, the interface test method may be performed by software or hardware installed in a terminal device or a server device, and the software may be a blockchain platform. The service end includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
Referring to fig. 1, a flow chart of an interface testing method according to an embodiment of the invention is shown.
In this embodiment, the interface testing method includes:
s1, classifying an interface set to be detected according to interface keywords to obtain a flow interface set and a scene interface set.
In the embodiment of the invention, the interface to be detected refers to a part for connecting and interacting with an external system, a system and internal subsystems, and is mainly used for data exchange, transmission, control and management processes, inter-logic dependency relationship among systems and the like. The process interface refers to an interface related to a service process, and can be combined with other interfaces to form a complete service flow according to service characteristics of the interface, including: registration interface, login interface, etc. The scene interface is an interface for different service scenes, and is used for verifying whether the content format and the field content of a single interface meet the design requirement, and is generally irrelevant to other interfaces, for example, an interface with different settings according to the content of the interface request, an interface with different settings according to the field types of the interface, and the like.
Specifically, referring to fig. 2, the classifying the interface set to be detected according to the interface keywords to obtain a flow interface set and a scene interface set includes:
S10, extracting keywords of interfaces to be detected in the interfaces to be detected set to obtain the interface keywords;
s11, sequentially calculating the similarity between the interface keywords and keywords in a preset business process library;
if the similarity is greater than or equal to a preset similarity threshold, executing S12, determining that an interface to be detected corresponding to the interface keyword is a flow interface, and summarizing the flow interface to obtain the flow interface set;
and if the similarity is smaller than a preset similarity threshold, executing S13, determining that the interface to be detected corresponding to the interface keyword is a scene interface, and summarizing the scene interface to obtain the scene interface set.
In the embodiment of the present invention, the preset business process library may be constructed according to an actual business process, for example, the business process library may include keywords such as "registration", "login", "verification", "save", "submit", etc.
In the embodiment of the present invention, the sequentially calculating the similarity between the interface keywords and keywords in a preset business process library includes:
and sequentially calculating the similarity between the interface keywords and keywords in a preset business process library by using the following formula:
Wherein j (A, B) is the similarity, A is an interface keyword, and B is a keyword in the business process library.
In one embodiment of the present invention, the similarity threshold is 100%.
In the embodiment of the invention, the keywords of the interfaces to be detected in the interfaces to be detected set can be extracted by using a preset language processing algorithm, wherein the preset language processing algorithm can be a TextRank, a semantic-based keyword extraction algorithm and the like which are disclosed at present. For example, the interface to be detected may be a "login interface", the extracted interface keyword is "login", and the matching is performed in the business process library, and the "login interface" is determined to be a process interface according to the similarity between the interface keyword and the keyword in the business process library.
According to the embodiment of the invention, the flow interface set and the scene interface set are obtained by classifying the interface set to be detected, and the flow test case and the scene test case can be respectively generated, so that the flow test and the scene test are carried out separately, and the complexity of the interface test case design is reduced.
S2, creating a flow interface diagram according to the flow interface set.
In the embodiment of the invention, the flow interface diagram may be a UML (Unified Modeling Language ) diagram, where the UML (Unified Modeling Language, unified modeling language) diagram is a graphical language supporting modeling and software system development, and provides modeling and visual support for all stages of software development, including from requirement analysis to specification, to construction and configuration, and so on.
Specifically, referring to fig. 3, the creating a flow interface diagram according to the flow interface set includes:
s20, acquiring a flow interface template diagram, wherein the flow interface template diagram comprises extraction fields;
s21, extracting fields from the interfaces in the flow interface set by using the extraction fields to obtain flow interface fields;
s22, filling the flow interface field into the flow interface template diagram to obtain the flow interface diagram.
In an optional embodiment of the present invention, the flow interface template diagram is a UML template diagram, and the extraction field in the flow interface template diagram includes: "interface name", "request header", "request body", "expected interface", "expected result", "check mode", and "actual result", etc., the "interface name" is used to extract the interface name; the "request header" is used to extract the Content of the request header, such as Content-Type, session, etc.; the 'request body' is used for extracting specific request Content, for example, the request body can be automatically assembled into a test case meeting the requirements according to defined Content-Type; the 'expected interface' is used for extracting the content to be checked by the interface; the verification mode can be equal to, contain, not contain, be greater than or equal to, and can be developed according to specific requirements; the "expected result" refers to a desired result, and may be a specific value or an argument; the "actual result" refers to the actual value in the returned content, and may be any expression of the extracted result, such as jsonpath, xpath, regular expression, and the like.
In the embodiment of the invention, the flow interface diagram is obtained by carrying out graphic modeling on the flow interface, so that the interface can be embodied in a graphic mode, and the system is more visual and is easy to maintain.
S3, generating a flow test case by using the flow interface diagram and a preset flow control diagram.
In the embodiment of the present invention, referring to fig. 4, the generating a flow test case by using the flow interface diagram and a preset flow control diagram includes:
s30, receiving a business process instruction of a user;
s31, carrying out flow arrangement on the flow interface diagram and the flow control diagram according to the business flow instruction to obtain an original flow diagram;
s32, adding a parameter extraction diagram to the original flow chart to obtain the flow test case.
In an alternative embodiment of the present invention, the business process instruction refers to an instruction for performing process combination on the flow interface diagram according to an actual business process. The preset flow control chart (for example, may be a diamond chart) is used for controlling the flow trend according to the judged result so as to improve the robustness of the interface test, and the flow control chart includes any type of self-defined and resolvable judgment expression, and can perform different processes according to the judgment result.
In the embodiment of the invention, in the script of the actual interface test, the condition that the subsequent interface returns the content by using the previous interface often occurs, so that parameter extraction is required, and the parameter extraction diagram comprises fields such as an extraction mode, an extraction expression, a variable name and the like. The "extraction mode" refers to a specific mode for extracting data, and may be jsonpath, xpath, regular expression, etc.; the expression "extraction expression" refers to an expression corresponding to an extraction mode; the "variable name" is used to hold the extracted parameters.
Meanwhile, in the embodiment of the invention, graphics are not needed for parameter transfer, and the parameter transfer is directly replaced by a defined expression where needed, such as { { { variable name } }, $ { variable name }.
In the embodiment of the invention, the interface can be used as an object to be imported into the test case by carrying out graphic modeling on the interface, the interface test data is strictly generated according to the interface definition, the complexity of manual writing is avoided, and the efficiency of the interface test is improved.
S4, generating the flow interface set and the scene test cases of the interfaces in the scene interface set according to preset scene rules.
In the embodiment of the present invention, the preset scene rules include a request content scene rule and a field type scene rule, where the request content scene rule includes: A. and B, the structure of the requested content is inconsistent with the definition, if the content in the json format is required to be transmitted, but the format is actually transmitted, and C, the structure of the requested content is incomplete, if the requested content is not in a complete json format. The field type scene rules include: A. contents conforming to the field type and rule, B, contents not conforming to the field rule, C, contents not conforming to the field type, D, oversized or ultralong contents, E, null and G, corresponding field deletion.
In the embodiment of the present invention, referring to fig. 5, the generating the flow interface set and the scene test case of the interface in the scene interface set according to the preset scene rule includes:
s40, acquiring a preset scene rule, wherein the scene rule comprises a request content scene rule and a field type scene rule;
s41, generating a flow interface set and a request content scene use case of each interface in the scene interface set by using the request content scene rule, and generating a field type scene use case of each interface in the flow interface set and the scene interface set by using the field type scene rule;
s42, summarizing the scene use cases of the request content and the scene use cases of the field type to obtain the scene test use cases.
In the embodiment of the invention, since the interfaces are defined, corresponding scene test cases can be automatically generated according to the scene rules of the request content and the scene rules of the field types aiming at the request content and the field types of each interface, so that the test efficiency is improved, and meanwhile, the scene test cases are generated according to the established scene rules, so that the existing cases can be updated by managing the corresponding scene rules, and the maintenance cost is reduced.
S5, respectively detecting the flow test case and the scene test case to obtain an interface test result.
Specifically, the detecting the flow test case and the scene test case respectively to obtain an interface test result includes:
generating a flow test script according to the flow test case, and generating a scene test script according to the scene test case;
and respectively running the flow test script and the scene test script to obtain a flow test result and a scene test result, and summarizing the flow test result and the scene test result to obtain the interface test result.
In the embodiment of the invention, the flow test case already contains the parameters of each interface and the interface operation flow, and the scene test case is also generated according to the preset scene rule, so that the test script can be directly generated according to the test case, and the error caused by manually writing the script is avoided. And meanwhile, the flow test script and the scene test script are respectively operated to obtain a flow test result and a scene test result, so that the problems of the interface can be rapidly determined, and the efficiency of the interface test is further improved.
According to the method and the device, the interfaces to be detected are classified to obtain the flow interfaces and the scene interfaces, so that the flow test and the scene test of the interfaces are separated, and the complexity of interface test case design is reduced. The flow interface is utilized to create a flow interface diagram, a flow test case is generated according to the flow interface diagram and a preset flow control diagram, the interface to be detected can be used as an object to be imported into the test case through graphic modeling of the interface, the complicated and visual manual writing is avoided, meanwhile, the interface is associated with the case, the case needing to be adjusted can be pushed in time if the interface is changed, and the efficiency of interface test is improved. And the flow interface and the scene test cases of the scene interface are generated according to the preset scene rules, and all the scene test cases can be modified only by modifying the scene rules, so that the overall maintenance capability and detection efficiency of the scene cases are improved. Therefore, the embodiment of the invention can solve the problem of lower interface test efficiency.
Fig. 6 is a functional block diagram of an interface testing apparatus according to an embodiment of the present invention.
The interface test apparatus 100 of the present invention may be installed in an electronic device. The interface test device 100 may include an interface classification module 101, an interface diagram creation module 102, a flow case generation module 103, a scene case generation module 104, and an interface detection module 105 according to the implemented functions. The module of the invention, which may also be referred to as a unit, refers to a series of computer program segments, which are stored in the memory of the electronic device, capable of being executed by the processor of the electronic device and of performing a fixed function.
In the present embodiment, the functions concerning the respective modules/units are as follows:
the interface classification module 101 is configured to classify an interface set to be detected according to an interface keyword, so as to obtain a flow interface set and a scene interface set.
In the embodiment of the invention, the interface to be detected refers to a part for connecting and interacting with an external system, a system and internal subsystems, and is mainly used for data exchange, transmission, control and management processes, inter-logic dependency relationship among systems and the like. The process interface refers to an interface related to a service process, and can be combined with other interfaces to form a complete service flow according to service characteristics of the interface, including: registration interface, login interface, etc. The scene interface is an interface for different service scenes, and is used for verifying whether the content format and the field content of a single interface meet the design requirement, and is generally irrelevant to other interfaces, for example, an interface with different settings according to the content of the interface request, an interface with different settings according to the field types of the interface, and the like.
Specifically, the interface classification module 101 obtains a flow interface set and a scene interface set by:
extracting keywords of interfaces to be detected in the interfaces to be detected set to obtain the interface keywords;
Sequentially calculating the similarity between the interface keywords and keywords in a preset business process library;
if the similarity is greater than or equal to a preset similarity threshold, determining that the interface to be detected corresponding to the interface keyword is a flow interface, and summarizing the flow interface to obtain the flow interface set;
and if the similarity is smaller than a preset similarity threshold, determining that the interface to be detected corresponding to the interface keyword is a scene interface, and summarizing the scene interface to obtain the scene interface set.
In the embodiment of the present invention, the preset business process library may be constructed according to an actual business process, for example, the business process library may include keywords such as "registration", "login", "verification", "save", "submit", etc.
In the embodiment of the present invention, the interface classification module 101 sequentially calculates the similarity between the interface keywords and the keywords in the preset business process library by the following operations:
and sequentially calculating the similarity between the interface keywords and keywords in a preset business process library by using the following formula:
wherein j (A, B) is the similarity, A is an interface keyword, and B is a keyword in the business process library.
In one embodiment of the present invention, the similarity threshold is 100%.
In the embodiment of the invention, the keywords of the interfaces to be detected in the interfaces to be detected set can be extracted by using a preset language processing algorithm, wherein the preset language processing algorithm can be a TextRank, a semantic-based keyword extraction algorithm and the like which are disclosed at present. For example, the interface to be detected may be a "login interface", the extracted interface keyword is "login", and the matching is performed in the business process library, and the "login interface" is determined to be a process interface according to the similarity between the interface keyword and the keyword in the business process library.
According to the embodiment of the invention, the flow interface set and the scene interface set are obtained by classifying the interface set to be detected, and the flow test case and the scene test case can be respectively generated, so that the flow test and the scene test are carried out separately, and the complexity of the interface test case design is reduced.
The interface diagram creation module 102 is configured to create a flow interface diagram according to the flow interface set.
In the embodiment of the invention, the flow interface diagram may be a UML (Unified Modeling Language ) diagram, where the UML (Unified Modeling Language, unified modeling language) diagram is a graphical language supporting modeling and software system development, and provides modeling and visual support for all stages of software development, including from requirement analysis to specification, to construction and configuration, and so on.
Specifically, the interface map creation module 102 creates a flow interface map by:
acquiring a flow interface template diagram, wherein the flow interface template diagram comprises extraction fields;
extracting the fields of the interfaces in the process interface set by using the extraction fields to obtain process interface fields;
and filling the flow interface field into the flow interface template diagram to obtain the flow interface diagram.
In an optional embodiment of the present invention, the flow interface template diagram is a UML template diagram, and the extraction field in the flow interface template diagram includes: "interface name", "request header", "request body", "expected interface", "expected result", "check mode", and "actual result", etc., the "interface name" is used to extract the interface name; the "request header" is used to extract the Content of the request header, such as Content-Type, session, etc.; the 'request body' is used for extracting specific request Content, for example, the request body can be automatically assembled into a test case meeting the requirements according to defined Content-Type; the 'expected interface' is used for extracting the content to be checked by the interface; the verification mode can be equal to, contain, not contain, be greater than or equal to, and can be developed according to specific requirements; the "expected result" refers to a desired result, and may be a specific value or an argument; the "actual result" refers to the actual value in the returned content, and may be any expression of the extracted result, such as jsonpath, xpath, regular expression, and the like.
In the embodiment of the invention, the flow interface diagram is obtained by carrying out graphic modeling on the flow interface, so that the interface can be embodied in a graphic mode, and the system is more visual and is easy to maintain.
The flow case generating module 103 is configured to generate a flow test case by using the flow interface diagram and a preset flow control diagram.
In the embodiment of the present invention, the flow case generation module 103 generates a flow test case by:
receiving a business process instruction of a user;
performing flow arrangement on the flow interface diagram and the flow control diagram according to the business flow instruction to obtain an original flow diagram;
and adding a parameter extraction diagram into the original flow chart to obtain the flow test case.
In an alternative embodiment of the present invention, the business process instruction refers to an instruction for performing process combination on the flow interface diagram according to an actual business process. The preset flow control chart (for example, may be a diamond chart) is used for controlling the flow trend according to the judged result so as to improve the robustness of the interface test, and the flow control chart includes any type of self-defined and resolvable judgment expression, and can perform different processes according to the judgment result.
In the embodiment of the invention, in the script of the actual interface test, the condition that the subsequent interface returns the content by using the previous interface often occurs, so that parameter extraction is required, and the parameter extraction diagram comprises fields such as an extraction mode, an extraction expression, a variable name and the like. The "extraction mode" refers to a specific mode for extracting data, and may be jsonpath, xpath, regular expression, etc.; the expression "extraction expression" refers to an expression corresponding to an extraction mode; the "variable name" is used to hold the extracted parameters.
Meanwhile, in the embodiment of the invention, graphics are not needed for parameter transfer, and the parameter transfer is directly replaced by a defined expression where needed, such as { { { variable name } }, $ { variable name }.
In the embodiment of the invention, the interface can be used as an object to be imported into the test case by carrying out graphic modeling on the interface, the interface test data is strictly generated according to the interface definition, the complexity of manual writing is avoided, and the efficiency of the interface test is improved.
The scene case generating module 104 is configured to generate the flow interface set and a scene test case of the interface in the scene interface set according to a preset scene rule.
In the embodiment of the present invention, the preset scene rules include a request content scene rule and a field type scene rule, where the request content scene rule includes: A. and B, the structure of the requested content is inconsistent with the definition, if the content in the json format is required to be transmitted, but the format is actually transmitted, and C, the structure of the requested content is incomplete, if the requested content is not in a complete json format. The field type scene rules include: A. contents conforming to the field type and rule, B, contents not conforming to the field rule, C, contents not conforming to the field type, D, oversized or ultralong contents, E, null and G, corresponding field deletion.
In the embodiment of the present invention, the scene case generation module 104 generates the flow interface set and the scene test cases of the interfaces in the scene interface set by the following operations:
acquiring a preset scene rule, wherein the scene rule comprises a request content scene rule and a field type scene rule;
generating a request content scene use case of each interface in the flow interface set and the scene interface set by using the request content scene rule, and generating a field type scene use case of each interface in the flow interface set and the scene interface set by using the field type scene rule;
And summarizing the scene use cases of the request content and the scene use cases of the field type to obtain the scene test use cases.
In the embodiment of the invention, since the interfaces are defined, corresponding scene test cases can be automatically generated according to the scene rules of the request content and the scene rules of the field types aiming at the request content and the field types of each interface, so that the test efficiency is improved, and meanwhile, the scene test cases are generated according to the established scene rules, so that the existing cases can be updated by managing the corresponding scene rules, and the maintenance cost is reduced.
The interface detection module 105 is configured to detect the flow test case and the scene test case respectively, so as to obtain an interface test result.
Specifically, the interface detection module 105 obtains an interface test result by:
generating a flow test script according to the flow test case, and generating a scene test script according to the scene test case;
and respectively running the flow test script and the scene test script to obtain a flow test result and a scene test result, and summarizing the flow test result and the scene test result to obtain the interface test result.
In the embodiment of the invention, the flow test case already contains the parameters of each interface and the interface operation flow, and the scene test case is also generated according to the preset scene rule, so that the test script can be directly generated according to the test case, and the error caused by manually writing the script is avoided. And meanwhile, the flow test script and the scene test script are respectively operated to obtain a flow test result and a scene test result, so that the problems of the interface can be rapidly determined, and the efficiency of the interface test is further improved.
Fig. 7 is a schematic structural diagram of an electronic device for implementing an interface testing method according to an embodiment of the present invention.
The electronic device 1 may comprise a processor 10, a memory 11 and a bus, and may further comprise a computer program, such as an interface test program 12, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, including flash memory, a mobile hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device 1, such as a removable hard disk of the electronic device 1. The memory 11 may in other embodiments also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the electronic device 1. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 11 may be used not only for storing application software installed in the electronic device 1 and various types of data, such as codes of the interface test program 12, but also for temporarily storing data that has been output or is to be output.
The processor 10 may be comprised of integrated circuits in some embodiments, for example, a single packaged integrated circuit, or may be comprised of multiple integrated circuits packaged with the same or different functions, including one or more central processing units (Central Processing unit, CPU), microprocessors, digital processing chips, graphics processors, combinations of various control chips, and the like. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects respective parts of the entire electronic device using various interfaces and lines, executes or executes programs or modules (e.g., interface test programs, etc.) stored in the memory 11, and invokes data stored in the memory 11 to perform various functions of the electronic device 1 and process data.
The bus may be a peripheral component interconnect standard (peripheral component interconnect, PCI) bus or an extended industry standard architecture (extended industry standard architecture, EISA) bus, among others. The bus may be classified as an address bus, a data bus, a control bus, etc. The bus is arranged to enable a connection communication between the memory 11 and at least one processor 10 etc.
Fig. 7 shows only an electronic device with components, it being understood by a person skilled in the art that the structure shown in fig. 7 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or may combine certain components, or may be arranged in different components.
For example, although not shown, the electronic device 1 may further include a power source (such as a battery) for supplying power to each component, and preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that functions of charge management, discharge management, power consumption management, and the like are implemented through the power management device. The power supply may also include one or more of any of a direct current or alternating current power supply, recharging device, power failure detection circuit, power converter or inverter, power status indicator, etc. The electronic device 1 may further include various sensors, bluetooth modules, wi-Fi modules, etc., which will not be described herein.
Further, the electronic device 1 may also comprise a network interface, optionally the network interface may comprise a wired interface and/or a wireless interface (e.g. WI-FI interface, bluetooth interface, etc.), typically used for establishing a communication connection between the electronic device 1 and other electronic devices.
The electronic device 1 may optionally further comprise a user interface, which may be a Display, an input unit, such as a Keyboard (Keyboard), or a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, or the like. The display may also be referred to as a display screen or display unit, as appropriate, for displaying information processed in the electronic device 1 and for displaying a visual user interface.
It should be understood that the embodiments described are for illustrative purposes only and are not limited to this configuration in the scope of the patent application.
The interface test program 12 stored in the memory 11 of the electronic device 1 is a combination of instructions that, when executed in the processor 10, may implement:
classifying the interface sets to be detected according to the interface keywords to obtain a flow interface set and a scene interface set;
creating a flow interface diagram according to the flow interface set;
generating a flow test case by using the flow interface diagram and a preset flow control diagram;
Generating a scene test case of the flow interface set and the scene interface set interface according to a preset scene rule;
and respectively detecting the flow test case and the scene test case to obtain an interface test result.
Specifically, the specific implementation method of the above instructions by the processor 10 may refer to descriptions of related steps in the corresponding embodiments of fig. 1 to 5, which are not repeated herein.
Further, the modules/units integrated in the electronic device 1 may be stored in a computer readable storage medium if implemented in the form of software functional units and sold or used as separate products. The computer readable storage medium may be volatile or nonvolatile. For example, the computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM).
The present invention also provides a computer readable storage medium storing a computer program which, when executed by a processor of an electronic device, can implement:
Classifying the interface sets to be detected according to the interface keywords to obtain a flow interface set and a scene interface set;
creating a flow interface diagram according to the flow interface set;
generating a flow test case by using the flow interface diagram and a preset flow control diagram;
generating a scene test case of the flow interface set and the scene interface set interface according to a preset scene rule;
and respectively detecting the flow test case and the scene test case to obtain an interface test result.
In the several embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be other manners of division when actually implemented.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof.
The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The Blockchain (Blockchain), which is essentially a decentralised database, is a string of data blocks that are generated by cryptographic means in association, each data block containing a batch of information of network transactions for verifying the validity of the information (anti-counterfeiting) and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, an application services layer, and the like.
Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units or means recited in the system claims can also be implemented by means of software or hardware by means of one unit or means. The terms second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (7)

1. An interface testing method, the method comprising:
classifying the interface sets to be detected according to the interface keywords to obtain a flow interface set and a scene interface set;
creating a flow interface diagram according to the flow interface set, including: acquiring a flow interface template diagram, wherein the flow interface template diagram comprises extraction fields; extracting the fields of the interfaces in the process interface set by using the extraction fields to obtain process interface fields; filling the flow interface field into the flow interface template diagram to obtain the flow interface diagram;
Generating a flow test case by using the flow interface diagram and a preset flow control diagram, including: receiving a business flow instruction of a user, performing flow arrangement on the flow interface diagram and the flow control diagram according to the business flow instruction to obtain an original flow diagram, and adding a parameter extraction diagram into the original flow diagram to obtain the flow test case;
generating a scene test case of the flow interface set and the scene interface set interface according to a preset scene rule;
detecting the flow test cases and the scene test cases respectively to obtain interface test results;
the generating the flow interface set and the scene test cases of the interfaces in the scene interface set according to the preset scene rules includes:
acquiring a preset scene rule, wherein the scene rule comprises a request content scene rule and a field type scene rule;
generating a request content scene use case of each interface in the flow interface set and the scene interface set by using the request content scene rule, and generating a field type scene use case of each interface in the flow interface set and the scene interface set by using the field type scene rule;
And summarizing the scene use cases of the request content and the scene use cases of the field type to obtain the scene test use cases.
2. The method for testing interfaces according to claim 1, wherein the step of classifying the interface set to be tested according to the interface keywords to obtain a flow interface set and a scene interface set comprises the steps of:
extracting keywords of interfaces to be detected in the interfaces to be detected set to obtain the interface keywords;
sequentially calculating the similarity between the interface keywords and keywords in a preset business process library;
if the similarity is greater than or equal to a preset similarity threshold, determining that the interface to be detected corresponding to the interface keyword is a flow interface, and summarizing the flow interface to obtain the flow interface set;
and if the similarity is smaller than a preset similarity threshold, determining that the interface to be detected corresponding to the interface keyword is a scene interface, and summarizing the scene interface to obtain the scene interface set.
3. The interface testing method according to claim 2, wherein the sequentially calculating the similarity between the interface keywords and keywords in a preset business process library includes:
and sequentially calculating the similarity between the interface keywords and keywords in a preset business process library by using the following formula:
Wherein j (A, B) is the similarity, A is an interface keyword, and B is a keyword in the business process library.
4. The method of claim 1, wherein the detecting the flow test case and the scene test case to obtain the interface test result includes:
generating a flow test script according to the flow test case, and generating a scene test script according to the scene test case;
and respectively running the flow test script and the scene test script to obtain a flow test result and a scene test result, and summarizing the flow test result and the scene test result to obtain the interface test result.
5. An interface testing apparatus for implementing the interface testing method of any one of claims 1 to 4, the apparatus comprising:
the interface classification module is used for classifying the interface set to be detected according to the interface keywords to obtain a flow interface set and a scene interface set;
the interface diagram creation module is used for creating a flow interface diagram according to the flow interface set;
the flow case generation module is used for generating a flow test case by utilizing the flow interface diagram and a preset flow control diagram;
The scene case generation module is used for generating the flow interface set and the scene test cases of the interfaces in the scene interface set according to preset scene rules;
and the interface detection module is used for respectively detecting the flow test case and the scene test case to obtain an interface test result.
6. An electronic device, the electronic device comprising:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the interface testing method of any one of claims 1 to 4.
7. A computer readable storage medium storing a computer program, wherein the computer program when executed by a processor implements the interface testing method according to any one of claims 1 to 4.
CN202110380190.4A 2021-04-08 2021-04-08 Interface testing method, device, equipment and storage medium Active CN113051171B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110380190.4A CN113051171B (en) 2021-04-08 2021-04-08 Interface testing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110380190.4A CN113051171B (en) 2021-04-08 2021-04-08 Interface testing method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113051171A CN113051171A (en) 2021-06-29
CN113051171B true CN113051171B (en) 2024-04-02

Family

ID=76519024

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110380190.4A Active CN113051171B (en) 2021-04-08 2021-04-08 Interface testing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113051171B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114840413A (en) * 2022-03-25 2022-08-02 阿里云计算有限公司 Integration test method, system, electronic device and readable storage medium
CN115203061B (en) * 2022-09-14 2022-12-20 广东美的暖通设备有限公司 Interface automation test method and device, electronic equipment and storage medium
CN118331888A (en) * 2024-06-13 2024-07-12 中国电信股份有限公司 Interface testing method and related equipment

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628738A (en) * 2018-01-11 2018-10-09 百富计算机技术(深圳)有限公司 The generation method and device of application programming interface test case
CN109446099A (en) * 2018-11-09 2019-03-08 贵州医渡云技术有限公司 Automatic test cases generation method, device, medium and electronic equipment
CN109684209A (en) * 2018-12-17 2019-04-26 北京奇虎科技有限公司 A kind of method for generating test case, device and electronic equipment
CN110162468A (en) * 2019-04-26 2019-08-23 腾讯科技(深圳)有限公司 A kind of test method, device and computer readable storage medium
CN110750442A (en) * 2019-09-06 2020-02-04 平安医疗健康管理股份有限公司 Test case generation method, device, equipment and storage medium
CN112231230A (en) * 2020-11-12 2021-01-15 腾讯科技(深圳)有限公司 Test case management method and device, electronic equipment and storage medium
CN112256558A (en) * 2020-09-17 2021-01-22 苏宁云计算有限公司 Test case generation method and device, computer equipment and storage medium
CN112506779A (en) * 2020-12-10 2021-03-16 平安普惠企业管理有限公司 Software interface testing method and device, electronic equipment and storage medium
CN112597020A (en) * 2020-12-24 2021-04-02 平安普惠企业管理有限公司 Interface testing method and device, computer equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10089217B2 (en) * 2014-09-23 2018-10-02 Red Hat, Inc. Identification of software test cases

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628738A (en) * 2018-01-11 2018-10-09 百富计算机技术(深圳)有限公司 The generation method and device of application programming interface test case
CN109446099A (en) * 2018-11-09 2019-03-08 贵州医渡云技术有限公司 Automatic test cases generation method, device, medium and electronic equipment
CN109684209A (en) * 2018-12-17 2019-04-26 北京奇虎科技有限公司 A kind of method for generating test case, device and electronic equipment
CN110162468A (en) * 2019-04-26 2019-08-23 腾讯科技(深圳)有限公司 A kind of test method, device and computer readable storage medium
CN110750442A (en) * 2019-09-06 2020-02-04 平安医疗健康管理股份有限公司 Test case generation method, device, equipment and storage medium
CN112256558A (en) * 2020-09-17 2021-01-22 苏宁云计算有限公司 Test case generation method and device, computer equipment and storage medium
CN112231230A (en) * 2020-11-12 2021-01-15 腾讯科技(深圳)有限公司 Test case management method and device, electronic equipment and storage medium
CN112506779A (en) * 2020-12-10 2021-03-16 平安普惠企业管理有限公司 Software interface testing method and device, electronic equipment and storage medium
CN112597020A (en) * 2020-12-24 2021-04-02 平安普惠企业管理有限公司 Interface testing method and device, computer equipment and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
On the Large-scale Graph Data Processing for User Interface Testing in Big Data Science Projects;Yasin Uygun 等;《2020 IEEE International Conference on Big Data (Big Data)》;2049-2056 *
中国优秀硕士学位论文全文数据库;李岩峰;《中国优秀硕士学位论文全文数据库 信息科技辑》(第2期);I138-391 *
基于通信协议的接口测试用例自动生成框架;刘逻 等;《测控技术》;第39卷(第1期);46-54 *

Also Published As

Publication number Publication date
CN113051171A (en) 2021-06-29

Similar Documents

Publication Publication Date Title
CN113051171B (en) Interface testing method, device, equipment and storage medium
CN112732567B (en) Mock data testing method and device based on ip, electronic equipment and storage medium
CN113238929B (en) Code testing method and device based on Mock data, electronic equipment and storage medium
CN113806434B (en) Big data processing method, device, equipment and medium
CN115964307B (en) Automatic test method, device, equipment and medium for transaction data
CN114881616A (en) Business process execution method and device, electronic equipment and storage medium
CN114398194A (en) Data collection method and device, electronic equipment and readable storage medium
CN113282854A (en) Data request response method and device, electronic equipment and storage medium
CN115129753A (en) Data blood relationship analysis method and device, electronic equipment and storage medium
CN112527655B (en) Software version quality abnormality detection method and device, electronic equipment and storage medium
CN114385497A (en) Test environment generation method and device, electronic equipment and storage medium
CN114398282A (en) Test script generation method, device, equipment and storage medium
CN113434542A (en) Data relation identification method and device, electronic equipment and storage medium
CN115037587B (en) Automatic issuing method, device, equipment and storage medium for network equipment configuration
CN113254446B (en) Data fusion method, device, electronic equipment and medium
CN111859985B (en) AI customer service model test method and device, electronic equipment and storage medium
CN112686759A (en) Account checking monitoring method, device, equipment and medium
CN112667244A (en) Data verification method and device, electronic equipment and computer readable storage medium
CN112527282B (en) Front-end page verification method and device, electronic equipment and storage medium
CN112214981B (en) Presentation file generation method and device, electronic equipment and storage medium
CN113704109B (en) Front-end and back-end data interaction method and device, electronic equipment and storage medium
CN114564413B (en) Synchronous equipment testing method and device
CN116610572A (en) Object testing method and device, electronic equipment and storage medium
CN115277469A (en) Weak network visualization control method and device, electronic equipment and readable storage medium
CN114840438A (en) Text code detection and evaluation method, device, equipment 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
TA01 Transfer of patent application right

Effective date of registration: 20211018

Address after: 518000 Room 201, building A, No. 1, Qian Wan Road, Qianhai Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong (Shenzhen Qianhai business secretary Co., Ltd.)

Applicant after: Shenzhen saiante Technology Service Co.,Ltd.

Address before: 1-34 / F, Qianhai free trade building, 3048 Xinghai Avenue, Mawan, Qianhai Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong 518000

Applicant before: Ping An International Smart City Technology Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant