Method and apparatus for generating test cases
By generating and saving the description data of graph test cases, the problem of difficult reuse of graph test cases is solved, and the reusable and convenient modification of graph test cases is realized, and the efficiency of user writing and understanding is improved.
Patent Information
- Application Number
- CN202210230732.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-09
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2042-03-09
AI Technical Summary
Existing graphical test cases are difficult to reuse, and due to the lack of logical relationships and semantic meanings, test cases in the form of images have difficulties in understanding and writing.
By determining multiple graphic controls and their description data selected by the user, a graph test case is generated and the description data is saved for easy reuse, supporting the establishment of hierarchical relationships and logical relationships of the graph test case, allowing the graph test case to be converted into text form.
It realizes the reusable and convenient modification of graphical test cases, expands the application scope of graphical test cases, and improves the efficiency of user writing and understanding.
Smart Images

Figure CN114579458B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to software testing technology, and in particular to a method and device for generating test cases. Background Art
[0002] A test case refers to a description of the test tasks for a specific software product. The content of a test case includes test objectives, test environment, input data, test steps, expected results, test scripts, etc.
[0003] Currently, test cases are usually in text form. When users write test cases or view the completed test cases, due to the large amount of text content, it is difficult for users to quickly understand the structure and content of the test cases, which brings trouble to the users' writing and testing work.
[0004] At present, there are also test cases in the form of pictures. Although it is convenient for users to understand, since the data in the pictures does not have logical relationships and semantic meanings, it is difficult to reuse the graphical test cases. Summary of the Invention
[0005] The present invention provides a method and device for generating test cases, aiming to solve the problem that graphical test cases are difficult to be reused.
[0006] On the one hand, the present invention provides a method for generating test cases, including:
[0007] Determine a plurality of graphical controls selected by the user, and obtain the description data of each of the graphical controls, where the description data is used to describe the hierarchy of the graphical control in the test case to be generated;
[0008] Generate a graphical test case according to each of the graphical controls and the description data of the graphical control;
[0009] Save the description data of each of the graphical controls, where the saved description data of each of the graphical controls can be reused.
[0010] In an embodiment, the step of generating a graphical test case according to each of the graphical controls and the description data of the graphical control includes:
[0011] Determine the hierarchical relationship between each of the graphical controls according to the description data of each of the graphical controls;
[0012] Generate the logical relationship of each of the graphical controls according to the hierarchical relationship, and generate a graphical test case according to each of the graphical controls and the logical relationship.
[0013] In an embodiment, the step of saving the description data of each of the graphical controls includes:
[0014] Store each of the described data hierarchically according to the hierarchical relationship.
[0015] In one embodiment, the step of storing each of the described data includes:
[0016] Receive modification information for the graphic test case;
[0017] Modify the graphic test case according to the modification information, and update each of the described data according to the modification information;
[0018] Store each of the updated described data.
[0019] In one embodiment, after the step of generating a graphic test case according to each of the graphic controls and the description data of the graphic control, the method further includes:
[0020] Receive a conversion instruction;
[0021] Convert the graphic test case according to the conversion instruction to generate a test case in text form.
[0022] In one embodiment, the obtaining of the description data of each of the graphic controls includes:
[0023] When the description data of the graphic control is stored locally, obtain the description data of the graphic control from local, wherein the description data of the graphic control stored locally is the description data of the graphic control in the generated graphic test case;
[0024] When the description data of the graphic control is not stored locally, receive the description data of the graphic control input by the user.
[0025] On the other hand, the present invention also provides a test case generation device, including:
[0026] A determination module, configured to determine a plurality of graphic controls selected by a user, and obtain the description data of each of the graphic controls, where the description data is used to describe the hierarchy of the graphic control in the to-be-generated test case;
[0027] A generation module, configured to generate a graphic test case according to each of the graphic controls and the description data of the graphic control;
[0028] A storage module, configured to store each of the description data, where each of the stored description data can be reused.
[0029] On the other hand, the present invention also provides a test case generation device, including: a memory and a processor;
[0030] The memory stores computer-executable instructions;
[0031] The processor executes the computer-executable instructions stored in the memory, such that the processor executes the method for generating a test case as described above.
[0032] On the other hand, the present invention further provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method for generating a test case as described above.
[0033] On the other hand, the present invention further provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the method for generating a test case as described above.
[0034] The method and apparatus for generating a test case provided by the present invention determine each selected graphical control, obtain description data of the graphical control, generate a graphical test case based on each graphical control and the description data of the graphical control, and save each description data, such that each description data can be reused. In the present invention, the description data of the graphical control for generating the graphical test case is stored and can be reused, and the graphical test case can be regenerated based on the reused description data, such that the graphical test case can be repeatedly used. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.
[0036] Figure 1 It is a schematic diagram of the scenario of the method for generating a test case according to an embodiment of the present invention;
[0037] Figure 2 It is a schematic flowchart of the first embodiment of the method for generating a test case of the present invention;
[0038] Figure 3 It is a schematic flowchart of the refinement of step S20 in the second embodiment of the method for generating a test case of the present invention;
[0039] Figure 4 It is a schematic flowchart of the refinement of step S30 in the third embodiment of the method for generating a test case of the present invention;
[0040] Figure 5 It is a schematic diagram of the modules of the device for generating a test case of the present invention;
[0041] Figure 6 It is a schematic structural diagram of the apparatus for generating a test case of the present invention.
[0042] Through the above-mentioned drawings, specific embodiments of the present disclosure have been shown, and will be described in more detail hereinafter. These drawings and the written description are not intended to limit the scope of the concept of the present disclosure in any way, but to illustrate the concept of the present disclosure to those skilled in the art by referring to specific embodiments. Detailed Description of the Invention
[0043] Here, exemplary embodiments will be described in detail, and examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numerals in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0044] The present invention provides a method for generating test cases, which can be implemented through Figure 1 the application scenarios shown. As Figure 1 shown, a test case generation device 100 stores a plurality of graphic controls 110 with predefined functions. Each graphic control 110 can be carried by a certain application program loaded in the test case generation device 100, or can be directly downloaded and saved by the test case generation device 100 from the server.
[0045] The test case generation device 100 can be any terminal with data processing capabilities, such as a computer. When generating graphic test cases, the test case generation device 100 displays an interface containing a plurality of graphic controls 110, and the user selects the graphic controls 110 on the interface ( Figure 1 the graphic controls 110 within the dashed box in are the ones selected by the user). After selecting each graphic control 110, description data 120 of each graphic control 110 can be input into the test case generation device 100. The description data 120 is used to describe the hierarchy of the graphic control 110 in the test case to be generated. The test case generation device 100 can generate graphic test cases 130 based on each graphic control 110 and the description data 120, store each description data 120, and each description data 120 can be reused.
[0046] The following uses specific embodiments to describe in detail the technical solutions of the present invention and how the technical solutions of the present application solve the above technical problems. The following several specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below with reference to the drawings.
[0047] Refer to Figure 2 , Figure 2This is the first embodiment of the method for generating test cases of the present invention. The method for generating test cases includes the following steps:
[0048] Step S10, determine multiple graphical controls selected by the user, and obtain the description data of each graphical control. The description data is used to describe the hierarchy of the graphical control in the test case to be generated.
[0049] In this embodiment, the execution entity is a test case generation device. For the convenience of description, hereinafter, the device is used to refer to the test case generation device. The device stores multiple custom image controls, and each graphical control has a corresponding function. The device downloads an application program, and the application program carries multiple graphical controls. Alternatively, the device directly downloads each graphical control from the server. The user can add, delete, and modify each graphical control of the device.
[0050] The user can input the functions required for the test case in the device, and the device then obtains the graphical controls corresponding to the functions as the graphical controls selected by the user. Alternatively, the device displays each graphical control, and the user selects the graphical controls on the display interface.
[0051] After the device determines each graphical control, it obtains the description data of each graphical control. The description data is the hierarchy of the graphical control in the test case to be generated. The description data can be input by the user, that is, the user inputs the description data for each graphical control.
[0052] Step S20, generate a graphical test case according to each graphical control and the description data of the graphical control.
[0053] After the device obtains the description data of each graphical control, it can generate a graphical test case according to each graphical control and the description data of the graphical control. Specifically, the hierarchy of each graphical control in the test case to be generated can be determined based on each description data, and based on the hierarchy of each graphical control, each graphical control is generated into a graphical test case with a tree structure.
[0054] Step S30, save each description data, where each saved description data can be reused.
[0055] After generating the graphical test case, each description data will not be deleted, but each description data will be stored. The description data and the graphical control corresponding to the description data can be associated and stored. The stored description data can be transplanted, so that other users can generate graphical test cases using the transplanted description data, achieving the purpose of reusing the graphical test cases.
[0056] In the technical solution provided in this embodiment, each selected graphic control is determined, and the description data of the graphic control is obtained. Based on each graphic control and the description data of the graphic control, a graphic test case is generated, and each description data is saved so that each description data can be reused. In the present invention, the description data of the graphic control for generating the graphic test case is stored and can be reused, and the graphic test case can be regenerated based on the reused description data, so that the graphic test case can be repeatedly used.
[0057] Referring to Figure 3 , Figure 3 This is the second embodiment of the method for generating test cases of the present invention. Based on the first embodiment, step S20 includes:
[0058] Step S21, according to the description data of each graphic control, determine the hierarchical relationship between each graphic control.
[0059] In this embodiment, after the device obtains the description data of each graphic control, it can determine the level of the graphic control in the test case to be generated, and based on the levels of each graphic control, the hierarchical relationship between each graphic control can be determined. For example, graphic control A belongs to the third level, and graphic control B belongs to the fourth level, then graphic control B is a sub-control of graphic control B. It should be noted that if there are multiple graphic controls at a level, the graphic controls in the next level need to belong to the sub-controls of a certain graphic control at that level. For example, graphic controls A and C belong to the third level, and graphic control B belongs to the fourth level, then it is necessary to determine whether graphic control B is a sub-control of graphic control A or a sub-control of graphic control C. The specific determination method can be determined by the user on the device.
[0060] Step S22, generate the logical relationship of each graphic control according to the hierarchical relationship, and generate a graphic test case according to each graphic control and the logical relationship.
[0061] After determining the hierarchical relationship between each graphic control, the device generates the logical relationship between each graphic control based on the hierarchical relationship, and thus generates a graphic test case according to the logical relationship and each graphic control.
[0062] Furthermore, after the device determines the hierarchical relationship between each graphic control according to each description data, it stores each description data hierarchically according to the hierarchical relationship. When it is necessary to generate a graphic test case subsequently, the logical relationship between each graphic control can be directly determined according to the hierarchical relationship, and it is possible to more conveniently generate a graphic test case based on each description data stored hierarchically.
[0063] In the technical solution provided in this embodiment, the device determines the hierarchical relationship between each graphical control according to the description data of each graphical control, then generates the logical relationship of each graphical control according to the hierarchical relationship, and finally generates a graphical test case according to the logical relationship and each graphical control.
[0064] Referring Figure 4 , Figure 4 This is the third embodiment of the method for generating test cases of the present invention. Based on the first or second embodiment, step S30 further includes:
[0065] Step S31, receiving modification information for the graphical test case.
[0066] In this embodiment, the device also supports collaborative writing of the same test case by multiple users. After the device generates a graphical test case, it sends the image test case to the terminal corresponding to the collaborative writing user.
[0067] The user can modify the graphical test user, that is, send modification information for the graphical test case to the device through the terminal.
[0068] Step S32, modifying the graphical test case according to the modification information, and updating each description data according to the modification information;
[0069] Step S33, saving each updated description data.
[0070] After receiving the modification information, the device will modify the image test case according to the modification information. The modification information can be the addition, deletion, and modification of graphical controls in the graphical test case, or the modification of the hierarchy of graphical controls in the graphical test case.
[0071] After modifying the graphical test case, each description data will be updated according to the modification information, that is, adding, deleting, or modifying the description data of the graphical test case.
[0072] In the technical solution provided in this embodiment, the device receives modification information for the graphical test case, modifies the graphical test case according to the modification information, and updates and saves each description data based on the modification information.
[0073] In one embodiment, after generating the graphical test case, the graphical test case can be converted into a text-form test case. Specifically, after receiving the conversion instruction, the device converts the graphical test case according to the conversion instruction, thereby generating a text-form test case, and further expanding the usage range of the graphical test case. Specifically, the functions of the graphical controls in the graphical test case can be converted into execution codes, so as to generate a text-form test case.
[0074] In one embodiment, the description data can be reused. Therefore, after the device determines the graphical control selected by the user, it determines whether the description data of the graphical control is stored locally. If the description data of the graphical control is stored locally, the description data of the graphical control is obtained from the local. The description data of the graphical control stored locally is the description data of the graphical control in the generated graphical test case. If the description data of the graphical control is not stored locally, the description data of the graphical control input by the user is received.
[0075] In this embodiment, the device reuses the description data of the graphical control in the generated graphical test case stored locally, and can generate the graphical test case more conveniently.
[0076] Based on the above embodiments, a brief description of the test case generation device provided by the present invention is given.
[0077] The test case generation device stores predefined graphical controls. The user can select multiple graphical controls, input description data for the selected graphical controls, and set the functions and levels of each graphical control in the test case to form a test case represented graphically. The description data of each graphical control of the test case is stored in a hierarchical data format. The stored data can be transplanted and supports collaborative writing of the same test case by multiple users. The graphical test case can be parsed to generate a test case in text form.
[0078] The test case generation device mainly includes the following modules:
[0079] Graphical control management module, user input module, display module, data storage module, conversion module, collaboration module.
[0080] The graphical control management module is used to manage graphical controls, add, delete, and modify graphical controls;
[0081] The graphical control selection module is used to select corresponding graphical controls according to the user's instructions;
[0082] The user input module is used to receive the description data of the graphical control input by the user;
[0083] The logic generation module is used to generate the logical relationship between graphical controls according to the hierarchical relationship set by the user;
[0084] The display module is used to display the generated graphical test case;
[0085] The data storage module is used to store the description data of the graphical control input by the user and store the description data of the graphical control according to the hierarchical relationship set by the user;
[0086] The conversion module is used to convert graphical test cases into textual test cases;
[0087] The collaboration module is used to receive modifications to the graphical test case by the online user and send the modified graphical test case to the display module.
[0088] The present invention also provides a test case generation device, referring to Figure 5 , the test case generation device 500 includes:
[0089] The determination module 501 is used to determine multiple graphic controls selected by the user and obtain description data of each graphic control, where the description data is used to describe the hierarchy of the graphic control in the test case to be generated;
[0090] A generating module 502 is used to generate a graphic test case based on each graphic control and its description data;
[0091] The storage module 503 is used to store various description data, wherein the stored description data can be reused.
[0092] In one embodiment, the test case generation device 500 includes:
[0093] Determining module 501, for determining the hierarchical relationship between the graphic controls according to the description data of the graphic controls;
[0094] The generating module 502 is used to generate the logical relationship of each graphic control according to the hierarchical relationship, and generate a graphic test case according to each graphic control and the logical relationship.
[0095] In one embodiment, the test case generation device 500 includes:
[0096] The storage module 503 is used to store the description data in a hierarchical manner according to a hierarchical relationship.
[0097] In one embodiment, the test case generation device 500 includes:
[0098] A receiving module, used for receiving modification information for a graphic test case;
[0099] The modification module is used to modify the graphic test case according to the modification information and update each description data according to the modification information;
[0100] The storage module 503 is used to store the updated description data.
[0101] In one embodiment, the test case generation device 500 includes:
[0102] A receiving module, configured to receive a conversion instruction;
[0103] A conversion module, configured to convert a graphical test case according to a conversion instruction to generate a test case in text form.
[0104] In one embodiment, the test case generation device 500 includes:
[0105] An acquisition module, configured to obtain the description data of a graphical control from local when the description data of the graphical control is stored locally, where the description data of the graphical control stored locally is the description data of the graphical control in the generated graphical test case;
[0106] A receiving module, configured to receive the description data of the graphical control input by a user when the description data of the graphical control is not stored locally.
[0107] Figure 6 It is a hardware structure diagram of a test case generation device shown according to an exemplary embodiment.
[0108] The test case generation device 600 may include: a processor 61, such as a CPU, a memory 62, and a transceiver 63. Those skilled in the art can understand that Figure 6 the structure shown in does not constitute a limitation on the test case generation device, and may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements. The memory 62 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disc.
[0109] The processor 61 can call the computer program stored in the memory 62 to complete all or part of the steps of the above-mentioned test case generation method.
[0110] The transceiver 63 is configured to receive information sent by an external device and send information to the external device.
[0111] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by the processor of the test case generation device, enables the test case generation device to execute the above-mentioned test case generation method.
[0112] A computer program product, including a computer program, when the computer program is executed by the processor of the test case generation device, enables the test case generation device to execute the above-mentioned test case generation method.
[0113] Other embodiments of the present disclosure will be readily apparent to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. The present invention is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include known common general knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and examples are only to be considered as exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.
[0114] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.
Claims
1. A method for generating test cases, characterized in that, Including: Determine a plurality of graphical controls selected by a user, and obtain description data of each of the graphical controls, where the description data is used to describe the hierarchy of the graphical control in a test case to be generated; Generate a graphical test case according to each of the graphical controls and the description data of the graphical control; Save the description data of each of them, where the saved description data of each of them can be reused to generate a new graphical test case; The step of saving the description data of each of them includes: Store the description data of each of them hierarchically according to the hierarchical relationship between the graphical controls.
2. The method for generating test cases according to claim 1, wherein The step of generating a graphical test case according to each of the graphical controls and the description data of the graphical control includes: Determine the hierarchical relationship according to the description data of each of the graphical controls; Generate a logical relationship of each of the graphical controls according to the hierarchical relationship, and generate a graphical test case according to each of the graphical controls and the logical relationship.
3. The method for generating test cases according to claim 1, characterized in that The step of saving the description data of each of them further includes: Receive modification information for the graphical test case; Modify the graphical test case according to the modification information, and update the description data of each of them according to the modification information; Save the updated description data of each of them.
4. The method for generating a test case according to claim 1, wherein After the step of generating a graphical test case according to each of the graphical controls and the description data of the graphical control, it further includes: Receive a conversion instruction; Convert the graphical test case according to the conversion instruction to generate a test case in text form.
5. The method for generating a test case according to any one of claims 1-4, characterized in that The obtaining the description data of each of the graphical controls includes: When the description data of the graphical control is stored locally, obtain the description data of the graphical control from local, where the description data of the graphical control stored locally is the description data of the graphical control in the generated graphical test case; When the description data of the graphical control is not stored locally, receive the description data of the graphical control input by the user.
6. A test case generation device, characterized in that Including: A determination module, configured to determine a plurality of graphical controls selected by a user, and obtain description data of each of the graphical controls, where the description data is used to describe the hierarchy of the graphical control in a test case to be generated; A generation module, configured to generate a graphical test case according to each of the graphical controls and the description data of the graphical control; A storage module, configured to save the description data of each of them, where the saved description data of each of them can be reused to generate a new graphical test case; The storage module is specifically configured to store the description data of each of them hierarchically according to the hierarchical relationship between the graphical controls.
7. A test case generation device, characterized in that Including: A memory and a processor; The memory stores computer execution instructions; The processor executes the computer execution instructions stored in the memory, so that the processor executes the test case generation method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, Computer execution instructions are stored in the computer-readable storage medium, and when the computer execution instructions are executed by a processor, they are used to implement the test case generation method according to any one of claims 1 to 5.
9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method for generating a test case according to any one of claims 1 to 5.
Citation Information
Patent Citations
Information storage method and information storage device
CN102571381A
Program testing method and device, computer system and storage medium
CN113656326A