CN112559368A - Interface automation test method and its use case generation method, equipment and storage medium - Google Patents

Interface automation test method and its use case generation method, equipment and storage medium Download PDF

Info

Publication number
CN112559368A
CN112559368A CN202011539604.5A CN202011539604A CN112559368A CN 112559368 A CN112559368 A CN 112559368A CN 202011539604 A CN202011539604 A CN 202011539604A CN 112559368 A CN112559368 A CN 112559368A
Authority
CN
China
Prior art keywords
interface
tested
test
testing
result
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
CN202011539604.5A
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.)
Mashang Xiaofei Finance Co Ltd
Mashang Consumer Finance Co Ltd
Original Assignee
Mashang Xiaofei Finance 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 Mashang Xiaofei Finance Co Ltd filed Critical Mashang Xiaofei Finance Co Ltd
Priority to CN202011539604.5A priority Critical patent/CN112559368A/en
Publication of CN112559368A publication Critical patent/CN112559368A/en
Pending legal-status Critical Current

Links

Images

Classifications

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

Landscapes

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

Abstract

The application discloses an interface automatic test method, a case generation method, equipment and a storage medium thereof. The automatic interface testing method comprises the following steps: acquiring a mind map of a test case, wherein the mind map represents a test sequence of interfaces to be tested of the test case and corresponding interface elements of the interfaces to be tested, and the interface elements are information required by the interfaces to be tested during testing; analyzing a thinking guide diagram of the test case to obtain a test sequence of the interface to be tested and corresponding interface elements; and testing the interface to be tested based on the test sequence and the interface elements to obtain a test result of the interface to be tested. According to the scheme, the test of the interface to be tested can be realized according to the content included in the mind map of the test case, the information required by the test of the interface to be tested is not required to be designed by manually compiling program codes, the automatic test process can be simplified, and the time is saved.

Description

Interface automation test method and its use case generation method, equipment and storage medium
Technical Field
The present application relates to the field of interface testing technologies, and in particular, to an interface automated testing method, a method and an apparatus for generating a use case thereof, and a storage medium.
Background
Before software is formally on-line, software functions are generally required to be tested, and the software automatic test is to realize a group of test cases through codes and send the test cases to a computer to be automatically executed at a proper time so as to finish the software test. When the software realizes the functions, a plurality of interfaces are often required to be called and executed step by step according to the service logic of the software, so that the interfaces provided by the software need to be tested, and the automatic testing of the interfaces is realized.
In order to realize the interface automatic test, a test case required by the interface test needs to be designed and written. Generally, a test case required by interface automation is realized by a program, data is managed by a form, readability is poor, and a case designer is required to have certain coding capability. For example, the test case required by the interface automation test provides an interface reference file to the outside by using an interface definition standard service, so that the information required by the actual test is copied from the interface reference file and then delivered to a test tool to complete the interface automation test.
Disclosure of Invention
The technical problem mainly solved by the application is to provide an interface automatic testing method, a case generating method, equipment and a storage medium thereof, so that labor can be saved, and the testing efficiency can be improved.
In order to solve the above problem, a first aspect of the present application provides an interface automation test method, including: acquiring a mind map of a test case, wherein the mind map represents a test sequence of interfaces to be tested of the test case and corresponding interface elements of the interfaces to be tested, and the interface elements are information required by the interfaces to be tested during testing; analyzing the thinking guide diagram of the test case to obtain the test sequence of the interface to be tested and the corresponding interface element; and testing the interface to be tested based on the testing sequence and the interface elements to obtain a testing result of the interface to be tested.
Wherein the interface element comprises at least one of: the interface testing system comprises an interface name, an interface class name, interface parameters, an interface execution mark and an expected return result preset for the interface to be tested, wherein the interface execution mark is used for indicating whether to execute the test of the interface to be tested.
The thinking guide graph comprises at least one theme, each theme corresponds to one interface to be tested, and the connection relation among the themes is used for representing the testing sequence of the interfaces to be tested corresponding to the themes; the information of the theme is used for representing the interface element of the interface to be tested corresponding to the theme.
Wherein the theme includes at least one of the following information: the subject name is used for recording the interface name of the interface to be tested; the label is used for recording the interface class name of the interface to be tested; the remark is used for recording the interface parameters of the interface to be tested and/or the expected return result; an icon serving as the interface execution flag.
The testing the interface to be tested based on the testing sequence and the interface elements to obtain a testing result of the interface to be tested includes: testing the to-be-tested interfaces according to the testing sequence by using the interface parameters to obtain an actual return result of the to-be-tested interfaces; and obtaining the test result of the interface to be tested based on the actual return result.
If the interface element includes the interface name, the interface class name, and the interface parameter, the interface parameter is used to test the to-be-tested interface according to the test sequence to obtain an actual return result of the to-be-tested interface, including: instantiating the interface class name of the interface to be tested; in the class corresponding to the interface class name of the interface to be tested, finding a test method corresponding to the interface name of the interface to be tested; calling the testing method based on the interface parameters to obtain an actual return result of the interface to be tested; and/or, if the interface element further includes the interface execution flag, before the interface to be tested is tested according to the test sequence by using the interface parameter to obtain an actual return result of the interface to be tested, the method further includes: if the interface execution mark does not exist in the current interface to be tested, testing the current interface to be tested by using the interface parameters to obtain an actual return result of the current interface to be tested; if the interface execution mark exists in the current interface to be tested, the current interface to be tested is not tested, or the interface to be tested with the test sequence behind the current interface to be tested is not tested.
Wherein the interface parameters include the expected return result, and the obtaining the interface test result based on the actual return result includes: and comparing the actual return result and the expected return result of the interface to be tested, and obtaining whether the test result of the interface to be tested passes the test or not based on the comparison result. And/or after the test result of the interface to be tested is obtained based on the actual return result, the method further comprises the following steps: recording test result information in an annotation of the mind map, wherein the test result information includes at least one of: the actual return result, the return time of the actual return result and the interface test result.
Wherein, the obtaining of the thinking map of the test case comprises: receiving an interface reference file of an interface definition standard service; analyzing the interface reference file to form a thinking guide graph of the test template; and responding to a user instruction, and adjusting the test sequence and/or the interface elements in the mind map of the test template to obtain the mind map of the test case.
In the mind map of the test template, a sub-theme represents a corresponding template case, and the analyzing of the interface reference file to form the mind map of the test template includes: taking the item name in the interface reference file as a parent theme of the thinking guide graph of the test template; creating a sub-theme for each path field of the interface reference file, and connecting the corresponding sub-theme with the parent theme according to the sequence of the path fields; correspondingly recording the interface name, the interface class name and the interface parameter in the path field in a subject name, a label and a remark of the subtopic; the adjusting the test sequence and/or the interface element in the mind map of the test template comprises at least one of the following steps: deleting and/or adding the sub-topic; adjusting the connection relation between the sub-topics; modifying the interface parameters in the remarks.
In order to solve the above problem, a second aspect of the present application provides a method for generating an interface test case, where the method includes: determining a test sequence of interfaces to be tested and corresponding interface elements of the interfaces to be tested; the interface element is information required by the interface to be tested during testing; and drawing the test sequence of the interface to be tested and the corresponding interface element of the interface to be tested in a mind map to obtain the mind map of the test case.
Wherein the interface element comprises at least one of: the interface testing system comprises an interface name, an interface class name, interface parameters, an interface execution mark and an expected return result preset for the interface to be tested, wherein the interface execution mark is used for indicating whether to execute the test of the interface to be tested; the thinking guide graph comprises at least one theme, each theme corresponds to one interface to be tested, and the connection relation among the themes is used for representing the testing sequence of the interfaces to be tested corresponding to the themes; the information of the theme is used for representing interface elements of the interface to be tested corresponding to the theme; wherein the theme includes at least one of the following information: the subject name is used for recording the interface name of the interface to be tested; the label is used for recording the interface class name of the interface to be tested; the remark is used for recording the interface parameters of the interface to be tested and/or the expected return result; an icon serving as the interface execution flag.
To solve the above problem, a third aspect of the present application provides an electronic apparatus comprising: a memory and a processor coupled to each other; the processor is configured to execute the program instructions stored in the memory to implement the interface automation testing method of the first aspect, or implement the interface test case generating method of the second aspect.
In order to solve the above problem, a fourth aspect of the present application provides a computer-readable storage medium, on which program instructions capable of being executed by a processor are stored, and when the program instructions are executed by the processor, the method for automatically testing an interface of the first aspect or the method for generating an interface test case of the second aspect is implemented.
By the mode, the mind map represents the test sequence of the to-be-tested interface of the test case and the corresponding interface element of the to-be-tested interface, and the interface element is the information required by the to-be-tested interface during testing, so that the mind map of the test case is obtained to be equivalent to the test sequence of the to-be-tested interface and the information required by the to-be-tested interface during testing, the mind map of the test case is analyzed, the test sequence of the to-be-tested interface and the corresponding interface element are obtained, the to-be-tested interface can be tested based on the test sequence and the interface element, the test result of the to-be-tested interface is obtained, the test of the to-be-tested interface can be realized only by the content included in the mind map of the test case, the information required by the to-be-tested interface during testing is not required to be designed by manually, time is saved.
Drawings
FIG. 1 is a schematic flow chart diagram illustrating an exemplary method for automated interface testing;
FIG. 2 is a flowchart illustrating an embodiment of the interface automated testing method of the present application in step S11;
FIG. 3 is a flowchart illustrating step S13 of an exemplary method for automated testing of an interface according to the present application;
FIG. 4 is a flowchart illustrating an embodiment of a method for generating an interface test case according to the present application;
FIG. 5 is a schematic diagram of a thinking diagram test case of an embodiment of the interface automation test method of the present application;
FIG. 6 is a remark diagram illustrating a query blacklist in the thinking diagram test case of FIG. 5;
FIG. 7 is a block diagram of an embodiment of an electronic device of the present application;
FIG. 8 is a block diagram of an embodiment of a computer-readable storage medium of the present application.
Detailed Description
The following describes in detail the embodiments of the present application with reference to the drawings attached hereto.
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application. The term "and/or" herein is merely an association describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship. Further, the term "plurality" herein means two or more than two.
Referring to fig. 1, fig. 1 is a schematic flow chart illustrating an embodiment of an interface automatic testing method according to the present application. Specifically, the method of the present embodiment includes the following steps:
step S11: and acquiring a mind map of the test case.
When the software realizes the functions, a plurality of interfaces are often required to be called, and the software is executed step by step according to the service logic of the software, so the automatic testing of the interfaces is carried out on the interfaces which are required to be called when the software realizes the functions according to the service logic. The thinking guide diagram of the test case represents the test sequence of the interfaces to be tested of the test case and the corresponding interface elements of the interfaces to be tested, so that the scheduling relation among the interfaces to be tested is clearer, the display and the understanding are convenient, and the readability is improved. The mind map comprises a plurality of interfaces to be tested in the test case, and the mind map can not only represent the test sequence of the plurality of interfaces to be tested, but also represent interface elements of each interface to be tested in the test case, so that the mind map can comprise all information required by the interfaces to be tested in the test case during testing.
The test sequence in the thinking diagram of the test case can reflect the business logic sequence between the interfaces; and the interface element is information required by the interface to be tested during testing. The interface element includes at least one of: the interface test system comprises an interface name, an interface class name, interface parameters, an interface execution mark and an expected return result preset for an interface to be tested. The interface name can be customized, such as inquiring the blacklist, deleting the blacklist, pausing for several seconds, adding the blacklist, and the like. The interface class name is, for example, RISKFACECMP, TOOL. The interface parameter is used for being provided for the interface to be tested, so that the interface to be tested calls the testing method corresponding to the interface to be tested based on the interface parameter. The interface execution flag is used to indicate whether to execute the test of the interface to be tested.
The thinking guide graph can comprise themes, wherein the theme can be a parent theme or a child theme, so that each theme corresponds to one interface to be tested in the thinking guide graph of the test case, and the connection relation among the themes is used for representing the test sequence of the interfaces to be tested corresponding to the themes; the information of the theme is used for representing the interface element of the interface to be tested corresponding to the theme. Each theme of the mind map corresponds to one interface to be tested, and the information of the theme represents the interface elements of the corresponding interface to be tested. In an embodiment, each theme of the mind map may include a theme name, a tag, a remark, an icon, an annotation, and other functional tools, so that interface elements may be recorded by the functional tools, information required by the interface to be tested during testing may be conveniently embodied, and interface elements recorded by the functional tools may be customized, and information required by the interface to be tested during testing may be recorded. In one embodiment, the subject name of the subject is used for recording the interface name of the interface to be tested; the label is used for recording the interface class name of the interface to be tested; remarks for recording interface parameters and/or expected return results of the interface to be tested; and the icon is used as an interface execution mark.
If a test case contains a plurality of interfaces to be tested, the information of each interface to be tested, which is required during testing, needs to be defined, and the call relation between the interfaces to be tested is indicated by using the connecting line to indicate the testing sequence of the interfaces to be tested.
The mind map of the test case of the present application may be generated by the device executing the interface automation test method itself, or may be obtained from other devices, and is not limited specifically herein. To more clearly illustrate how the device executing the interface automated testing method generates the mind diagram of the test case by itself, please refer to fig. 2, and fig. 2 is a flowchart illustrating step S11 according to an embodiment of the interface automated testing method of the present application. In this embodiment, the step S11 of obtaining the mind map of the test case may be implemented by the following steps:
step S111: an interface reference file of an interface definition standard service is received.
Interface definition standard services may provide interface references, and the interface references are used to provide test sequences and interface elements. The interface definition standard service includes but is not limited to Swagger interface service, and the interface reference file of the interface definition standard service provides the Json interface data for the Swagger interface service.
Step S112: and analyzing the interface reference file to form a thinking map of the test template.
And analyzing the interface reference file to obtain a test sequence and interface elements, and forming a mind map of the test template based on the test sequence and the interface elements, so that when the interface reference file of the interface definition standard service is converted into the mind map of the test template, all information and test sequences required by testing of a project can be converted into the mind map of the test template. For example, Json interface data is converted into an XMind test template, and the mind map of the test case can be quickly generated by using the XMind test template.
In one embodiment, in the mind map of the test template, the project name may be represented by a parent topic and the corresponding template use case may be represented by a child topic. When the interface reference file is analyzed to form the thinking guide graph of the test template, the project names in the interface reference file are used as the father subjects of the thinking guide graph of the test template; creating a sub-theme for each path field of the interface reference file, and connecting the corresponding sub-theme with the parent theme according to the sequence of the path fields, so as to obtain the test sequence in the thinking diagram of the test template; and correspondingly recording the interface name, the interface class name and the interface parameter in the path field in the subject name, the label and the remark of the subtopic, thereby obtaining the interface element in the thinking diagram of the test template.
Step S113: and responding to the user instruction, and adjusting the test sequence and/or interface elements in the mind map of the test template to obtain the mind map of the test case.
The user may be any person, such as a test case designer, a test case writer, and the like, and is not particularly limited herein. Adjusting the test sequence and/or interface elements in the mind map of the test template, and deleting and/or adding subtopics when obtaining the mind map of the test case; the connection relation between the sub-topics can be adjusted; interface parameters in the notes can be modified so that test sequences and interface elements can be edited quickly. The sub-topics represent the corresponding template use cases, and the interface names, the interface class names and the interface parameters are correspondingly recorded in the topic names, the labels and the remarks of the sub-topics, so that the interface elements can be quickly adjusted by deleting and/or adding and the like. In an application scene, when responding to a user instruction and deleting and/or adding the sub-topics, a user can directly delete and/or add the sub-topics corresponding to each interface in the mind map of the test template, and interface elements related to the interfaces are deleted and/or added integrally, so that the mind map of the test case is generated quickly. In another application scenario, after the mind map of the test template is formed, in response to a user's instruction, the mind map is created, and part or all of the test sequence and/or interface elements are copied from the mind map of the test template into the new mind map, so that the new mind map is used as the mind map of the test case.
In summary, in the mind map of the test case, the mind map of the test case includes topics, each topic corresponds to one interface to be tested, the connection relationship between the topics is used to represent the test sequence of the interface to be tested corresponding to the topic, and each topic records the information required by the interface to be tested during testing, so that the mind map of the test case simultaneously includes the definition and the logical connection relationship of the interface to be tested, and therefore, the use of the mind map of the test case to perform automatic testing on the interface can save labor, time or hardware resources and improve the testing efficiency.
Compared with the existing test case, the test case can be compiled only when users such as test case designers, test case writers and the like have a certain coding capacity, the mind map of the test case can represent the test sequence and interface elements of the to-be-tested interface of the test case, the test of the to-be-tested interface can be realized without excessive compiling operation of the users, the automatic test process can be simplified, and the time is saved. Compared with a test case which realizes the interface by a program, the information required by the interface to be tested during testing is managed by a table, and the thinking guide diagram of the test case has lower technical requirements and maintenance cost. The mind map comprises a test sequence and interface elements, and the test sequence of the interfaces to be tested can be intuitively embodied by the connection relation between the subjects of the mind map, and the interface elements can be intuitively displayed by the mind map, so that even a person without professional code writing capability can know the test sequence and the interface elements of the test case according to the mind map, and the person can conveniently adjust the test sequence and the interface elements of the test case.
Step S12: and analyzing the thinking guide diagram of the test case to obtain the test sequence of the interface to be tested and the corresponding interface element.
After the mind map of the test case is obtained, the mind map of the test case is analyzed, and the test sequence and the interface elements of the interface to be tested can be obtained. In one embodiment, after the mind map of the test case is drawn by the XMind application, the mind map of the test case can be parsed by the XMind application interface.
Step S13: and testing the interface to be tested based on the test sequence and the interface elements to obtain a test result of the interface to be tested.
And testing the interfaces to be tested by respectively utilizing the interface elements corresponding to the interfaces to be tested according to the testing sequence to obtain the testing result of the interfaces to be tested. When the interface to be tested comprises a plurality of interfaces, the plurality of interfaces to be tested are tested based on the test sequence and the interface elements to obtain the test results of the plurality of interfaces to be tested, and then the automatic interface test result can be obtained based on the test results of the plurality of interfaces to be tested. Based on the test sequence and the interface elements, the interface to be tested can be tested to obtain a test result of the interface to be tested, and the interface to be tested behind the interface to be tested is continuously tested to obtain a corresponding test result. In an implementation scenario, the step S12 and the step S13 may execute the step S12 first and then execute the step S13, that is, analyze the mind map of the test case first to obtain the test sequence and interface elements of all the interfaces to be tested, then test the interfaces to be tested based on the test sequence and interface elements to obtain the test results of the interfaces to be tested, and obtain the test results of all the interfaces to be tested after testing all the interfaces to be tested of the test case based on the test sequence and interface elements, and form the interface automated test results based on the test results of all the interfaces to be tested, where the interface automated test results include pass or fail. In another implementation scenario, the step S12 and the step S13 may also be executed simultaneously, that is, in the process of analyzing the mind map of the test case, the interface to be tested may be tested based on the test sequence and the interface elements to obtain the test result of the interface to be tested, which may be specifically set according to the actual application, and is not limited herein. And testing the interfaces to be tested in sequence according to the test sequence to obtain test results of the interfaces to be tested, if the test results of all the interfaces to be tested pass the test, forming an interface automatic test result indicating that the test passes, and if the test results of the interfaces to be tested do not pass the test, forming an interface automatic test result indicating that the test does not pass. In an embodiment, an interface automatic test result may not be formed until all the interfaces to be tested are tested, but an interface automatic test result may be formed in the process of testing the interfaces to be tested, for example, according to a test sequence, the interfaces to be tested are used as the interfaces to be tested, if the test result of the interfaces to be tested is that the test does not pass, an interface automatic test result indicating that the test does not pass is formed, if the test result of the interfaces to be tested is that the test passes, the next interface to be tested is used as the interface to be tested according to the test sequence to be tested, so that in the test process, as long as the test result of the interfaces to be tested is that the test does not pass, an interface automatic test result indicating that the test does not pass is formed, otherwise, the subsequent interfaces to be tested are continuously tested.
In order to more clearly illustrate how the interface to be tested is tested by using the test sequence and the interface elements, and the interface test result is obtained. Referring to fig. 3, fig. 3 is a schematic flowchart illustrating a step S13 of an embodiment of an interface automation test method according to the present application, in this embodiment, the step S13 may be implemented by:
in this embodiment, the interface element further includes an interface execution flag; before testing the interface to be tested by using the interface parameters in step S131 to obtain an actual returned result of the interface to be tested, the interface execution flag may be detected, so as to determine whether to test the interface to be tested according to the detected interface execution flag. If it is detected that the interface execution flag does not exist in the current interface to be tested, executing step S132 to test the current interface to be tested by using the interface parameters to obtain an actual return result of the current interface to be tested; if the interface execution mark exists in the current interface to be tested, the current interface to be tested is not tested, or the interface to be tested with the test sequence behind the current interface to be tested is not tested. In another embodiment, if it is detected that the interface execution flag exists in the current interface to be tested, step S132 is executed; and if the interface execution mark does not exist in the current interface to be tested, the current interface to be tested is not tested, or the interface to be tested with the test sequence behind the current interface to be tested is not tested. The interface execution flag may also be used as other custom functions, and is not specifically limited herein.
Step S131: and testing the interfaces to be tested according to the testing sequence by using the interface parameters to obtain the actual return result of the interfaces to be tested.
In the embodiment, the interface element comprises an interface name, an interface class name and an interface parameter, so that the interface class name of the interface to be tested is instantiated when the interface to be tested is tested by using the interface parameter to obtain an actual return result of the interface to be tested; in a class corresponding to the interface class name of the interface to be tested, finding a test method corresponding to the interface name of the interface to be tested; and calling a test method based on the interface parameters to obtain an actual return result of the interface to be tested. After instantiating the interface class name of the interface to be tested, the object to perform the test can be determined. If the interface class name of the interface to be tested is detected to be changed, re-instantiating the interface class name of the interface to be tested based on the interface class name; if the interface class name of the interface to be tested is detected to be unchanged, namely the interface class name of the interface to be tested is the same as the interface class name of the adjacent interface to be tested, which is tested, the interface class name of the interface to be tested is not required to be instantiated. The interface parameters in the remarks of the interface to be tested may be obtained by any analysis method, which is not specifically limited herein. For example, the remarks may be resolved by rows using python to obtain the interface parameters.
Step S132: and obtaining a test result of the interface to be tested based on the actual return result.
In this embodiment, the interface parameters may further include an expected return result, so that when the test result of the interface to be tested is obtained based on the actual return result, the actual return result of the interface to be tested is compared with the expected return result, and based on the comparison result, a test result of whether the test of the interface to be tested passes or not is obtained. It can be understood that, the interface parameters can be used to test all the interfaces to be tested as the interfaces to be tested, after the actual return results of all the interfaces to be tested are obtained, the actual return results and the expected return results of each interface to be tested are respectively compared, and the test result of whether the test of each interface to be tested passes or not is obtained based on the comparison result; the interface parameters can also be used for testing the interface to be tested, after the actual return result of the interface to be tested is obtained, the actual return result and the expected return result of the interface to be tested are immediately compared, then the test result of whether the test of the interface to be tested passes or not is obtained based on the comparison result, or the next interface to be tested of the interface to be tested is continuously used as a new interface to be tested, the interface to be tested is tested by using the interface parameters, and the actual return result of the interface to be tested and the subsequent steps are obtained.
In an application scenario, when the fact that the actual return result of the interface to be tested is the same as the expected return result or within a preset error range is detected, the test of the interface to be tested is passed, otherwise, the test of the interface to be tested is failed. After detecting that each interface to be tested passes the test, obtaining an automatic test result of the tested interface; and if the test of the interface to be tested fails, obtaining an automatic test result of the interface which fails, or if the test of the interface to be tested fails for a preset number of times, obtaining an automatic test result of the interface which fails. Because each interface to be tested is used as the interface to be tested according to the test sequence, the interface to be tested is used as the interface to be tested according to the test sequence after the test of the interface to be tested is not passed.
In another embodiment, after the interface test result is obtained based on the actual return result, the test result information may also be recorded in the annotation of the mind map of the test case. In order to improve the accuracy of the test result, the mind map of the test case, in which the test result information is recorded, may also be used as the mind map of the test case obtained in step S11 of the present application, so that the mind map of the test case is tested multiple times, and the test result of the interface to be tested based on multiple times is used as the final test result of the interface to be tested, thereby forming an automated interface test result. Wherein the test result information includes at least one of: actual return results, return time of the actual return results, and interface test results. The test result information may also include other information reflecting the test result of the interface to be tested, and is not limited in particular herein.
By the mode, the mind map represents the test sequence and the interface elements of the to-be-tested interface of the test case, and the interface elements are information required by the to-be-tested interface during testing, so that the obtained mind map of the test case is equivalent to the test sequence of the to-be-tested interface and the information required by the to-be-tested interface during testing, the mind map of the test case is analyzed, the to-be-tested interface can be tested based on the test sequence and the interface elements after the test sequence and the interface elements of the to-be-tested interface are obtained, the test result of the to-be-tested interface is obtained, the test of the to-be-tested interface can be realized only according to the content included by the mind map of the test case, the automatic test process can be simplified, and the time can.
The mind map of the test case can be generated by a generation method of the interface test case. Referring to fig. 4, fig. 4 is a flowchart illustrating an embodiment of a method for generating an interface test case according to the present application. Specifically, the method of the present embodiment includes the following steps:
step S41: and determining the test sequence of the interfaces to be tested and the corresponding interface elements of the interfaces to be tested.
The interface element is information required by the interface to be tested during testing. The interface element includes at least one of: the interface testing method comprises an interface name, an interface class name, an interface parameter, an interface execution mark and an expected return result preset for an interface to be tested, wherein the interface parameter is used for being provided for the interface to be tested, so that the interface to be tested can call and find a testing method corresponding to the interface to be tested based on the interface parameter. The interface execution flag is used to indicate whether to execute the test of the interface to be tested.
Step S42: and drawing the test sequence of the interfaces to be tested and the corresponding interface elements of the interfaces to be tested in the mind map to obtain the mind map of the test case.
In the thinking guide graph of the test case, the thinking guide graph comprises themes, each theme corresponds to one interface to be tested, and the connection relation among the themes is used for representing the test sequence of the interfaces to be tested corresponding to the themes; the information of the theme is used for representing the interface element of the interface to be tested corresponding to the theme. The theme includes the following information: the subject name is used for recording the interface name of the interface to be tested; the label is used for recording the interface class name of the interface to be tested; remarks for recording interface parameters and/or expected return results of the interface to be tested; and the icon is used as an interface execution mark.
By the mode, the interface elements are information required by the interface to be tested during testing, so that after the testing sequence and the interface elements of the interface to be tested are determined, the thinking diagram of the test case can be obtained only by drawing the testing sequence and the interface elements of the interface to be tested in the thinking diagram, the thinking diagram of the test case simultaneously comprises the testing sequence and the information required by the interface to be tested during testing, the testing sequence of the interface to be tested in the thinking diagram of the test case is clear, and the interface elements are convenient to display and apply.
To facilitate understanding of the present application, the following description is made with reference to a specific example:
referring to fig. 5, fig. 5 is a schematic diagram of a mind map of a test case of an embodiment of an interface automation test method according to the present application. FIG. 6 is a remark diagram of querying a blacklist in the mind map of the test case of FIG. 5.
In the embodiment of the present application, as shown in fig. 5, the mind map of the test case is an XMind test case drawn by using an XMind application. Taking the interface to be tested of "query blacklist" as an example, the interface to be tested of "query blacklist" corresponds to a subject, and the subject includes a subject name 51, a label 52, a remark 53, an icon 54, and an annotation 55. The subject name 51 is used for recording the interface name of the interface to be tested; the label 52 is used for recording the interface class name of the interface to be tested; the remark 53 is used for recording interface parameters and/or expecting to return results of the interface to be tested; icon 54 serves as an interface execution flag; the annotations 55 are used for recording test result information in the mind map of the test case. In this application embodiment, the interface names of the interfaces to be tested are "query blacklist", "delete blacklist", "pause for several seconds", "new blacklist", "timedelete (5)", "blacklist comparison v 1", or "blacklist comparison v 2" in sequence according to the test sequence. As shown in fig. 5, taking "query blacklist" as an example, the topic name 51 records an interface name of "query blacklist" as "query blacklist"; tag 52 records the interface class name of "query blacklist" as RISKFACECMP; icon 54 is used as an interface execution flag, so that if it is detected that the interface execution flag exists in the "query blacklist", the "query blacklist" is not tested, or the to-be-tested interface whose test sequence is behind the "query blacklist" is not tested; the endorsement 55 may record the test result information of the "query blacklist" in the mind map of the test case. With reference to fig. 5 and fig. 6, remark 53 in fig. 5 records an interface parameter of "query black list" and an expected return result, where in fig. 6, the "query black list" is taken as an example, and the interface parameter includes cacheId ═ get _ list; serviceId ═ None; the serviceKey is None, and the expected return result is exception. Taking the subject of the "blacklist comparison v 2" as an example, the interface execution flag is included, so when the interface to be tested is tested in sequence based on the test sequence and the interface elements to obtain the interface test result, if the interface execution flag exists in the blacklist comparison v2, the blacklist comparison v2 is not tested. It can be understood that the mind map of the test case in the embodiment of the present application may be obtained through the flow steps shown in fig. 2, or may also be obtained through the method for generating the interface test case shown in fig. 4.
After obtaining the thought guide graph of the test case, analyzing the thought guide graph of the test case to obtain the test sequence of the to-be-tested interface as ' inquiring blacklist ', ' deleting blacklist ', ' pausing for several seconds ', ' adding blacklist ', ' timesleep (5) ' blacklist comparison v1 ', and obtaining interface names, interface class names, interface parameters, interface execution marks, expected return results and other interface elements of each to-be-tested interface, and then testing the to-be-tested interface based on the test sequence and the interface elements to obtain the test results of the to-be-tested interfaces which pass or fail the test.
The specific test procedure is as follows: using the query blacklist as an interface to be tested, and instantiating an interface class name of the query blacklist as RISKFACECMP 1; in the class corresponding to the interface class name RISKFACECMP1 of the "query blacklist", the test method corresponding to the "query blacklist" is found, for example, the test method required by the actual program corresponding to the "query blacklist" is found by Swagger; calling a test method based on interface parameters (cacheId: get _ list, serviceId: None, serviceKey: None) of the 'inquiry blacklist' to obtain an actual return result of the interface to be tested; and comparing the actual return result of the query blacklist with an expected return result (expect) and obtaining a test result of the interface to be tested, which passes or fails the test, based on the comparison result. After the "query blacklist", similarly to the "query blacklist" in the test, the "delete blacklist", "pause for several seconds", "add blacklist", "timedelete (5)", and "blacklist comparison v 1" are sequentially used as the interfaces to be tested, and details are not repeated here.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
Referring to fig. 7, fig. 7 is a schematic diagram of a frame of an embodiment of an electronic device 70 according to the present application. The electronic device 70 includes a memory 71 and a processor 72 coupled to each other, and the processor 72 is configured to execute program instructions stored in the memory 71 to implement steps of any one of the above-described embodiments of the interface automated testing method, or to implement steps of any one of the above-described embodiments of the interface test case generation method. In one particular implementation scenario, the electronic device 70 may include, but is not limited to: a microcomputer, a server, and the electronic device 70 may also include a mobile device such as a notebook computer, a tablet computer, and the like, which is not limited herein.
Specifically, the processor 72 is configured to control itself and the memory 71 to implement the steps of any of the above-described embodiments of the interface automation test method, or to implement the steps of any of the above-described embodiments of the interface test case generation method. The processor 72 may also be referred to as a CPU (Central Processing Unit). The processor 72 may be an integrated circuit chip having signal processing capabilities. The Processor 72 may also be a general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. Additionally, the processor 72 may be collectively implemented by an integrated circuit chip.
Referring to fig. 8, fig. 8 is a block diagram illustrating an embodiment of a computer readable storage medium 80 according to the present application. The computer readable storage medium 80 stores program instructions 801 capable of being executed by the processor, and the program instructions 801 are used for implementing steps of any one of the above-mentioned interface automation test method embodiments or implementing steps of any one of the above-mentioned interface test case generation method embodiments.
In some embodiments, functions of or modules included in the apparatus provided in the embodiments of the present disclosure may be used to execute the method described in the above method embodiments, and specific implementation thereof may refer to the description of the above method embodiments, and for brevity, will not be described again here.
The foregoing description of the various embodiments is intended to highlight various differences between the embodiments, and the same or similar parts may be referred to each other, and for brevity, will not be described again herein.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a module or a unit is merely one type of logical division, and an actual implementation may have another division, for example, a unit or a component may be combined or integrated with another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some interfaces, and may be in an electrical, mechanical or other form.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.

Claims (13)

1. An automated interface testing method, the method comprising:
acquiring a mind map of a test case, wherein the mind map represents a test sequence of interfaces to be tested of the test case and corresponding interface elements of the interfaces to be tested, and the interface elements are information required by the interfaces to be tested during testing;
analyzing the thinking guide diagram of the test case to obtain the test sequence of the interface to be tested and the corresponding interface element;
and testing the interface to be tested based on the testing sequence and the interface elements to obtain a testing result of the interface to be tested.
2. The method of claim 1, wherein the interface element comprises at least one of: the interface testing system comprises an interface name, an interface class name, interface parameters, an interface execution mark and an expected return result preset for the interface to be tested, wherein the interface execution mark is used for indicating whether to execute the test of the interface to be tested.
3. The method according to claim 2, wherein the mind map comprises at least one subject, each subject corresponds to one interface to be tested, and the connection relationship between the subjects is used for representing the test sequence of the interfaces to be tested corresponding to the subjects; the information of the theme is used for representing the interface element of the interface to be tested corresponding to the theme.
4. The method of claim 3, wherein the topic comprises at least one of:
the subject name is used for recording the interface name of the interface to be tested;
the label is used for recording the interface class name of the interface to be tested;
the remark is used for recording the interface parameters of the interface to be tested and/or the expected return result;
an icon serving as the interface execution flag.
5. The method of claim 2, wherein the testing the interface to be tested based on the testing order and the interface elements to obtain the testing result of the interface to be tested comprises:
testing the to-be-tested interfaces according to the testing sequence by using the interface parameters to obtain an actual return result of the to-be-tested interfaces;
and obtaining the test result of the interface to be tested based on the actual return result.
6. The method of claim 5, wherein if the interface element includes the interface name, the interface class name, and the interface parameter, the testing the interface to be tested according to the testing sequence using the interface parameter to obtain the actual returned result of the interface to be tested, includes:
instantiating the interface class name of the interface to be tested;
in the class corresponding to the interface class name of the interface to be tested, finding a test method corresponding to the interface name of the interface to be tested;
calling the testing method based on the interface parameters to obtain an actual return result of the interface to be tested;
and/or, if the interface element further includes the interface execution flag, before the interface to be tested is tested according to the test sequence by using the interface parameter to obtain an actual return result of the interface to be tested, the method further includes:
if the interface execution mark does not exist in the current interface to be tested, testing the current interface to be tested by using the interface parameters to obtain an actual return result of the current interface to be tested;
if the interface execution mark exists in the current interface to be tested, the current interface to be tested is not tested, or the interface to be tested with the test sequence behind the current interface to be tested is not tested.
7. The method of claim 5, wherein the interface parameters include the expected return result, and wherein obtaining the interface test result based on the actual return result comprises:
comparing the actual return result and the expected return result of the interface to be tested, and obtaining a test result of whether the interface to be tested passes the test or not based on the comparison result; and/or after the test result of the interface to be tested is obtained based on the actual return result, the method further comprises the following steps:
recording the test result information in an annotation of the mind map, wherein the test result information includes at least one of: the actual return result, the return time of the actual return result and the interface test result.
8. The method of claim 1, wherein obtaining a mind map of test cases comprises:
receiving an interface reference file of an interface definition standard service;
analyzing the interface reference file to form a thinking guide graph of the test template;
and responding to a user instruction, and adjusting the test sequence and/or the interface elements in the mind map of the test template to obtain the mind map of the test case.
9. The method as claimed in claim 8, wherein in the mind map of the test template, sub-topics represent corresponding template use cases, and the parsing the interface reference file to form the mind map of the test template comprises:
taking the item name in the interface reference file as a parent theme of the thinking guide graph of the test template;
creating a sub-theme for each path field of the interface reference file, and connecting the corresponding sub-theme with the parent theme according to the sequence of the path fields; and
correspondingly recording the interface name, the interface class name and the interface parameter in the path field in a subject name, a label and a remark of the subtopic;
the adjusting the test sequence and/or the interface element in the mind map of the test template comprises at least one of the following steps:
deleting and/or adding the sub-topic;
adjusting the connection relation between the sub-topics;
modifying the interface parameters in the remarks.
10. A method for generating an interface test case is characterized in that the method comprises the following steps:
determining a test sequence of interfaces to be tested and corresponding interface elements of the interfaces to be tested; the interface element is information required by the interface to be tested during testing;
and drawing the test sequence of the interface to be tested and the corresponding interface element of the interface to be tested in a mind map to obtain the mind map of the test case.
11. The method of claim 10, wherein the interface element comprises at least one of: the interface testing system comprises an interface name, an interface class name, interface parameters, an interface execution mark and an expected return result preset for the interface to be tested, wherein the interface execution mark is used for indicating whether to execute the test of the interface to be tested;
the thinking guide graph comprises at least one theme, each theme corresponds to one interface to be tested, and the connection relation among the themes is used for representing the testing sequence of the interfaces to be tested corresponding to the themes; the information of the theme is used for representing interface elements of the interface to be tested corresponding to the theme;
wherein the theme includes at least one of the following information:
the subject name is used for recording the interface name of the interface to be tested;
the label is used for recording the interface class name of the interface to be tested;
the remark is used for recording the interface parameters of the interface to be tested and/or the expected return result;
an icon serving as the interface execution flag.
12. An electronic device, comprising a memory and a processor coupled to each other, wherein the processor is configured to execute program instructions stored in the memory to implement the interface automation test method according to any one of claims 1 to 9, or to implement the interface test case generation method according to any one of claims 10 to 11.
13. A computer-readable storage medium having stored thereon program instructions, which, when executed by a processor, implement the method for automated interface testing according to any one of claims 1 to 9, or implement the method for generating an interface test case according to any one of claims 10 to 11.
CN202011539604.5A 2020-12-23 2020-12-23 Interface automation test method and its use case generation method, equipment and storage medium Pending CN112559368A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011539604.5A CN112559368A (en) 2020-12-23 2020-12-23 Interface automation test method and its use case generation method, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011539604.5A CN112559368A (en) 2020-12-23 2020-12-23 Interface automation test method and its use case generation method, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112559368A true CN112559368A (en) 2021-03-26

Family

ID=75030982

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011539604.5A Pending CN112559368A (en) 2020-12-23 2020-12-23 Interface automation test method and its use case generation method, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112559368A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113377661A (en) * 2021-06-23 2021-09-10 深圳平安智汇企业信息管理有限公司 Interface testing method and device, electronic equipment and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106033389A (en) * 2015-03-11 2016-10-19 腾讯科技(深圳)有限公司 A test use case display method and device
US20170060734A1 (en) * 2015-08-30 2017-03-02 International Business Machines Corporation Method and system for creating functional model of test cases
CN106959919A (en) * 2016-01-08 2017-07-18 广州市动景计算机科技有限公司 Method for testing software and device based on test path figure
CN107577599A (en) * 2017-08-21 2018-01-12 同程网络科技股份有限公司 A kind of automatic interface testing method and platform based on custom script
CN107741911A (en) * 2017-11-01 2018-02-27 广州爱九游信息技术有限公司 Interface test method, device, client and computer-readable recording medium
CN109032923A (en) * 2018-06-21 2018-12-18 深圳壹账通智能科技有限公司 Method for testing software, device based on call chain, terminal
CN109828909A (en) * 2018-12-21 2019-05-31 北京城市网邻信息技术有限公司 Regression test case determines method, apparatus, electronic equipment and storage medium
CN109857667A (en) * 2019-02-03 2019-06-07 苏州市龙测智能科技有限公司 Automatic interface testing method, test device, test equipment and storage medium
CN110532175A (en) * 2019-07-29 2019-12-03 深圳中兴网信科技有限公司 Interface test method, interface test device, server and storage medium
CN111090575A (en) * 2018-10-23 2020-05-01 亿度慧达教育科技(北京)有限公司 Test method

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106033389A (en) * 2015-03-11 2016-10-19 腾讯科技(深圳)有限公司 A test use case display method and device
US20170060734A1 (en) * 2015-08-30 2017-03-02 International Business Machines Corporation Method and system for creating functional model of test cases
CN106959919A (en) * 2016-01-08 2017-07-18 广州市动景计算机科技有限公司 Method for testing software and device based on test path figure
CN107577599A (en) * 2017-08-21 2018-01-12 同程网络科技股份有限公司 A kind of automatic interface testing method and platform based on custom script
CN107741911A (en) * 2017-11-01 2018-02-27 广州爱九游信息技术有限公司 Interface test method, device, client and computer-readable recording medium
CN109032923A (en) * 2018-06-21 2018-12-18 深圳壹账通智能科技有限公司 Method for testing software, device based on call chain, terminal
CN111090575A (en) * 2018-10-23 2020-05-01 亿度慧达教育科技(北京)有限公司 Test method
CN109828909A (en) * 2018-12-21 2019-05-31 北京城市网邻信息技术有限公司 Regression test case determines method, apparatus, electronic equipment and storage medium
CN109857667A (en) * 2019-02-03 2019-06-07 苏州市龙测智能科技有限公司 Automatic interface testing method, test device, test equipment and storage medium
CN110532175A (en) * 2019-07-29 2019-12-03 深圳中兴网信科技有限公司 Interface test method, interface test device, server and storage medium

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
XMIND思维导图: "在哪些工作上可以用到思维导图?", Retrieved from the Internet <URL:《https://www.zhihu.com/question/19595433/answer/452607502》> *
方海光等: "《思维能力的教学理论与实践》", 北京:北京理工大学出版社, pages: 235 - 236 *
熊掌游天下: "Xmind软件中如何绘制时间轴导图", pages 235 - 236, Retrieved from the Internet <URL:《https://jingyan.baidu.com/article/a681b0ded8435e7a184346a0.html》> *
科技变革: "怎样使用思维导图画组织结构图,时间轴图", Retrieved from the Internet <URL:《https://jingyan.baidu.com/article/e5c39bf5e68f2a39d660337b.html》> *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113377661A (en) * 2021-06-23 2021-09-10 深圳平安智汇企业信息管理有限公司 Interface testing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110019486B (en) Data acquisition method, device, equipment and storage medium
WO2019227641A1 (en) Application testing method, apparatus, terminal device and medium
WO2019242164A1 (en) Document management method and apparatus, computer device and storage medium
CN111190825A (en) Automatic test method, system and robot
CN111475694A (en) Data processing method, device, terminal and storage medium
CN114116496A (en) Automatic testing method, device, equipment and medium
CN111782546A (en) Automatic interface testing method and device based on machine learning
CN112559368A (en) Interface automation test method and its use case generation method, equipment and storage medium
CN112395182A (en) Automatic testing method, device, equipment and computer readable storage medium
CN113836014A (en) Interface testing method and device, electronic equipment and storage medium
CN109634838A (en) Position method, apparatus, storage medium and the electronic equipment of application failure
CN109542743B (en) Log checking method and device, electronic equipment and computer readable storage medium
CN109144841B (en) Method and device for identifying advertisement application, computer equipment and storage medium
CN113377648B (en) Software system diagnosis method, device, electronic equipment and computer readable medium
CN115688706A (en) Information verification method, device, equipment and storage medium
CN115185797A (en) Method and system for testing visual algorithm model, electronic equipment and storage medium
CN114201484A (en) Information processing method, information processing device, electronic equipment and storage medium
CN114297152A (en) Data reporting method and terminal equipment
CN112860722A (en) Data checking method and device, electronic equipment and readable storage medium
CN111352824B (en) Test method and device and computer equipment
CN113238940A (en) Interface test result comparison method, device, equipment and storage medium
CN111274143A (en) Buried point testing method, device, equipment and storage medium
CN113448820B (en) Webpage testing method and device
CN113360364B (en) Target object testing method and device
US10691521B2 (en) Using telemetry to drive high impact accessibility issues

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