Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, 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 some embodiments of the present application, but not all 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 terminology used in the embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the examples of this application and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, and "a" and "an" typically include at least two, but do not exclude the presence of at least one.
It should be understood that the term "and/or" as used herein is merely one type of association that describes 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.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
It is also noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a good or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such good or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a commodity or system that includes the element.
In addition, the sequence of steps in each method embodiment described below is only an example and is not strictly limited.
In order to facilitate those skilled in the art to understand the technical solutions provided in the present application, a technical environment for implementing the technical solutions is described below.
A method for generating a test case, which is commonly used in the related art, mainly includes that a tester uses a curl, fiddler, postman, and other compiling tools to compile a test case, which is generally completed by a tester familiar with the grammar of the compiling tools.
Based on the actual technical requirements similar to those described above, the test case generation method provided by the application can realize the visualization of the test case by using a technical means, and the intelligence is improved.
The test case generation method described in the embodiments of the present application is specifically described below by two exemplary service scenarios.
Scene one
In one scenario, as shown in fig. 1A, theserver 11 stores therein the interface function to be tested, and theserver 11 may include any form of data storage server such as a cloud server, a distributed server, and the like. A user uses the terminal 12 to compile a test case for an interface function to be tested stored in theserver 11, and the terminal 12 may include a notebook computer, a tablet computer, a desktop computer, a smart phone, and the like.
As shown in fig. 1A, the terminal 12 may obtain, from theserver 11, implementation codes of an interface function to be tested of a target object, where the target object may be understood as an object that needs to perform an interface function test, such as a product, Software, and the like, and for example, the implementation codes of the interface function to be tested in the form of a Software Development Kit (SDK) of the target object may be obtained from theserver 11. After obtaining the implementation code of the interface function to be tested of the target object, the terminal 12 may analyze the implementation code of the interface function to be tested of the target object, obtain an interface list of the interface function to be tested of the target object, and establish a corresponding relationship between the target object and the interface list, which may be understood as a synchronization process of an object between the terminal 12 and theserver 11. Then, the user may input a flowchart operation according to the interface list, where the flowchart operation is used to set a plurality of process nodes, a flow direction order of the plurality of process nodes, interface functions respectively corresponding to the plurality of process nodes, and entry parameters of the interface functions, and the terminal 12 may obtain a visual test case according to the flowchart operation input by the user.
It should be noted that in the visual test case, one process node may correspond to one interface function, the interface functions corresponding to the two process nodes may be the same or different, and one process node may correspond to one visual graph, such as a rectangle, a square, a diamond, a triangle, and the like. The flow direction sequence of the plurality of flow nodes may represent a call sequence of the interface functions corresponding to the plurality of flow nodes, for example, the flow direction sequence is three flow nodes of flow node 1 → flow node 2 → flow node 3, the interface function corresponding to flow node 1 is called first, after the interface function corresponding to flow node 1 is called, the interface function corresponding to flow node 2 is called next, and after the interface function corresponding to flow node 2 is called, the interface function corresponding to flow node 3 is called next. Therefore, the visual test case can be obtained based on the plurality of process nodes, the flow direction sequence of the plurality of process nodes, the interface functions respectively corresponding to the plurality of process nodes, and the entry parameters of the interface functions.
Optionally, to facilitate a user to write a visual test case, the terminal 12 may further obtain function related information of the interface function in the interface list by analyzing an implementation code of the interface function to be tested of the target object in the process of synchronizing the objects, where the function related information includes one or more of the following: the parameter name of the entry parameter, the parameter name of the exit parameter, or the function implementation.
It is understood that, alternatively, theserver 11 may parse the implementation code of the interface function to be tested of the target object, obtain the interface list and send the interface list to the terminal 12. Further, theserver 11 may analyze the implementation code of the interface function to be tested of the target object to obtain the function related information of the interface function in the interface list, and send the function related information to the terminal 12.
It can be understood that the interface list and the function-related information are for the convenience of the user to write a visual test case, and may also be omitted in certain cases, for example, the user already knows the interface parameters to be tested and the function-related information thereof in advance.
After the visualized test case is obtained, the user may use the terminal 12 to run the visualized test case, and the terminal 12 may obtain a case running operation input by the user and run the visualized test case according to the case running operation. As shown in fig. 1A, the terminal 12 may sequentially send, according to the flow direction sequence of the plurality of flow nodes of the visualized test case, an execution request of the flow node to the corresponding interface function to theserver 11 according to the entry parameter of the interface function corresponding to the flow node, and receive an execution result obtained by the server executing the interface function according to the execution request, until the test case is ended, to complete the running of the test case. It should be noted that, in fig. 1A, the terminal for running the test case and the terminal for generating the test case are taken as the same terminal, and it is understood that the terminal for running the test case and the terminal for generating the test case may be different terminals.
For example, if the visualized test case includes a flow node a, a flow node b, and a flow node c, and 3 flow nodes are provided, the flow sequence of the 3 flow nodes is flow node a → flow node b → flow node c, and the entry parameter of the interface function corresponding to flow node a is (a), the entry parameter of the interface function corresponding to flow node b is (b, the exit parameter of the interface function corresponding to flow node a), and the entry parameter of the interface function corresponding to flow node c is (the interface function corresponding to flow node b), after the user inputs the operation, the terminal 12 may run the visualized test case, first request the server 11 to execute the interface function corresponding to flow node a according to the entry parameter (a), the server 11 executes the interface function corresponding to flow node a according to the request of the terminal 12 to obtain and return the execution result 1 to the terminal 12, and then the terminal 12 may execute the visualized test case according to the entry parameter (b, the execution result 1) requests the server to execute the interface function corresponding to the flow node b, the server 11 obtains the execution result 2 according to the request execution of the terminal 12 and returns the execution result to the terminal 12, then the terminal 12 may request the server to execute the interface function corresponding to the flow node c according to the entry parameter (the execution result 2), the server obtains the execution result 3 according to the request execution of the terminal 12 and returns the execution result to the terminal 12, further, the terminal 12 may determine whether the execution result 13 is the same as the expected result, if so, it indicates that the use case operation is successful, and if not, it indicates that the use case operation is failed. It should be noted that, for convenience of description, a single flow direction is taken as an example among the plurality of flow nodes, and the sequence of the flow direction after the plurality of flow nodes is not limited to the single flow direction.
Optionally, in order to enable a user to intuitively determine whether the visualized test case is successfully or unsuccessfully operated, the last-stage process node of the visualized test case may correspondingly implement a preset function of the comparison function, so as to avoid whether the execution result of the last-stage process node is the same as the expected result, and the last stage may be executed by the terminal. For example, on the basis of the flow nodes a, b, and c, a flow node d may be further included, where the flow direction order is flow node a → flow node b → flow node c → flow node d, and the flow node d may correspond to a preset function implementing a comparison function to compare whether the execution result of the flow node c is the same as the expected result.
Scene two
In another scenario, as shown in fig. 1B, theintermediate device 13 may obtain an implementation code of an interface function to be tested of the target object from theserver 11, and after obtaining the implementation code of the interface function to be tested of the target object, theintermediate device 13 may parse the implementation code of the interface function to be tested of the target object, obtain an interface list of the interface function to be tested of the target object, and establish a corresponding relationship between the target object and the interface list, which may be understood as a synchronization process of an object between theintermediate device 13 and theserver 11. Then, the terminal 12 may obtain an interface list from theintermediate device 13, further, the user may input a flowchart operation according to the interface list, where the flowchart operation is used to indicate a plurality of process nodes of the device, a flow direction order of the plurality of process nodes, interface functions respectively corresponding to the plurality of process nodes, and entry parameters of the interface functions, and the terminal 12 may obtain a visual test case according to the flowchart operation input by the user.
Similarly, in order to facilitate the user to write a visual test case, theintermediate device 13 may further obtain function related information of the interface function in the interface list by analyzing the implementation code of the interface function to be tested of the target object in the process of synchronizing the objects.
Compared with fig. 1A, in this scenario, theintermediate device 13 completes the analysis of the implementation code of the interface function, which can reduce the calculation amount of the terminal 12 and reduce the performance requirement for the terminal 12. As shown in fig. 1B, the interface list of the target object can be obtained from themiddleware 13 for each of theterminals 12 used by the plurality of users, thereby avoiding resource waste caused by obtaining the interface list analysis code for each of the plurality ofterminals 12.
Alternatively, after obtaining the function-related information, theintermediate device 13 may directly send the function-related information of each interface function in the interface list to the terminal 12. Or, the user may input a keyword of an interface function to be queried through the terminal 12, the terminal 12 sends the keyword to theintermediate device 13, and theintermediate device 13 may determine, after receiving the keyword, an interface function matched with the keyword, and return function-related information of the matched interface function to the terminal 12, so that the terminal 12 can provide a query function of the interface function to the user by means of theintermediate device 13.
After obtaining the visualized test case, the user may use the terminal 12 to run the visualized test case. As shown in fig. 1B, after the user inputs a case operation, the terminal 12 may send, according to the flow direction sequence of the plurality of flow nodes of the visualized test case and according to the entry parameter of the interface function corresponding to the flow node, an execution request of the interface function corresponding to each flow node to theserver 11 sequentially through theintermediate device 13, and receive, through theintermediate device 13, an execution result obtained by the server executing the interface function according to the execution request until the test case is finished, so as to complete the operation of the test case.
It should be noted that, in fig. 1B, the terminal for running the test case and the terminal for generating the test case are taken as the same terminal as an example, and it can be understood that the terminal for running the test case and the terminal for generating the test case may also be different terminals. In fig. 1B, taking the example that the terminal 12 sends the execution request to theserver 11, and theserver 11 returns the execution result to the terminal 12 and forwards the execution result through theintermediate device 13, it can be understood that the terminal 12 may also directly interact with theserver 11 in the process of running the test case.
In fig. 1A and 1B, communication with different devices is performed by a wireless communication method, but it should be understood that communication with different devices may also be performed by a wired communication method, and the present application is not limited thereto.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
Fig. 2 is a flowchart illustrating a method for generating a test case according to an embodiment of the present application, where an execution main body of the embodiment may be the terminal in fig. 1A and 1B, and specifically, may be executed by a processor of the terminal. As shown in fig. 2, the method of this embodiment may include:
step 201, obtaining a flow chart operation input by a user, where the flow chart operation is used to set a plurality of flow nodes, a flow direction sequence of the plurality of flow nodes, interface functions respectively corresponding to the plurality of flow nodes, and entry parameters of the interface functions.
Step 202, operating according to the flow chart to obtain a visual test case.
It should be noted that the visualized test case obtained in step 202 can be updated in real time according to the flowchart operation of step 201. For example, after the user inputs the flowchart operation 1, a visual test case 1 is obtained, and after the further user inputs the flowchart operation 2, the visual test case 1 may be updated according to the flowchart operation 2, so that a visual test case 2 is obtained.
The flow chart operation is a general term of operations for setting flow nodes, setting flow direction sequences of the flow nodes, setting interface functions corresponding to the flow nodes and setting parameter values. The method and the system for setting the flow nodes, the flow direction sequence of the plurality of flow nodes, the interface functions respectively corresponding to the plurality of flow nodes, and the sequence of the interface functions are not limited in the present application.
For example, a plurality of process nodes may be set first, and then after the flow direction sequence of the plurality of process nodes is set, an interface function corresponding to each process node in the plurality of process nodes and an entry parameter of the interface function may be further set.
For example, the interface function and the function parameter of the interface function corresponding to each process node in the plurality of process nodes may be set first, and then the flow direction sequence of the plurality of nodes may be set.
For example, the entry parameters of the interface function may be set after the plurality of process nodes, the process sequence of the plurality of process nodes, and the interface functions corresponding to the plurality of process nodes are set.
For example, when a flow node is set, the flow direction order of the flow node in the existing flow chart may be specified. For example, on the basis of the visualized test case shown in fig. 3A, if the user inputs a flowchart operation indicating that the flow node 3 is newly added before the flow node 2, for example, a click operation of the user on "insert node ahead" in fig. 3A, the visualized test case after being updated may be as shown in fig. 3B. For another example, on the basis of the visualized test case shown in fig. 3A, if the user inputs a flowchart operation for indicating that a flow node is added after the flow node 2, for example, a click operation of "insert node behind" in fig. 3A, the updated visualized test case may be as shown in fig. 3C.
For example, after a process node is set, an interface function corresponding to the process node and entry parameters of the interface function may be set. For example, on the basis of fig. 3B, an interface function corresponding to the flow node 3 and an entry parameter of the interface function are further set.
Or, an interface function corresponding to a flow node and an entry parameter of the interface function may be set in the process of setting the flow node. For example, on the basis of the visualized test case shown in fig. 3A, if the user inputs and clicks "insert node in front" in fig. 3A, a dialog box may be popped up, and after the user further sets an interface function corresponding to the new process node and a parameter value of the interface function in the popped dialog box and clicks a confirmation button in the dialog box, the updated visualized test case shown in fig. 3B may be displayed.
It should be noted that, the flow nodes are identified by rectangular boxes in the visualized test cases shown in fig. 3A to 3C, which are only examples, and arrows in fig. 3A to 3C are used to identify a flow direction sequence. For a specific manner of displaying the menu shown in fig. 3A by the trigger terminal, the application may not be limited, and for example, the application may be a right click operation of the flow node 2 in the visual test case.
Further, in order to facilitate the user to view the visual test case, the interface function and/or the entry parameter corresponding to each flow node may be directly displayed in the visual test case, or, in order to avoid the visual test case from being too complicated to be presented to the user, the interface function and/or the entry parameter corresponding to the flow node may be displayed in the visual test case after the user selects one flow node, and the interface function and/or the entry parameter corresponding to the flow node may be cancelled from being displayed after the user cancels the selection of the flow node.
Optionally, in the process of setting a plurality of process nodes, the set process nodes may also be deleted. For example, on the basis of the flowchart shown in fig. 3A, if the user inputs a flowchart operation for indicating that the flow node 2 in the flowchart is deleted, for example, a click operation of the user on "delete this node" in fig. 3A, the visualized test case shown in fig. 3D can be obtained.
It should be noted that, the specific manners of setting the flow nodes, setting the flow direction sequence of the flow nodes, setting the interface functions corresponding to the flow nodes, and setting the parameter values of the entry parameters are only examples.
In the embodiment, by obtaining the flow chart operation input by the user, the flow chart operation is used for setting a plurality of flow nodes, the flow direction sequence of the flow nodes, the interface functions respectively corresponding to the flow nodes and the entry parameters of the interface functions, and a visual test case is obtained according to the flow chart operation.
In addition, the test case generation method provided by the embodiment of the application has universality and can be used for generating test cases of different objects, wherein the objects can be understood as objects needing interface function testing, such as products, software and the like, and the interface function corresponding to the process node can be an interface function of a target object, so that the writing of the test case of the target object is realized.
Optionally, on the basis of the above method embodiment, in order to facilitate a user to set an interface function corresponding to the flow node, as shown in fig. 4,step 401 and step 402 may also be included.
Step 401, obtaining an object selection operation input by the user, where the object selection operation is used to select a test case for writing a target object.
In this step, for example, an object selection entry may be displayed, and an object selection operation input by the user may be acquired through the object selection entry.
Optionally, the object selection operation input by the user may be obtained before step 201, and after the object selection operation is obtained, it may be determined that the user needs to write a test case of the target object. It is to be understood that the object selection operation may also be acquired after acquiring the flowchart operation for setting the plurality of process nodes input by the user and before acquiring the interface function for setting the corresponding process node.
Step 402, according to the object selection operation, displaying an interface list of interface functions to be tested of the target object, where the interface list is used for the user to select the interface function corresponding to the process node in the interface list.
In this step, the interface list may be a list of function names. For example, the terminal may obtain the interface list from the server, for example, the server may send the interface list to the terminal; or, beforestep 401, the terminal may obtain the implementation code of the interface function to be tested of the target object from the server, and analyze the implementation code of the interface function to be tested of the target object to obtain the interface list; or, the terminal may obtain the interface list by using the intermediate device, and the intermediate device may obtain the interface list by analyzing the implementation code. The interface list is obtained by analyzing the implementation code of the interface function, and the effectiveness of the interface list can be improved.
Further, in order to facilitate the user to manage the object, an object list interface may be provided for the user, and the object list interface is used to provide the user with functions of viewing the object, adding the object, deleting the object, triggering an interface function for acquiring the object, and the like.
It should be noted that, as to the specific way of presenting the interface list to the user, the application may not be limited. For example, the interface list may be prompted in a form of a drop-down list in a dialog box in which the user sets the interface function corresponding to the flow node, so that the user can conveniently select the interface function corresponding to the flow node.
In the embodiment, the interface list of the interface functions to be tested of the target object is displayed according to the object selection operation input by the user, so that the user selects the interface functions corresponding to the process nodes from the interface list, the efficiency of writing the visual test case by the user is improved, the interface functions set for the process nodes by the user are all the interface functions of the target object, and the error probability of the visual test case is reduced.
Optionally, on the basis of the above method embodiment, in order to facilitate the user to set the entry parameter of the interface function, as shown in fig. 5,step 501 and step 502 may also be included.
Step 501, obtaining a node selection operation input by the user, where the node selection operation is used to select a target process node, and the target process node is one of the plurality of process nodes.
In this step, the specific form of the node selection operation may not be limited in this application. For example, the left click operation of the flow node in the visualized test case may be performed, for example, if the user clicks "flow node 1" in the visualized test case shown in fig. 3B, the node selection operation 1 input by the user is obtained, and is used to select the flow node 1 as the target flow node.
And 502, displaying function related information of the interface function corresponding to the target process node according to the node selection operation, wherein the function related information is used for setting an entry parameter of the interface function by the user.
In this step, the function-related information may specifically be any type of information that facilitates the user to set the entry parameter, and optionally, the function-related information may include one or more of the following: an entry parameter, an exit parameter, or a function implemented function. For example, the entry parameter in the function-related information may be used for the user to set an entry parameter of the interface function corresponding to the target process node. For example, the exit parameter in the function-related information may be used for the user to set an entry parameter of the interface function corresponding to the next-stage process node of the target process node. For example, the function implemented function in the function-related information may facilitate a relationship between the input parameter and the output parameter of the target process node of the user.
It should be noted that, the specific way of displaying the function-related information may not be limited in this application. Illustratively, the function-related information may be displayed in a pop-up interface.
Optionally, similar to the interface list, in this embodiment of the application, the terminal may obtain function-related information of the interface function in the interface list from the server, or obtain function-related information of the interface function in the interface list from the intermediate device, or obtain function-related information of the interface function in the interface list by analyzing the implementation code of the interface function to be tested of the target object.
In the embodiment, the function related information of the interface function corresponding to the target process node is displayed through the node selection operation input by the user, so that the user can set the entry parameter of the interface function according to the displayed function related information, the user can conveniently set the parameter value, and the efficiency of writing the visual test case by the user is improved.
The above terminal can understand the process of obtaining the interface list and the function-related information of the interface function in the interface list as the synchronization process of the object. For example, as shown in fig. 6, the intermediate device may synchronize an SDK package of an interface function to be tested of a target object from a server, and the intermediate device may perform interface automated analysis on an implementation code of each interface function in the SDK package to obtain interface information, where the interface information includes an interface list and function-related information of the interface function in the interface list, and further, the terminal may obtain the interface information from the intermediate device, thereby completing a synchronization process.
Optionally, before the obtaining the interface list, the method further includes:
according to the object management operation input by the user, the object management operation is used for indicating the management of the object;
displaying an object management interface according to the object management operation, wherein the object management interface comprises a newly-built object entrance;
acquiring a new object operation input by the user through the new object entrance, wherein the new object operation is used for indicating to newly create the target object;
and determining that the interface list and function related information of the interface functions in the interface list need to be obtained according to the operation of the newly-built object.
Further optionally, in order to facilitate the user to manage the object, the object management interface further includes an object list of the established object, and an operation entry of each object in the object list. Taking an object as a product as an example, the object management interface may be as shown in fig. 7, where "new product" is a new object entry, and "product name" is a product identifier in the product list. The "update", "delete", "configure" and "synchronize" are the operation entries of the product. Wherein, the 'update' is used for the user to input an object update operation so as to update the interface function of the object from the server; "delete" is used for the user to input an object delete operation to delete an object; "configure" is used for a user to enter a configuration operation to configure an attribute of an object, such as the name of the configuration object; "synchronization" is used for user input synchronization operations to trigger the acquisition of interface information.
In order to facilitate the user to view the product, as shown in fig. 7, a search entry for an object may be further provided, and in particular, the search may be performed by a product name.
In order to facilitate the user to know the related information of the object, as shown in fig. 7, the object management interface may further include a synchronization status of each object in the object list and a domain name of the corresponding server.
Further optionally, in order to facilitate the user to manage the interface function, optionally, on the basis of the above method embodiment, the method may further include the following steps:
acquiring interface management operation input by the user, wherein the interface management operation is used for indicating to manage the interface function which is successfully synchronized;
and displaying an interface management interface according to the interface management operation, wherein the interface management interface comprises a successfully synchronized interface list and operation entries of each interface function in the interface list.
Taking an object as an example, the interface management interface may be as shown in fig. 8, where "interface name" is an interface identifier in the interface list, and "view" and "debug" are operation entries of the interface function. Wherein "view" is used for a user to input a view operation to view function-related information of the interface function; the 'debugging' is used for inputting single-interface debugging operation by a user so as to display a single-interface debugging interface of an interface function.
In order to facilitate the user to view the interface, as shown in fig. 8, a search entry for the interface may be provided, and in particular, the interface may be searched by "product name" or "interface name".
On the basis of completing the synchronization process, further, as shown in fig. 6, the user may input a flowchart operation through the terminal to generate a visualized test case. Optionally, as shown in fig. 6, further on the basis of generating the visualized test case, the visualized test case may be operated through interaction with the server.
Illustratively, on the basis of the above method embodiment, the method may further include the following steps:
acquiring use case management operation input by the user, wherein the use case management operation is used for indicating management of the obtained use case;
and displaying a use case management interface according to the use case management operation, wherein the use case management interface comprises a use case list and operation entries of each use case in the use case list.
The use case management interface may be, for example, as shown in fig. 9, where the "number" and the "use case name" are use case identifiers in the use case list, and the "update", "run", "view record", and "delete" are operation entries of the use case. The 'update' is used for inputting case update operation by a user so as to update the test case; the 'operation' is used for inputting case operation by a user so as to operate a test case; the 'viewing record' is used for a user to input a use case viewing operation so as to view the running record of the use case, such as a running result; "delete" is used for the user to enter a case delete operation to delete the test case.
In order to facilitate the user to view the use case, as shown in fig. 9, a search entry for the use case may be further provided, and specifically, the use case may be searched by "use case name".
In order to facilitate the user to know the relevant information of the use case, the use case management interface may further include creation time, a creator, and the like of each use case in the use case list.
On the basis of the use case management interface shown in fig. 9, when the user selects the "run" operation entry corresponding to the visualized test case generated in the above embodiment, the visualized test case may be run. Illustratively, the interface functions corresponding to the flow nodes may be sequentially called according to the flow direction sequence according to the entry parameters of the interface functions in the visual test case.
Optionally, on the basis of the above method embodiment, the method may further include the following steps: acquiring a template storage operation input by the user, wherein the template storage operation is used for indicating to store a flow template corresponding to the visual test case; and after receiving the template storage operation, obtaining a flow template according to the visual test case, and storing the flow template, wherein the flow template comprises the flow direction sequence of the plurality of flow nodes and interface functions respectively corresponding to the plurality of flow nodes. And the flow template comprises the flow direction sequence of the flow nodes and the interface functions corresponding to the flow nodes respectively, so that the flow template can further compile visual test cases on the basis of the flow template. Optionally, the terminal may send the flow template to other users, so that the other users compile visual test cases according to the flow template; and/or the terminal can add the process template into the template list, so that the user can select the process template through the template list.
Optionally, the obtaining a flow template according to the visualized test case may specifically include: and taking the visualized test case as a flow template. Optionally, after the user sets the flow nodes and the interface functions corresponding to the flow nodes through the flow chart operation, a prompt message may be output to the user for prompting that the current visual test case can be saved as the template. For example, when it is determined that the visualized test case includes the flow sequence of the plurality of flow nodes and the interface functions corresponding to the plurality of flow nodes, but does not include the entry parameters of the interface functions, the prompt information may be output.
And/or, obtaining a flow template according to the visualized test case, which may specifically include: and setting the entry parameters of the interface function in the visual test case to be invalid, and then obtaining a flow template. For the specific way of setting the entry parameter to be invalid, the present application may not be limited, for example, the entry parameter may be set to NULL. The entry parameters of the interface function in the visual test case are set to be invalid, and then the flow template is obtained, so that the entry parameters of the interface function in the flow template can be avoided, a user can be allowed to input the flow diagram operation without the need of firstly arranging the flow and then inputting the flow diagram operation in the case generation process, and the flexibility is improved.
Further optionally, the method of this embodiment may further include: when the user is determined to need to generate a test case based on the flow template, displaying the flow template; and obtaining a new visual test case according to the entry parameters of the interface function in the flow template set by the user. For a specific manner of setting the entry parameter of the interface function in the flow template according to the user, the application may not be limited, and for example, the entry parameter of the interface function in the flow template may be set by inputting a parameter value setting operation in the visualized flow template by the user. The method has the advantages that the process template selected by the user is determined, the process template is visualized, and the entry parameters of the interface function in the process template are set according to the input of the user, so that the user can obtain a new visualized test case different from the existing visualized test case parameter values by modifying the parameter values, the writing of the visualized test case is simplified, and the efficiency of writing the visualized test case by the user is improved.
Optionally, on the basis of the above method embodiment, the method may further include the following steps:
acquiring the process management operation input by the user, wherein the process management operation is used for indicating to manage the saved process template;
and displaying a process management interface according to the process management operation, wherein the process management interface comprises a process template list and operation entries of all process templates in the process template list.
The process management interface may be, for example, as shown in fig. 10, where the "process number" is a template identifier in the process template list, and the "edit", "run", "view record", "add case", and "delete" are operation entries of the process template. Wherein, the 'editing' is used for the user to input the flow editing operation so as to edit the flow template; the 'operation' is used for inputting the operation of the process operation by the user so as to set the parameters of the process template and operate; the 'viewing record' is used for a user to input a flow viewing operation so as to view an operation result after the parameters of the flow template are set and operated; the new case is used for inputting a new case operation by a user to generate a test case based on the flow template; "delete" is used for the user to enter a flow delete operation to delete the flow template.
In order to facilitate the user to obtain the relevant information of the flow template, as shown in fig. 10, the flow management interface may further include a flow name and a flow number of each flow template in the flow template list. In addition, as shown in fig. 10, a search entry for the flow template may be provided, and specifically, the use case may be searched through the "flow name" or the "flow number".
On the basis of the process management interface shown in fig. 10, when the user selects the "new use case" operation entry of the process template corresponding to the visualized test case generated in the foregoing embodiment, it may be determined that the user needs to generate the test case based on the process template.
In order to improve the intuitiveness of the visualized test case, optionally, on the basis of the above method embodiment, the method may further include the following steps: determining an initial process node in the plurality of process nodes, and identifying the initial process node; and/or determining an end process node in the plurality of process nodes, and identifying the end process node. The starting process node is a node without a previous process node, and the ending process node is a node without a next process node.
The specific manner of determining the starting process node and the ending process node may not be limited in this application. For example, the terminal may automatically determine the starting process node according to whether the previous process node exists, and determine the ending process node according to whether the next process node exists.
After identifying the starting flow node and the ending flow node based on fig. 3C, the visualized test case may be as shown in fig. 11. Wherein, the "start" is used to identify the starting process node, that is, the process node 1 pointed by the "start" is the starting process node; "end" is used to identify an end flow node, i.e., the flow node 3 pointing to "end" is an end flow node. Of course, the starting flow node and ending flow node may be identified in other ways besides FIG. 11 in other embodiments.
Fig. 12 is a flowchart illustrating a testing method according to an embodiment of the present application, where an execution main body of the embodiment may be the terminal 12 in fig. 1A and fig. 1B, or may be another terminal besides the terminal 12. As shown in fig. 12, the method of this embodiment may include:
step 121, obtaining a use case running operation input by a user, wherein the use case running operation is used for indicating to run a visualized test use case; the visualized test case is obtained according to a flow chart operation input by a user, and the flow chart operation is used for setting a plurality of flow nodes, flow direction sequences of the flow nodes, interface functions respectively corresponding to the flow nodes and entry parameters of the interface functions.
In this step, the visualized test case may be a locally generated test case, or a test case obtained from another terminal, or a test case obtained from a server, and so on. Specific contents of the visualized test case may refer to related descriptions in the foregoing embodiments, and are not described herein again.
The case running operation may be, for example, a click operation of a "running" entry corresponding to the visualized test case, and of course, the case running operation may also include other forms of operations, which is not limited in this application.
And step 122, running the visualized test case according to the case running operation.
In this step, since the flow direction sequence of the plurality of flow nodes in the visual test case may represent the call sequence of the interface functions corresponding to the plurality of flow nodes, the interface functions corresponding to the flow nodes may be sequentially called according to the flow direction sequence of the plurality of flow nodes. Illustratively, step 122 may specifically include: and sequentially calling the interface functions corresponding to the flow nodes according to the flow direction sequence of the flow nodes.
For example, the sequentially calling the interface functions corresponding to the flow nodes according to the flow direction sequence of the flow nodes may include:
a, calling an interface function corresponding to a current flow node to obtain an execution result of the interface function corresponding to the current flow node;
and B, taking the execution result of the interface function corresponding to the current process node as the entry parameter of the interface function corresponding to the next-stage process node, taking the next-stage process node as a new current process node, returning to the step A for execution until the last-stage process node is called.
For example, for the above-mentioned flow node a, flow node b and flow node c, first, the flow node a is taken as the current flow node, a is taken as the entry parameter of the interface function corresponding to the flow node a, the interface function corresponding to the flow node a is called, then the execution result of the interface function corresponding to the flow node a and b are taken together as the entry parameter of the interface function corresponding to the flow node b, the flow node b is taken as the current flow node, the interface function corresponding to the flow node b is called, finally the execution result of the interface function corresponding to the flow node b and c are taken together as the entry parameter of the interface function corresponding to the flow node c, the flow node c is taken as the current flow node, and the interface function corresponding to the flow node c is called.
In order to reduce the calculation amount of the terminal, the server may execute an interface function, and based on this, the interface function corresponding to the current flow node is called to obtain an execution result of the current flow node, which may specifically include: sending an execution request to a server, wherein the execution request is used for requesting the server to execute an interface function corresponding to the current process node; and receiving an execution result obtained by the server executing the current interface function according to the execution request.
For example, for the above-mentioned flow node a, flow node b and flow node c, first, the flow node a is taken as the current flow node, a is taken as the entry parameter of the interface function corresponding to the flow node a, an execution request for the interface function corresponding to the flow node a is sent to the server, and the execution result returned by the server is received, then the execution result of the interface function corresponding to the flow node a and b are taken together as the entry parameter of the interface function corresponding to the flow node b, the flow node b is taken as the current flow node, an execution request for the interface function corresponding to the flow node b is sent to the server, and the execution result returned by the server is received, finally, the execution result of the interface function corresponding to the flow node b and c are taken together as the entry parameter of the interface function corresponding to the flow node c, and the flow node c is taken as the current flow node, and sending an execution request aiming at the interface function corresponding to the flow node c to the server, and receiving an execution result returned by the server.
In this embodiment, a test method based on a visual test case is implemented by obtaining a case operation input by a user, where the case operation is used to instruct the operation of the visual test case, and operating the visual test case according to the case operation, so that the user can complete a test based on the visual test case.
Fig. 13 is a schematic structural diagram of a test case generation apparatus according to an embodiment of the present application; referring to fig. 13, the apparatus may execute the test case generation method described above, and specifically, the test case generation apparatus may include:
an obtainingmodule 131, configured to obtain a flowchart operation input by a user, where the flowchart operation is used to set a plurality of process nodes, a flow direction sequence of the plurality of process nodes, interface functions respectively corresponding to the plurality of process nodes, and entry parameters of the interface functions;
and thevisualization module 132 is configured to obtain a visualized test case according to the flowchart operation.
Optionally, the obtainingmodule 131 is further configured to obtain an object selection operation input by the user, where the object selection operation is used to select to write a test case of a target object;
thevisualization module 132 is further configured to display an interface list of interface functions to be tested of the target object according to the object selection operation, where the interface list is used for the user to select an interface function corresponding to the process node in the interface list.
Optionally, the obtainingmodule 131 is further configured to obtain a node selection operation input by the user, where the node selection operation is used to select a target process node, and the target process node is one of the plurality of process nodes;
thevisualization module 132 is further configured to display function related information of the interface function corresponding to the target process node according to the node selection operation, where the function related information is used for the user to set an entry parameter of the interface function.
Optionally, the function-related information includes one or more of the following: the parameter name of the entry parameter, the parameter name of the exit parameter, or the function implementation.
Optionally, the apparatus further comprises: the first obtaining module is used for obtaining the implementation code of the interface function to be tested of the target object from a server; and the analysis module is used for analyzing the implementation code of the interface function to be tested of the target object to obtain the interface list and the function related information of the interface function in the interface list.
Optionally, the apparatus further comprises: a second obtaining module, configured to obtain, from a server, the interface list and function-related information of the interface functions in the interface list.
Optionally, the apparatus further comprises: a third obtaining module, configured to obtain, from an intermediate device, the interface list and function-related information of the interface functions in the interface list, where the intermediate device is configured to obtain, from a server, an implementation code of an interface function to be tested of the target object, and analyze the implementation code to obtain the interface list and the function-related information of the interface functions in the interface list.
Optionally, the apparatus further comprises an object management module;
the obtainingmodule 131 is further configured to obtain an object management operation input by the user, where the object management operation is used to instruct to manage an object;
the object management module is used for displaying an object management interface according to the object management operation, wherein the object management interface comprises a newly-built object entrance;
the obtainingmodule 131 is further configured to obtain a new object operation input by the user through the new object entry, where the new object operation is used to indicate to create the new target object;
and the object management module is further configured to determine, according to the new object operation, that the interface list and function-related information of the interface functions in the interface list need to be obtained.
Optionally, the object management interface further includes an object list of the established objects, and an operation entry of each object in the object list.
Optionally, the apparatus further includes an interface management module;
the obtainingmodule 131 is further configured to obtain an interface management operation input by the user, where the interface management operation is used to instruct to manage an interface function that is successfully synchronized;
and the interface management module is used for displaying an interface management interface according to the interface management operation, wherein the interface management interface comprises a successfully synchronized interface list and an operation entry of each interface function in the interface list.
Optionally, the obtainingmodule 131 is further configured to obtain a template saving operation input by the user, where the template saving operation is used to instruct to save a flow template corresponding to the visualized test case;
the device further comprises: and the template module is used for obtaining a flow template according to the visual test case after receiving the template storage operation, and storing the flow template, wherein the flow template comprises the flow direction sequence of the plurality of flow nodes and the interface functions corresponding to the plurality of flow nodes respectively.
Optionally, the template module is specifically configured to use the visualized test case as a flow template.
Optionally, the template module is specifically configured to obtain a flow template after setting the entry parameter in the visual test case to be invalid.
Optionally, thevisualization module 132 is further configured to determine that the user selects the process template, and display the process template;
thevisualization module 132 is further configured to obtain a new visualized test case according to the entry parameter of the interface function in the flow template set by the user.
Optionally, the apparatus further comprises: a process management module;
the obtainingmodule 131 is further configured to obtain a process management operation input by the user, where the process management operation is used to instruct to manage the saved process template;
and the process management operation is used for displaying a process management interface according to the process management operation, wherein the process management interface comprises a process template list and operation entries of all the process templates in the process template list.
Optionally, thevisualization module 132 is further configured to determine a starting process node in the plurality of process nodes, and identify the starting process node.
Optionally, thevisualization module 132 is further configured to determine a flow end node in the plurality of flow nodes, and identify the flow end node.
Optionally, the apparatus further comprises: a use case management module;
the obtainingmodule 131 is further configured to obtain a use case management operation input by the user, where the use case management operation is used to instruct to manage an obtained use case;
the use case management module is used for displaying a use case management interface according to the use case management operation, wherein the use case management interface comprises a use case list and operation entries of each use case in the use case list.
Optionally, the operation inlet comprises one or more of the following: run entry, update entry, delete entry, or view record entry.
Optionally, the apparatus further comprises: an operation module;
the obtainingmodule 131 is specifically configured to obtain a use case running operation input by the user, where the use case running operation is used to instruct to run the visualized test case;
the running module is specifically configured to run the visualized test case according to the case running operation.
Optionally, the operation module is specifically configured to: and sequentially calling the interface functions corresponding to the process nodes according to the interface functions corresponding to the process nodes and the inlet parameters of the interface functions and the flow direction sequence of the plurality of process nodes.
Optionally, the running module is configured to call an interface function corresponding to the current flow node, and specifically includes:
sending a first execution request to a server, wherein the first execution request is used for requesting the server to execute an interface function corresponding to the current flow node;
and receiving an execution result obtained by the server executing the interface function according to the first execution request.
The execution module, after receiving an execution result obtained by the server executing the interface function according to the execution request, is further configured to: taking the execution result as an entry parameter of an interface function corresponding to a next-stage process node of the current node; sending a second execution request to a server, wherein the second execution request is used for requesting the server to execute an interface function corresponding to the next-stage process node; and receiving an execution result obtained by the server executing the interface function according to the second execution request.
The apparatus shown in fig. 13 may execute the method of the above test case generation method embodiment, and reference may be made to the related description of the test case generation method embodiment in a part not described in detail in this embodiment. The execution process and the technical effect of the technical scheme are described in the above embodiment of the test case generation method, and are not described herein again.
In one possible implementation, the structure of the test case generation apparatus shown in fig. 13 may be implemented as a terminal. As shown in fig. 14, the terminal may include: aprocessor 141 and amemory 142. Thememory 142 is configured to store a program that supports the terminal to execute the test case generation method provided in the foregoing method embodiment, and theprocessor 141 is configured to execute the program stored in thememory 142.
The program includes one or more computer operations, wherein the one or more computer operations, when executed byprocessor 141, enable the following steps:
acquiring a flow chart operation input by a user, wherein the flow chart operation is used for setting a plurality of flow nodes, the flow direction sequence of the flow nodes, interface functions respectively corresponding to the flow nodes and inlet parameters of the interface functions;
and operating according to the flow chart to obtain a visual test case.
Optionally, theprocessor 141 is further configured to perform all or part of the steps in the foregoing method embodiments.
The terminal may further include acommunication interface 143, which is used for the terminal to communicate with other devices or a communication network.
FIG. 15 is a schematic structural diagram of a testing apparatus according to an embodiment of the present application; referring to fig. 15, the apparatus may perform the above-mentioned testing method, and specifically, the testing apparatus may include:
an obtainingmodule 151, configured to obtain a use case running operation input by a user, where the use case running operation is used to instruct running of a visualized test use case; the visualized test case is obtained according to a flow chart operation input by a user, wherein the flow chart operation is used for setting a plurality of flow nodes, the flow direction sequence of the flow nodes, interface functions respectively corresponding to the flow nodes and entry parameters of the interface functions;
and the runningmodule 152 is configured to run the visualized test case according to the case running operation.
Optionally, the runningmodule 152 is specifically configured to sequentially call the interface functions corresponding to the flow nodes according to the flow direction sequence of the flow nodes.
Optionally, theoperation module 152 is specifically configured to:
a, calling an interface function corresponding to a current flow node to obtain an execution result of the interface function corresponding to the current flow node;
and B, taking the execution result of the interface function corresponding to the current process node as the entry parameter of the interface function corresponding to the next-stage process node, taking the next-stage process node as a new current process node, returning to the step A for execution until the last-stage process node is called.
Optionally, the runningmodule 152 is configured to call an interface function corresponding to the current flow node to obtain an execution result of the current flow node, and specifically includes:
sending an execution request to a server, wherein the execution request is used for requesting the server to execute an interface function corresponding to the current process node;
and receiving an execution result obtained by the server executing the interface function corresponding to the current flow node according to the execution request.
The apparatus shown in fig. 15 may perform the method of the above-mentioned test method embodiment, and reference may be made to the related description of the above-mentioned test method embodiment for a part not described in detail in this embodiment. The implementation process and technical effect of the technical solution refer to the description in the above test method embodiment, and are not described herein again.
In one possible implementation, the structure of the test device shown in FIG. 15 may be implemented as a terminal. As shown in fig. 16, the terminal may include: aprocessor 161 and amemory 162. Wherein, thememory 162 is used for storing programs for supporting the terminal to execute the testing method provided in the above method embodiments, and theprocessor 161 is configured to execute the programs stored in thememory 142.
The program comprises one or more computer operations, wherein the one or more computer operations, when executed by theprocessor 161, enable the following steps:
acquiring use case running operation input by a user, wherein the use case running operation is used for indicating to run a visual test case; the visualized test case is obtained according to a flow chart operation input by a user, wherein the flow chart operation is used for setting a plurality of flow nodes, the flow direction sequence of the flow nodes, interface functions respectively corresponding to the flow nodes and entry parameters of the interface functions;
and running the visualized test case according to the case running operation.
Optionally, theprocessor 161 is further configured to perform all or part of the steps in the foregoing method embodiments.
The terminal may further include acommunication interface 163, which is used for the terminal to communicate with other devices or a communication network.
In addition, the present application provides a computer storage medium for storing computer software operations used by a terminal, which includes a program for executing the test case generation method in the foregoing method embodiments.
The embodiment of the application provides a computer storage medium for storing computer software operations used by a terminal, which contains a program for executing the test method in the method embodiment.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course, can also be implemented by a combination of hardware and software. With this understanding in mind, the above-described technical solutions and/or portions thereof that contribute to the prior art may be embodied in the form of a computer program product, which may be embodied on one or more computer-usable storage media having computer-usable program code embodied therein (including but not limited to disk storage, CD-ROM, optical storage, etc.).
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.