Test case generation method and device, equipment and storage medium

By analyzing the requirement documents and generating a graph, the problem of insufficient test cases in software testing is solved, and more comprehensive test case coverage is achieved.

CN119883937APending Publication Date: 2025-04-25HANGZHOU NEWGRAND TECHNOLOGY CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510353707.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In software testing, the prior art is difficult to ensure the completeness of test cases, resulting in the possibility of missing important test cases.

Method used

By analyzing the requirements document, generating a graph and determining the node type, adding node description, information structure, association functions, superior nodes and initial use cases, and finally rendering the graph to generate target test cases.

Benefits of technology

Improve the completeness of test cases in software testing and ensure that test cases cover multiple test directions of the software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883937A_ABST
    Figure CN119883937A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of software testing, in particular to a test case generation method and device, equipment and a storage medium, and the method comprises the following steps: analyzing a demand document to obtain a directory and a node name, and obtaining a first map based on the directory, the node name and a preset map template; determining the node type of each atlas node in the first atlas based on the node name of the bottommost layer node in the first atlas, and obtaining a second atlas based on the node type and the first atlas; adding node description, an information structure, an association function, a superior node and an initial use case corresponding to the map node to the second map based on the menu node in the second map to obtain a target map; and rendering the target map to obtain a target test case. According to the method and the device, the completeness of the test case required by software testing is conveniently improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing technology, and in particular to a test case generation method, device, equipment and storage medium. Background Art

[0002] Before the software is released, it is necessary to test the software with test cases. In software development, a test case is a set of components provided to the system being tested for the purpose of implementing the test, including the test environment, operating procedures, test data, expected results and other elements, which are used to verify whether the software meets the requirements and design requirements. Therefore, before testing the software, the corresponding test cases need to be generated.

[0003] At present, in software testing, there are generally corresponding test case writers. The writers will refer to the requirement documents written by the product manager, and then manually write the corresponding test cases based on their own writing experience.

[0004] However, due to the limitations of the writing experience of the writers, the test cases written by the writers may be incomplete; for example, assuming that it is necessary to write test cases for a system login function, experienced writers may not only write test cases about the security strength of the login password, but also write test cases about the complexity of the login password, but writers with less writing experience may only write test cases about the security strength of the login password, or test cases about the complexity of the login password. Summary of the invention

[0005] In order to improve the completeness of test cases required for software testing, the present application provides a test case generation method, apparatus, device and storage medium.

[0006] In a first aspect, the present application provides a test case generation method, comprising:

[0007] Parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template;

[0008] Determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain a second graph based on the node type and the first graph;

[0009] Based on the menu nodes in the second graph, the node description, information structure, associated functions, parent nodes and initial use cases corresponding to the graph nodes are added to the second graph to obtain a target graph;

[0010] Render the target graph to obtain a target test case.

[0011] In a second aspect, the present application provides a test case generation device, comprising:

[0012] A first graph generation module, used for parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template;

[0013] A second graph generation module, used to determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain a second graph based on the node type and the first graph;

[0014] A target graph generation module, used for adding node descriptions, information structures, associated functions, parent nodes and initial use cases corresponding to the graph nodes to the second graph based on menu nodes in the second graph, to obtain a target graph;

[0015] The graph rendering module is used to render the target graph to obtain the target test case.

[0016] In a third aspect, the present application provides a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method when executing the computer program.

[0017] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above method when executed by a processor.

[0018] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0019] The above-mentioned test case generation method, device, equipment and storage medium obtain the directory and node name by parsing the requirement document, and obtain the first graph based on the directory, the node name and the preset graph template; determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain the second graph based on the node type and the first graph; add the node description, information structure, associated function, parent node and initial use case corresponding to the graph node to the second graph based on the menu node in the second graph to obtain the target graph; render the target graph to obtain the target test case. Through the above implementation, when the requirement document is obtained, the directory, node description, node name, information structure, related functions, parent node and initial use case contained in the requirement document can be extracted, and then the above directory, node description, node name, information structure, related functions, parent node and initial use case are filled into the preset graph template to obtain the target graph. The above information covered in the target graph can be used as the information required for the target test case to be generated. Since the target graph covers the directories, node descriptions, node names, information structures, related functions, parent nodes and initial use cases related to multiple graph nodes, the target test cases generated based on the target graph can fully reflect the test cases required for different test directions in software testing, thereby effectively improving the completeness of the test cases required for software testing.

[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 A flow chart of a test case generation method provided in an embodiment of the present application;

[0023] Figure 2 A schematic diagram of the structure of a test case generation device provided in an embodiment of the present application;

[0024] Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present application;

[0025] Figure 4This is a diagram of the internal structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of this article and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this article described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0028] In this article, the term "and / or" is only a description of the association relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the related objects before and after are in an "or" relationship.

[0029] Embodiment 1

[0030] Figure 1 A flow chart of a test case generation method provided in Example 1 of the present application, refer to Figure 1 The method may be performed by a device for performing the method, and the device may be implemented by software and / or hardware. The method includes:

[0031] S110, parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template.

[0032] Among them, in software development, the software product manager will write the corresponding document according to the actual requirements of the software functions. This document is also the requirement document. The requirement document (Software Requirements Specification, SRS) is a formal document that describes the system functions, performance, constraints and other requirements in detail; the requirement document is divided into multiple levels of titles, and each title has the title content corresponding to the title, the sub-title and the title content corresponding to the sub-title. The title content is the description corresponding to the meaning of the title under the corresponding title; if the title is the last level title, only the title content is set under the title; by parsing the requirement document, the titles of each level in the requirement document can be obtained, and the titles of each level can be combined into a directory according to the level of the title. Each level of the title in the directory has a corresponding title name, and the title name is recorded as the node name.

[0033] Exemplarily, a directory includes: business system test cases (first-level title); 1. Case query subsystem test cases (second-level title), 1.1 Case name query module (third-level title), 1.2 Case number query module (third-level title), ..., 2. Case batch processing subsystem test cases (second-level title), ...; wherein, the node name of the first-level title is "Business System Test Cases", the node name of one second-level title is "Case Query Subsystem Test Cases", and the node name of another second-level title is "Case Batch Processing Subsystem Test Cases", the node name of one third-level title is "Case Name Query Module", and the node name of another third-level title is "Case Number Query Module".

[0034] It should be noted that this method subsequently prepares to use a method of rendering the graph to obtain test cases for the entire software, wherein the graph covers various information required to generate test cases for the entire software; in order to generate the graph, a graph template is preset, and the graph template is initially not filled with any information. The required graph can be obtained by filling the graph template with various information required to generate test cases for the entire software; wherein, the directory and node names obtained by parsing the requirement document are two of the information, and the graph obtained after filling the directory and node names into the corresponding positions in the graph template is recorded as the first graph.

[0035] S120. Determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain a second graph based on the node type and the first graph.

[0036] Among them, the titles of each level in the directory filled in the first atlas are still filled in according to the order of the title levels. The first-level title is recorded as the top-level node in the first atlas, and the last-level title is recorded as the bottom-level node in the atlas. The corresponding title name of the bottom-level node is also the node name of the bottom-level node; and the titles in the directory in the first atlas are recorded as atlas nodes, and each atlas node has its corresponding node type.

[0037] It should be noted that the software tested in this embodiment may correspond to a specific software system, such as the business system in the above content. The system may have multiple subsystems, each subsystem may have one or more modules, and each module may have one or more menus, that is, the software system includes multiple system levels: system-subsystem-module-menu; different graph nodes in the graph correspond to different system levels; exemplarily, if the graph node is a top-level node, the system level corresponding to the top-level node is "system"; if the graph node is a second-level node, the system level corresponding to the second-level node is "subsystem"; if the graph node is a third-level node, the system level corresponding to the third-level node is "module"; if the graph node is the bottom-level node, the system level corresponding to the bottom-level node is "menu". The above is only an example and does not limit the number of system levels of the software system and the number of graph nodes.

[0038] Still taking the above example, the node types include: system, subsystem, module and menu. If the system level corresponding to a certain graph node is "system", then the node type of the graph node is "system"; if the system level corresponding to a certain graph node is "subsystem", then the node type of the graph node is "subsystem"; if the system level corresponding to a certain graph node is "module", then the node type of the graph node is "module"; if the system level corresponding to a certain graph node is "menu", then the node type of the graph node is "menu".

[0039] It should be noted that, after determining the node name of the bottom-level node, the node type of the bottom-level node can be determined by processing the node name, and after determining the node type of the bottom-level node, the node type of the parent node of the bottom-level node can be further reversely determined; illustratively, if the node type of the bottom-level node is determined to be "menu", the node type of the parent node of the bottom-level node can be further determined to be "module", and so on, when determining the node type of the bottom-level node, the node type corresponding to each graph node in the first graph can be determined in sequence according to the system level corresponding to the software system. After determining the node type corresponding to each graph node in the first graph, a new graph can be obtained by filling the node type corresponding to each graph node into the corresponding position in the first graph, and the new graph is recorded as the second graph.

[0040] S130. Based on the menu nodes in the second graph, the node description, information structure, associated functions, parent nodes and initial use cases corresponding to the graph nodes are added to the second graph to obtain the target graph.

[0041] Among them, each graph node in the second graph has a one-to-one correspondence with a node type. If the graph node type is a menu, the graph node is recorded as a menu node; each graph node in the second graph corresponds to a certain level of title in the requirement document, and the graph nodes have corresponding title content in the requirement document, and the title content corresponding to the graph node is recorded as a node description; through the menu nodes in the second graph, not only the node description corresponding to each graph node can be determined, but also the information structure, related functions, parent nodes and initial use cases corresponding to each graph node can be determined, wherein the information structure is used to characterize the table features corresponding to the graph node in the requirement document, The table features include at least the table field name, table field type and table field description; the association function is used to characterize the functional flow relationship between each graph node, the parent node is the parent node of the graph node, if the graph node is a top-level node, the parent node of the graph node is empty; the initial use case is the use case obtained by processing the above node description and the association function, but the use case is not the test case of the target, and the above node description, information structure, association function, parent node and initial use case need to be added to the second graph to obtain the target graph, and the target graph needs to be processed to obtain the test case of the target.

[0042] S140, rendering the target graph to obtain a target test case.

[0043] Among them, this embodiment can use a preset graph rendering tool to render the target graph, so as to obtain a target test case; illustratively, the preset graph rendering tool includes but is not limited to ECharts.

[0044] It should be noted that this embodiment obtains a directory and node names by parsing the requirement document, and obtains a first graph based on the directory, the node names and a preset graph template; determines the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtains a second graph based on the node type and the first graph; adds the node description, information structure, associated function, parent node and initial use case corresponding to the graph node to the second graph based on the menu node in the second graph, to obtain a target graph; renders the target graph to obtain a target test case. Through the above implementation, when the requirement document is obtained, the directory, node description, node name, information structure, related functions, parent node and initial use case contained in the requirement document can be extracted, and then the above directory, node description, node name, information structure, related functions, parent node and initial use case are filled into the preset graph template to obtain the target graph. The above information covered in the target graph can be used as the information required for the target test case to be generated. Since the target graph covers the directories, node descriptions, node names, information structures, related functions, parent nodes and initial use cases related to multiple graph nodes, the target test cases generated based on the target graph can fully reflect the test cases required for different test directions in software testing, thereby effectively improving the completeness of the test cases required for software testing.

[0045] Embodiment 2

[0046] A test case generation method provided in the second embodiment of the present application is a supplement to the method described in the first embodiment; it should be noted that for the parts not described in detail in this embodiment, reference can be made to the descriptions of other embodiments, and the method includes:

[0047] S210, parsing the reference document to obtain parsed content.

[0048] Among them, in this embodiment, in order to generate a target test case, a plurality of software testing-related documents are generally received, and the plurality of software testing-related documents are recorded as reference documents, and the reference documents include not only requirement documents, but also technical documents related to the software; it should be noted that only the requirement documents can play a decisive role in the final generation of the target test case. For this purpose, it is necessary to first determine the requirement documents from the reference documents. For this purpose, it is first necessary to parse each document in the reference documents to determine whether each document has the characteristics of the requirement document; and the result obtained by parsing the document is recorded as the parsed content, and the parsed content includes but is not limited to one or more of text, pictures and tables.

[0049] S220: In response to the information structure and the function structure existing in the parsed content, obtain multiple-shape graphics and / or content images in the parsed content.

[0050] Among them, taking a document in the reference document as an example, after parsing the document, the corresponding parsed content is obtained, and it is determined whether the parsed content contains a table. If so, it is further determined whether the table field of the table includes a table field name, a table field type, and a table field description, wherein the table field type includes a text type and a string type, etc., and the table field description is a description of the table field; in response to the parsed content containing a table, and the table field of the table includes a table field name, a table field type, and a table field description, it is determined that the parsed content corresponding to the document contains an information structure.

[0051] Taking a document in the reference document as an example, after parsing the document, the corresponding parsed content is obtained, and it is determined whether the parsed content contains a directory. If so, it is further determined whether the title of the directory contains preset functional keywords. In this embodiment, the functional keywords include one or more of addition, deletion, modification, query and statistics. In response to the title of the directory containing preset functional keywords, it is further determined whether the title content containing the functional keywords contains execution logic and execution results corresponding to the functional keywords. If so, it is determined that the parsed content corresponding to the document contains a functional structure.

[0052] It should be noted that if a document is judged to have an information structure and a functional structure, it means that the document is most likely to be a requirement document; the target test case to be ultimately generated in this embodiment is a system-oriented test case at the system level. For this reason, when it is judged that a document has an information structure and a functional structure, it is also necessary to determine whether the document contains a test flowchart for the corresponding system in order to finally determine whether the document is a requirement document. For this reason, it is necessary to obtain multi-shape graphics and / or content images in the corresponding parsed content of the document, so as to determine whether the document contains a test flowchart for the corresponding system through the multi-shape graphics and / or content images.

[0053] Wherein, obtaining the multi-shape graphics and / or content pictures in the parsed content includes:

[0054] Determine the directory depth of the reference document, determine whether the directory depth is greater than a preset first depth threshold, and / or determine whether the directory of the reference document contains preset keywords; wherein the directory depth is the number of levels of titles contained in the directory, exemplarily, if a directory contains a first-level title, a second-level title, and a third-level title, then the number of levels of titles contained in the directory is 3, that is, the directory depth is 3, wherein the directory depth corresponding to the first-level title is 1, the directory depth corresponding to the second-level title is 2, and the directory depth corresponding to the third-level title is 3; the preset first depth threshold in this embodiment is 3, and in other embodiments, it is not specifically limited; in addition, the preset keywords in this embodiment are limited to one or more of the system, subsystem, and module, and in other embodiments, it is not specifically limited.

[0055] In response to the directory depth being greater than a preset depth threshold, and / or the directory of the reference document containing preset keywords, it is further determined whether the title in the directory whose directory depth exceeds a preset second depth threshold contains functional keywords; wherein, if the directory depth is greater than the preset depth threshold, and / or the directory of the reference document contains preset keywords, and the title in the directory whose directory depth exceeds the preset second depth threshold contains functional keywords, it means that the system level corresponding to the reference document corresponding to the directory is system, and at this time, the prerequisite for further determining whether the parsed content of the reference document contains multi-shape graphics and / or content pictures is also met.

[0056] In response to a title in a directory whose directory depth exceeds a preset second depth threshold containing a function keyword, it is determined whether the parsed content contains multi-shape graphics and / or content images, and if so, the multi-shape graphics and / or content images are obtained.

[0057] S230: Identify the multi-shape graphics and / or the content image to obtain a recognition result.

[0058] Among them, the multi-shape graphics are images composed of graphics of different shapes (such as rectangles, rhombuses, oval circles, parallelograms, etc.), and the content pictures are pictures existing in the document; this embodiment presets a corresponding image recognition algorithm to recognize multi-shape graphics and / or content pictures, and can obtain corresponding recognition results.

[0059] It should be noted that multi-shape graphics do not belong to pictures, and image recognition algorithms can generally only recognize pictures. Therefore, when there are multi-shape images in the parsed content, it is also necessary to convert the multi-shape images into corresponding pictures, and then recognize the pictures through the preset image recognition algorithm.

[0060] S240: In response to the recognition result being a test flowchart, use the reference document as a requirement document.

[0061] Among them, if the recognition result is a test flowchart, it means that the corresponding reference document not only has an information structure and a functional structure, but also has a test flowchart, which means that the reference document has the characteristics required for a requirement document, including: information structure, functional structure, and test flowchart.

[0062] S250, parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template.

[0063] S260. Determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain a second graph based on the node type and the first graph.

[0064] S270. Based on the menu nodes in the second graph, the node description, information structure, associated functions, parent nodes and initial use cases corresponding to the graph nodes are added to the second graph to obtain the target graph.

[0065] S280, rendering the target graph to obtain a target test case.

[0066] Embodiment 3

[0067] A test case generation method is provided in the third embodiment of the present application. The method optimizes the "determining the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtaining the second graph based on the node type and the first graph" in the first embodiment; wherein the graph node includes the bottom-level node in the first graph and all upper-level nodes of the bottom-level node; it should be noted that for the part not described in detail in this embodiment, please refer to the description of other embodiments, and the method includes:

[0068] S310, parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template.

[0069] S321. In response to the presence of a type keyword in the node name of the bottom-level node in the first graph, determine the node type of the bottom-level node based on the type keyword, and determine the node type of the parent node of the bottom-level node based on the node type of the bottom-level node.

[0070] Among them, the type keyword in this embodiment includes one of the system, subsystem, module and menu; first determine the bottom-level node in the first graph, and then determine whether the node name of the bottom-level node contains the type keyword. If so, determine the node type of the bottom-level node according to the type keyword. For example, if the type keyword is menu, the node type of the bottom-level node is menu.

[0071] When the node type of the bottom-level node is determined, the node type of the parent node of the bottom-level node can be further determined according to the system hierarchy of the software system (system-subsystem-module-menu); illustratively, if the node type of the bottom-level node is menu, the node type of the parent node of the bottom-level node is module.

[0072] S322. In response to the fact that there is no type keyword in the node name of the bottom-level node in the first graph, but there are multiple function keywords, determine the node type of the bottom-level node; determine whether the parent node of the bottom-level node is a top-level node to obtain a first judgment result, and determine the node type of the parent node of the bottom-level node based on the first judgment result.

[0073] Among them, if it is determined that there is no type keyword in the node name of the bottom-level node in the first graph, but there are multiple function keywords, at this time, it means that the node type of the bottom-level node is a menu; the top-level node is the highest-level node in the first graph, which generally corresponds to the first-level title in the directory of the requirement document.

[0074] S323. Obtain a second graph based on the node type of the bottom-level node, the node type of the upper-level node of the bottom-level node, and the first graph.

[0075] Among them, after determining the node type of the bottom-level node and the node types of all upper-level nodes of the first-level bottom-level node, the node type of the bottom-level node and the node types of all upper-level nodes of the bottom-level node are filled into the corresponding positions in the first graph to obtain a new graph, and the new graph is recorded as the second graph.

[0076] S330. Based on the menu nodes in the second graph, the node description, information structure, associated functions, parent nodes and initial use cases corresponding to the graph nodes are added to the second graph to obtain the target graph.

[0077] S340, rendering the target graph to obtain a target test case.

[0078] Embodiment 4

[0079] A test case generation method provided in a fourth embodiment of the present application optimizes the "determining the node type of the upper node of the bottom-level node based on the first judgment result" in the third embodiment; it should be noted that for the parts not described in detail in this embodiment, reference may be made to the descriptions of other embodiments, and the method includes:

[0080] S410, parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template.

[0081] S421. In response to the presence of a type keyword in the node name of the bottom-level node in the first graph, determine the node type of the bottom-level node based on the type keyword, and determine the node type of the parent node of the bottom-level node based on the node type of the bottom-level node.

[0082] S422A. In response to the fact that there is no type keyword in the node name of the bottom-level node in the first graph, but there are multiple function keywords, determine the node type of the bottom-level node; and determine whether the parent node of the bottom-level node is a top-level node to obtain a first judgment result.

[0083] S422B: In response to the first judgment result that the upper node of the bottom-level node is a top-level node, and the number of the top-level nodes is multiple, determine that the node type of the upper node of the bottom-level node is a subsystem.

[0084] If the first judgment result is that the upper node of the bottom node is a top node, and there are multiple top nodes, it means that the node type of the upper node of the bottom node, that is, the top node, is a subsystem.

[0085] S422C: In response to the first judgment result that the upper node of the bottom-level node is a top-level node and the number of top-level nodes is one, determine that the node type of the upper node of the bottom-level node is a module.

[0086] If the first judgment result is that the upper node of the bottom node is a top node, and the number of top nodes is one, it means that the node type of the upper node of the bottom node, that is, the top node, is a module.

[0087] S422D. In response to the first judgment result that the upper node of the bottom-level node is not the top-level node, determine the number of layers of all upper nodes of the bottom-level node, and determine the node type of all upper nodes of the bottom-level node based on the node type of the bottom-level node and the number of layers.

[0088] Among them, if the first judgment result is that the upper node of the bottom node is not the top node, it is necessary to further determine the number of layers of the upper node of the bottom node. For example, if the number of layers is 2, it means that there is an upper node above the bottom node, and there is another upper node above the upper node (that is, the upper upper node of the bottom node), and so on. In this embodiment, the system hierarchy corresponding to the known software system is: system-subsystem-module-menu. On the basis of determining the node type of the bottom node, the node types of all upper nodes of the bottom node can be determined in combination with the number of layers.

[0089] Exemplarily, the node type of the bottom-level node is determined to be a menu. When the number of layers is 2, it means that there are two layers of upper-level nodes above the bottom-level node, namely, the upper-level node and the upper-upper-level node of the bottom-level node. Among them, the node type of the upper-level node can be determined as a module according to the system level, and the node type of the upper-upper-level node can be determined as a subsystem according to the system level.

[0090] S423. Obtain a second graph based on the node type of the bottom-level node, the node type of the upper-level node of the bottom-level node, and the first graph.

[0091] S430. Based on the menu nodes in the second graph, the node description, information structure, associated functions, parent nodes and initial use cases corresponding to the graph nodes are added to the second graph to obtain the target graph.

[0092] S440, rendering the target graph to obtain a target test case.

[0093] Embodiment 5

[0094] A test case generation method provided in the fifth embodiment of the present application optimizes the method of "adding the node description, information structure, associated function, parent node and initial use case corresponding to the map node to the second map based on the menu node in the second map to obtain the target map" in the first embodiment; it should be noted that for the part not described in detail in this embodiment, reference can be made to the description of other embodiments, and the method includes:

[0095] S510, parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template.

[0096] S520. Determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain a second graph based on the node type and the first graph.

[0097] S531. Split the node description of the menu node in the second graph to obtain a functional segment, determine the corresponding functional sub-node based on the functional segment, and add the functional sub-node to the menu node; add the functional segment to the corresponding functional sub-node and use it as a sub-node description of the functional sub-node to obtain a third graph.

[0098] Among them, the menu generally contains multiple functions, such as adding, deleting, modifying, querying and statistics. The menu node has its corresponding node description in the second graph. The node description includes multiple natural segments, each natural segment is used to describe a function contained in the menu node, and the natural segment is recorded as a functional natural segment. The menu node is generally the lowest node in the graph, so the menu node generally no longer has its subordinate nodes. In order to facilitate the final generated target test case to fully cover the various functions contained in the menu, it is necessary to continue to set corresponding subordinate nodes for the menu node. To this end, the node corresponding to the functional natural segment can be generated according to the function specifically described in each functional natural segment as the subordinate node corresponding to the menu node, and the subordinate node is recorded as a functional sub-node. Further, the functional natural segment corresponding to the functional sub-node needs to be matched to the functional sub-node as the sub-node description of the functional sub-node; and the new graph obtained after the second graph is supplemented with functional sub-nodes and sub-node descriptions is recorded as the third graph.

[0099] S532. Determine the information structure of the functional sub-node based on the sub-node description, and determine the information structure of the parent node of the menu node based on the information structure of the menu node in the third graph.

[0100] The information structure corresponding to the corresponding function sub-node can be determined by processing the sub-node description, and the information structure includes the table field name, table field type and table field description. The information structure of the parent node of the menu node can be further determined by the information structure of each menu node in the third atlas.

[0101] S533. Obtain a fourth graph based on the information structure of the function sub-node, the information structure of the menu node, the information structure of the parent node of the menu node and the third graph.

[0102] Among them, by adding the information structure of the function sub-node, the information structure of the menu node, and the information structure of the parent node of the menu node to the corresponding positions in the third graph, a new graph can be obtained, and the new graph is recorded as the fourth graph.

[0103] S534: Determine the associated function based on the node description of the bottom-level node in the fourth graph, and obtain the fifth graph based on the associated function and the fourth graph.

[0104] Among them, the association function is used to characterize the functional flow relationship between each graph node, and the relationship can be determined through the node description of the bottom-level node in the fourth graph; a new graph can be obtained by adding the association function to the fourth graph, and the new graph is recorded as the fifth graph.

[0105] S535. Determine the parent node of each graph node in the fifth graph, and obtain a sixth graph based on the parent node and the fifth graph.

[0106] Among them, each graph node in the fifth graph has a corresponding parent node. If a graph node is a top-level node, the parent node of the graph node is empty. By adding the parent nodes of each graph node to the corresponding positions in the fifth graph, a new graph can be obtained, and the new graph is recorded as the sixth graph.

[0107] S536. Generate prompt words based on the associated functions in the sixth graph and the node descriptions of each graph node, and obtain an initial use case based on the prompt words and a preset use case generation model; obtain a target graph based on the initial use case and the sixth graph.

[0108] By assembling the associated functions in the sixth graph and the node descriptions of each graph node, the corresponding prompt word can be obtained; the use case generation model preset in this embodiment can process the prompt word and generate an initial use case corresponding to the prompt word. By adding the initial use case to the corresponding position in the sixth graph, a new graph can be obtained, and the new graph is recorded as the target graph.

[0109] S540: Render the target graph to obtain a target test case.

[0110] Embodiment 6

[0111] A test case generation method is provided in Embodiment 6 of the present application. The method optimizes the "determining the information structure of the function sub-node based on the sub-node description, and determining the information structure of the parent node of the menu node based on the information structure of the menu node in the third graph" in Embodiment 5; it should be noted that for the parts not described in detail in this embodiment, please refer to the description of other embodiments. The method includes:

[0112] S610, parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template.

[0113] S620. Determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain a second graph based on the node type and the first graph.

[0114] S631. Split the node description of the menu node in the second graph to obtain a functional segment, determine the corresponding functional sub-node based on the functional segment, and add the functional sub-node to the menu node; add the functional segment to the corresponding functional sub-node and use it as a sub-node description of the functional sub-node to obtain a third graph.

[0115] S632A: In response to the existence of a table in the sub-node description and the existence of a corresponding information structure for the table, use the information structure corresponding to the table as the information structure corresponding to the functional sub-node.

[0116] By parsing the subnode description of the functional subnode, it can be determined whether there is a table in the subnode description. If it is further determined that the table has a corresponding information structure, the information structure corresponding to the table can be used as the information structure of the functional subnode.

[0117] S632B: In response to the existence of the menu nodes at the same level in the third graph, determine whether the menu nodes at the same level in the third graph have the same information structure, and obtain a second determination result.

[0118] The menu nodes at the same level are menu nodes with the same directory depth. Each menu node has a corresponding node description. By parsing the node description, it can be determined whether the menu node has an information structure.

[0119] S632C: Determine the information structure of the parent node of the menu node based on the second judgment result.

[0120] S633. Obtain a fourth graph based on the information structure of the function sub-node, the information structure of the menu node, the information structure of the parent node of the menu node and the third graph.

[0121] S634: Determine an associated function based on the node description of the bottom-level node in the fourth graph, and obtain a fifth graph based on the associated function and the fourth graph.

[0122] S635. Determine the parent node of each graph node in the fifth graph, and obtain a sixth graph based on the parent node and the fifth graph.

[0123] S636. Generate prompt words based on the associated functions in the sixth graph and the node descriptions of each graph node, and obtain an initial use case based on the prompt words and a preset use case generation model; obtain a target graph based on the initial use case and the sixth graph.

[0124] S640: Render the target graph to obtain a target test case.

[0125] Embodiment 7

[0126] A test case generation method provided in Embodiment 7 of the present application optimizes the "determining the information structure of the parent node of the menu node based on the second judgment result" in Embodiment 6; it should be noted that for the parts not described in detail in this embodiment, reference may be made to the descriptions of other embodiments, and the method includes:

[0127] S710. Parse the requirement document to obtain a directory and a node name, and obtain a first graph based on the directory, the node name, and a preset graph template.

[0128] S720. Determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain a second graph based on the node type and the first graph.

[0129] S731. Split the node description of the menu node in the second graph to obtain a functional segment, determine the corresponding functional sub-node based on the functional segment, and add the functional sub-node to the menu node; add the functional segment to the corresponding functional sub-node and use it as a sub-node description of the functional sub-node to obtain a third graph.

[0130] S732A: In response to the existence of a table in the sub-node description and the existence of a corresponding information structure for the table, use the information structure corresponding to the table as the information structure corresponding to the functional sub-node.

[0131] S732B. In response to the existence of the menu nodes at the same level in the third graph, determine whether the menu nodes at the same level in the third graph have the same information structure, and obtain a second determination result.

[0132] S732C1. In response to the second judgment result that the menu nodes at the same level in the third graph have the same information structure, the information structure of the menu node is used as the information structure of the parent node of the menu node.

[0133] The similarity of the information structures of the menu nodes at the same level is calculated, and in response to the similarity exceeding a preset similarity threshold, it can be determined that the menu nodes at the same level in the third graph have the same information structure.

[0134] S732C2: In response to the second judgment result that the menu nodes at the same level in the third graph do not have the same information structure, determine whether the input parameters included in the function structure of the menu node are included in the information structure of the menu node.

[0135] The input parameter is a parameter in the function structure corresponding to the execution logic and the execution result. The execution logic can generate the corresponding execution result by executing the input parameter. The information structure of the menu node may also include the input parameter.

[0136] S732C3. In response to the input parameters included in the function structure of the menu node being included in the information structure of the menu node, use the information structure of the menu node as the information structure of the parent node of the menu node.

[0137] If the input parameters included in the function structure of the menu node are included in the information structure of the menu node, it means that the information structure of the menu node can be used as the information structure of the parent node of the menu node.

[0138] S733. Obtain a fourth graph based on the information structure of the function sub-node, the information structure of the menu node, the information structure of the parent node of the menu node and the third graph.

[0139] S734. Determine an associated function based on the node description of the bottom-level node in the fourth graph, and obtain a fifth graph based on the associated function and the fourth graph.

[0140] S735. Determine the parent node of each graph node in the fifth graph, and obtain a sixth graph based on the parent node and the fifth graph.

[0141] S736. Generate prompt words based on the associated functions in the sixth graph and the node descriptions of each graph node, and obtain an initial use case based on the prompt words and a preset use case generation model; obtain a target graph based on the initial use case and the sixth graph.

[0142] S740, rendering the target graph to obtain a target test case.

[0143] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0144] Embodiment 8

[0145] Based on the same inventive concept, this embodiment also provides a test case generation device for implementing the test case generation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more test case generation device embodiments provided below can refer to the limitations of the test case generation method above, and will not be repeated here.

[0146] In this embodiment, Figure 2 As shown, a test case generating device is provided, comprising:

[0147] A first graph generation module, used for parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template;

[0148] A second graph generation module, used to determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain a second graph based on the node type and the first graph;

[0149] A target graph generation module, used for adding node descriptions, information structures, associated functions, parent nodes and initial use cases corresponding to the graph nodes to the second graph based on menu nodes in the second graph, to obtain a target graph;

[0150] The graph rendering module is used to render the target graph to obtain the target test case.

[0151] Each module in the above test case generation device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0152] It should be noted that this embodiment obtains a directory and node names by parsing the requirement document, and obtains a first graph based on the directory, the node names and a preset graph template; determines the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtains a second graph based on the node type and the first graph; adds the node description, information structure, associated function, parent node and initial use case corresponding to the graph node to the second graph based on the menu node in the second graph, to obtain a target graph; renders the target graph to obtain a target test case. Through the above implementation, when the requirement document is obtained, the directory, node description, node name, information structure, related functions, parent node and initial use case contained in the requirement document can be extracted, and then the above directory, node description, node name, information structure, related functions, parent node and initial use case are filled into the preset graph template to obtain the target graph. The above information covered in the target graph can be used as the information required for the target test case to be generated. Since the target graph covers the directories, node descriptions, node names, information structures, related functions, parent nodes and initial use cases related to multiple graph nodes, the target test cases generated based on the target graph can fully reflect the test cases required for different test directions in software testing, thereby effectively improving the completeness of the test cases required for software testing.

[0153] Embodiment 9

[0154] In this embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a test case generation method is implemented.

[0155] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present disclosure, and does not constitute a limitation on the computer device to which the scheme of the present disclosure is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0156] Embodiment 10

[0157] In this embodiment, a computer readable storage medium is provided. Figure 4 As shown, a computer program is stored thereon, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0158] Embodiment 11

[0159] In this embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0160] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.

[0161] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present disclosure can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present disclosure may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided by the present disclosure may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, etc., but are not limited to this.

[0162] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0163] The above-described embodiments only express several implementation methods of the present disclosure, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present disclosure, and these all belong to the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the attached claims.

Claims

1. A test case generation method, characterized in that: include: Parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template; Determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain a second graph based on the node type and the first graph; Based on the menu nodes in the second graph, the node description, information structure, associated functions, parent nodes and initial use cases corresponding to the graph nodes are added to the second graph to obtain a target graph; Render the target graph to obtain a target test case.

2. The method according to claim 1, characterized in that: The parsing requirement document to obtain a directory and a node name, and before obtaining a first graph based on the directory, the node name and a preset graph template, the process includes: Parse the reference document to obtain the parsed content; In response to the existence of the information structure and the functional structure in the parsed content, obtaining multiple-shape graphics and / or content images in the parsed content; Recognize the multi-shape graphics and / or the content image to obtain a recognition result; In response to the recognition result being a test flow chart, the reference document is used as a requirement document.

3. The method according to claim 1, characterized in that The graph nodes include the bottom-level nodes in the first graph and all upper-level nodes of the bottom-level nodes; the node type of each graph node in the first graph is determined based on the node name of the bottom-level node in the first graph, and the second graph is obtained based on the node type and the first graph, including: In response to the presence of a type keyword in the node name of the bottom-level node in the first graph, determining the node type of the bottom-level node based on the type keyword, and determining the node type of the parent node of the bottom-level node based on the node type of the bottom-level node; In response to the fact that there is no type keyword in the node name of the bottom-level node in the first graph, but there are multiple function keywords, determining the node type of the bottom-level node; determining whether the parent node of the bottom-level node is a top-level node to obtain a first judgment result, and determining the node type of the parent node of the bottom-level node based on the first judgment result; A second graph is obtained based on the node type of the bottom-level node, the node type of the upper-level node of the bottom-level node, and the first graph.

4. The method according to claim 3, characterized in that The determining the node type of the upper node of the bottom-level node based on the first judgment result includes: In response to the first judgment result that the upper node of the bottom-most node is a top-level node, and the number of the top-level nodes is multiple, determining that the node type of the upper node of the bottom-most node is a subsystem; In response to the first judgment result that the upper node of the bottom-most node is a top-level node, and the number of the top-level nodes is one, determining that the node type of the upper node of the bottom-most node is a module; In response to the first judgment result that the upper node of the bottom-level node is not the top-level node, the number of layers of all upper nodes of the bottom-level node is determined, and the node type of all upper nodes of the bottom-level node is determined based on the node type of the bottom-level node and the number of layers.

5. The method according to claim 1, characterized in that The step of adding the node description, information structure, associated function, parent node and initial use case corresponding to the map node to the second map based on the menu node in the second map to obtain the target map includes: Splitting the node description of the menu node in the second graph to obtain a function segment, determining a corresponding function sub-node based on the function segment, and adding the function sub-node to the menu node; adding the function segment to the corresponding function sub-node and using it as a sub-node description of the function sub-node to obtain a third graph; Determine the information structure of the function sub-node based on the sub-node description, and determine the information structure of the parent node of the menu node based on the information structure of the menu node in the third graph; Based on the information structure of the function sub-node, the information structure of the menu node, the information structure of the parent node of the menu node and the third graph, a fourth graph is obtained; Determine an associated function based on a node description of the bottom-level node in the fourth graph, and obtain a fifth graph based on the associated function and the fourth graph; Determine the parent node of each graph node in the fifth graph, and obtain a sixth graph based on the parent node and the fifth graph; Prompt words are generated based on the associated functions in the sixth graph and the node descriptions of each graph node, and an initial use case is obtained based on the prompt words and a preset use case generation model; a target graph is obtained based on the initial use case and the sixth graph.

6. The method according to claim 5, characterized in that The determining the information structure of the function sub-node based on the sub-node description, and determining the information structure of the parent node of the menu node based on the information structure of the menu node in the third graph, includes: In response to the presence of a table in the sub-node description and the presence of a corresponding information structure in the table, using the information structure corresponding to the table as the information structure corresponding to the function sub-node; In response to the existence of the menu nodes at the same level in the third graph, determining whether the menu nodes at the same level in the third graph have the same information structure, and obtaining a second determination result; The information structure of the parent node of the menu node is determined based on the second judgment result.

7. The method according to claim 6, characterized in that The determining the information structure of the parent node of the menu node based on the second judgment result includes: In response to the second judgment result that the menu nodes at the same level in the third graph have the same information structure, using the information structure of the menu node as the information structure of the parent node of the menu node; In response to the second judgment result that the menu nodes at the same level in the third graph do not have the same information structure, judging whether the input parameters included in the function structure of the menu node are included in the information structure of the menu node; In response to the input parameter included in the function structure of the menu node being included in the information structure of the menu node, the information structure of the menu node is used as the information structure of the parent node of the menu node.

8. A test case generating device, characterized in that: The device comprises: A first graph generation module, used for parsing the requirement document to obtain a directory and a node name, and obtaining a first graph based on the directory, the node name and a preset graph template; A second graph generation module, used to determine the node type of each graph node in the first graph based on the node name of the bottom-level node in the first graph, and obtain a second graph based on the node type and the first graph; A target graph generation module, used for adding node descriptions, information structures, associated functions, parent nodes and initial use cases corresponding to the graph nodes to the second graph based on menu nodes in the second graph, to obtain a target graph; The graph rendering module is used to render the target graph to obtain the target test case.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Test case generation method and device, terminal and computer readable storage medium

    CN110287104A

  • Test case generation method and device, storage medium and electronic equipment

    CN113704083A

  • Test case generation method and device, computer equipment and storage medium

    CN117194216A

  • Knowledge graph generation method and device based on word document and electronic equipment

    CN119597930A