Test Case Generation Method, Device, Storage Medium, and Electronic Device
By constructing a directed infographic and traversing nodes to check natural language information, the problem of low efficiency in manual troubleshooting requirements description documents is solved, and the quality and efficiency of test case generation is improved.
Patent Information
- Application Number
- CN202110252901.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-09
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2041-03-09
AI Technical Summary
In the prior art, manual troubleshooting of language description errors in the requirement description document is time-consuming and labor-intensive, resulting in poor quality and low efficiency, so that all problems cannot be detected.
By constructing a directed infographic, traversing the graph nodes to conduct legality checks on natural language information, generating test cases, and improving inspection efficiency and quality.
Improve the efficiency of legality checking of natural language information in demand description documents, ensure the quality of generated test cases, and reduce the time and cost of manual inspection.
Smart Images

Figure CN113704083B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of computer technology, and in particular, to a test case generation method, apparatus, storage medium, and electronic device. Background Art
[0002] A test case refers to a description of the test tasks for a specific software product, which can reflect the test plan, methods, technologies, and strategies. Moreover, a test case is a structured text description that includes all the necessary information required for a complete test task. Test cases can be used to test software products to verify whether the software products meet the expected requirements.
[0003] The quality of test cases affects the performance of testing software products. Using test cases of poor quality for testing may result in missed tests or even program crashes. Moreover, it is extremely difficult and costly to troubleshoot problems existing in test cases. Therefore, currently, after writing a requirements description document, testers usually manually check whether there are language description errors or problems in the requirements description document, and then generate test cases based on the requirements description document after troubleshooting the problems.
[0004] However, using manual methods for troubleshooting is time-consuming and laborious. Moreover, when the content of the requirements description document is large or there are many language description problems, all existing problems usually cannot be detected, and the inspection efficiency is low. When generating test cases based on the requirements description document with problems, the quality of the generated test cases is generally poor, and sometimes test cases cannot be generated correctly. Summary of the Invention
[0005] To solve the technical problems existing in the related art, embodiments of the present application provide a test case generation method, apparatus, storage medium, and electronic device, which can improve the quality of generated test cases.
[0006] To achieve the above object, the technical solution of the embodiments of the present application is implemented as follows:
[0007] In a first aspect, embodiments of the present application provide a test case generation method, and the method includes:
[0008] Obtain a preset requirements description document; the requirements description document at least includes each business step of the service to be tested and the logical relationship between each business step;
[0009] Construct a corresponding directed information graph according to the requirements description document; wherein, each graph node in the directed information graph represents a business step, and the direction between every two graph nodes represents the logical order between the corresponding two business steps;
[0010] Traverse each graph node based on the direction between every two graph nodes in the directed information graph, and respectively perform a legality check on the natural language information associated with each graph node in the requirement description document. If the check result is passed, generate test cases according to the requirement description document.
[0011] In a second aspect, an embodiment of the present application further provides a test case generation device, and the device includes:
[0012] A document acquisition unit, configured to acquire a preset requirement description document; the requirement description document at least includes each business step of the service to be tested and the logical relationship between the business steps.
[0013] A directed graph construction unit, configured to construct a corresponding directed information graph according to the requirement description document; wherein, each graph node in the directed information graph represents a business step, and the direction between every two graph nodes represents the logical order between the corresponding two business steps.
[0014] A legality check unit, configured to traverse each graph node based on the direction between every two graph nodes in the directed information graph, and respectively perform a legality check on the natural language information associated with each graph node in the requirement description document.
[0015] A test case generation unit, configured to generate test cases according to the requirement description document if the check result is passed.
[0016] In an optional embodiment, the legality check unit is further configured to:
[0017] If the check result is not passed, output an error prompt message based on the natural language information associated with the graph node that fails the check.
[0018] In response to a request to generate test cases based on the modified requirement description document, perform a legality check on the natural language information in the modified requirement description document.
[0019] In an optional embodiment, the business steps include basic steps and extended steps; the directed graph construction unit is specifically configured to:
[0020] Take both the basic step and the extended step as graph nodes, and determine the direction between the corresponding two graph nodes according to the logical relationship between every two business steps, to obtain a directed relationship graph.
[0021] According to the requirement description document, add the associated natural language information to each graph node in the directed relationship graph, to obtain the directed information graph corresponding to the requirement description document.
[0022] In an alternative embodiment, the natural language information includes node description information and business rule information; the directed graph construction unit is further configured to:
[0023] According to the description information of each business step, add associated node description information to the corresponding graph nodes;
[0024] According to the business rules in the requirement description document, add associated business rule information to the graph nodes in the directed relationship graph.
[0025] In an alternative embodiment, the legality check unit is specifically configured to:
[0026] Adopt a depth-first search method or a breadth-first search method to traverse each graph node based on the direction between every two graph nodes in the directed information graph;
[0027] Respectively perform a legality check on the description methods of the natural language information associated with each graph node; if there is a graph node that fails the check, determine that the check result is a failed check, and if there is no graph node that fails the check, determine that the check result is a passed check.
[0028] In an alternative embodiment, the legality check unit is further configured to:
[0029] For each graph node, perform the following operations respectively:
[0030] Match the natural language information associated with one of the graph nodes with a preset illegal description information rule; the illegal description information rule includes at least one of the following: half-width punctuation marks, space characters at the beginning of each line of natural language information, space characters at the end of each line of natural language information, line break characters at the end of a single line of natural language information;
[0031] If the match is successful, determine that the one graph node fails the check.
[0032] In an alternative embodiment, the natural language information includes node description information; the legality check unit is further configured to: match the node description information associated with the one graph node with the illegal description information rule; or,
[0033] The natural language information includes business rule information; the legality check unit is further configured to: establish a reference tree corresponding to the one graph node based on the business rule information of the one graph node; each leaf node in the reference tree corresponds to a business rule in the business rule information of the one graph node; traverse each leaf node in the reference tree corresponding to the one graph node, and respectively match the business rules corresponding to the respective leaf nodes with the illegal description information rule.
[0034] In an alternative embodiment, the natural language information includes business rule information; the legality check unit is further configured to:
[0035] Establish a reference tree corresponding to each graph node based on the business rule information associated with each graph node respectively; each leaf node in each reference tree corresponds to a business rule in the business rule information of the corresponding graph node; the reference tree includes a plurality of leaf nodes; the business rule information includes business rule description information and business rule type;
[0036] Traverse each leaf node in the reference tree corresponding to each graph node, and for each leaf node, perform the following operations respectively:
[0037] Match the business rule description information of a leaf node among the leaf nodes with the business rule type; the business rule description information and the business rule type are included in the business rule corresponding to the one leaf node;
[0038] If the matching fails, determine that the graph node corresponding to the one leaf node fails the check.
[0039] In an alternative embodiment, the test case generation unit is specifically configured to:
[0040] Extract the corpus information of the requirement description document, and determine the corpus features corresponding to the requirement description document according to the corpus information;
[0041] Generate test cases according to the corpus features and the requirement description document.
[0042] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the test case generation method of the first aspect is implemented.
[0043] In a fourth aspect, an embodiment of the present application further provides an electronic device, including a memory and a processor, where a computer program that can run on the processor is stored on the memory, and when the computer program is executed by the processor, the processor implements the test case generation method of the first aspect.
[0044] The test case generation method, device, storage medium, and electronic device provided by the embodiments of the present application first construct a corresponding directed information graph according to each business step and the logical relationship between each business step in the obtained requirements description document before generating test cases based on the requirements description document. Then, traverse each graph node in the directed information graph, and respectively perform a legality check on the natural language information associated with each graph node in the requirements description document. After passing the legality check, generate test cases according to the requirements description document. Compared with the related art, it can improve the efficiency of the legality check on the natural language information associated with the requirements description document, and ensure the correctness of the requirements description document, so that test cases can be generated according to the correct requirements description document, improving the quality of the generated test cases. Description of the Drawings
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0046] Figure 1 It is an application scenario diagram of a test case generation method provided by the embodiments of the present application;
[0047] Figure 2 It is a flowchart of a test case generation method provided by the embodiments of the present application;
[0048] Figure 3 It is a structural diagram of a test case generation method provided by the embodiments of the present application;
[0049] Figure 4 It is a flowchart of another test case generation method provided by the embodiments of the present application;
[0050] Figure 5 It is a structural diagram of a requirements management system provided by the embodiments of the present application;
[0051] Figure 6 It is a page diagram of a requirements management system provided by the embodiments of the present application;
[0052] Figure 7 It is another page diagram of a requirements management system provided by the embodiments of the present application;
[0053] Figure 8 It is another page diagram of a requirements management system provided by the embodiments of the present application;
[0054] Figure 9A page schematic diagram of another requirement management system provided by an embodiment of the present application;
[0055] Figure 10 A timing schematic diagram of a requirement management system provided by an embodiment of the present application;
[0056] Figure 11 A page schematic diagram of a requirement description document provided by an embodiment of the present application;
[0057] Figure 12 A page schematic diagram of a test case provided by an embodiment of the present application;
[0058] Figure 13 A flowchart of another test case generation method provided by an embodiment of the present application;
[0059] Figure 14 A schematic diagram of a requirement description document provided by an embodiment of the present application;
[0060] Figure 15 A schematic diagram of another requirement description document provided by an embodiment of the present application;
[0061] Figure 16 A schematic diagram of a directed relationship graph provided by an embodiment of the present application;
[0062] Figure 17 A schematic diagram of a directed information graph provided by an embodiment of the present application;
[0063] Figure 18 A structural block diagram of a test case generation device provided by an embodiment of the present application;
[0064] Figure 19 A structural schematic diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0065] To make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings. Apparently, the described embodiments are only a part rather than all of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the scope of protection of the present application.
[0066] It should be noted that the terms "including" and "having" and their variations involved in the documents of the present application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those clearly listed steps or units, but may include other steps or units not clearly listed or inherent to these process, method, product or device.
[0067] The following explains some terms in the embodiments of the present application to facilitate understanding by those skilled in the art.
[0068] (1) Unified Modeling Language (UML) modeling: A modeling language that uses model elements to form the model of the entire system. The model elements include classes in the system, associations between classes, and the cooperation of class instances to achieve the dynamic behavior of the system.
[0069] (2) Model-Based Testing (MBT): A testing method in the field of software testing. According to this testing method, test cases can be automatically generated fully or partially using models.
[0070] (3) Directed information graph: A concept in graph theory, which is a graph composed of a vertex set and a set of directed edges connecting ordered vertex pairs, that is, one vertex of an edge points to another vertex.
[0071] (4) Directed information graph traversal: Also a concept in graph theory, which means starting from a certain vertex in the directed information graph and visiting all vertices in the graph along the edges in the graph once and only once according to a certain search method. Commonly used directed information graph traversal methods include the Depth First Search (DFS) method and the Breadth First Search (BFS) method.
[0072] The term "exemplary" used hereinafter means "serving as an example, embodiment, or illustration". Any embodiment illustrated as "exemplary" does not have to be construed as superior to or better than other embodiments.
[0073] The terms "first" and "second" in the text are only used for descriptive purposes and cannot be construed as explicitly or implicitly indicating relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the embodiments of the present application, unless otherwise specified, the meaning of "a plurality" is two or more.
[0074] The embodiments of the present application relate to artificial intelligence (AI) and machine learning technologies, and are designed based on computer vision (CV) technology, speech processing technology, and machine learning (ML) in artificial intelligence.
[0075] Artificial intelligence uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, including theories, methods, technologies, and application systems that can perceive the environment, acquire knowledge, and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines to enable machines to have the functions of perception, reasoning, and decision-making. Artificial intelligence technologies mainly include several major directions such as computer vision technology, speech processing technology, and machine learning / deep learning.
[0076] With the research and progress of artificial intelligence technology, artificial intelligence is being studied and applied in multiple fields, such as common smart homes, image retrieval, video surveillance, smart speakers, smart marketing, driverless, autonomous driving, drones, robots, intelligent healthcare, etc. It is believed that with the development of technology, artificial intelligence will be applied in more fields and play an increasingly important role.
[0077] Machine learning is an interdisciplinary subject that involves multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve their own performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent, and its applications cover all fields of artificial intelligence. Machine learning and deep learning usually include technologies such as artificial neural networks, belief networks, reinforcement learning, transfer learning, and inductive learning. The embodiments of this application use a model based on machine learning or deep learning to automatically generate test cases according to the requirements description document.
[0078] To better understand the technical solutions provided by the embodiments of this application, the following briefly introduces the application scenarios applicable to the technical solutions provided by the embodiments of this application. It should be noted that the application scenarios introduced below are only for illustrating the embodiments of this application and not for limitation. In specific implementations, the technical solutions provided by the embodiments of this application can be flexibly applied according to actual needs.
[0079] The test case generation method provided by the embodiments of this application can be applied to Figure 1 the application scenario shown in Figure 1 As shown, this application scenario includes multiple terminal devices 11 and a server 12. The terminal devices 11 and the server 12 can be connected and transmit data through a wired connection method or a wireless connection method. For example, the terminal devices 11 and the server 12 can be connected by a data cable or through a wired network; the terminal devices 11 and the server 12 can also be connected through a radio frequency module, a WiFi module, or a wireless network.
[0080] Among them, the terminal device 11 can be a computer, a notebook, a personal digital assistant (PDA), a tablet computer, etc. The server 12 can be a single server, a server cluster or a cloud computing center composed of several servers, or a virtualization platform, and can also be a personal computer, a large or medium-sized computer or a computer cluster, etc. According to the implementation requirements, the application scenario in the embodiments of the present application can have any number of terminal devices and servers. The present application does not make special limitations on this. The test case generation method provided in the embodiments of the present application can be executed by the server 12, or can be executed by the cooperation of the terminal device 11 and the server 12.
[0081] For example, an application development organization has a server 12 for generating test cases. Terminal devices 11 are set in each laboratory within the development organization. The user 10 can transmit the written requirement description document to the server 12 through the terminal device 11 in his own laboratory. After receiving the requirement description document, the server 12 can construct a corresponding directed information graph according to the requirement description document, and perform a legality check on the natural language information associated with each graph node in the directed information graph. When it is determined that the natural language information associated with the requirement description document is legal, test cases can be generated according to the requirement description document.
[0082] To further illustrate the technical solution provided in the embodiments of the present application, the following will be described in detail in combination with the accompanying drawings and specific implementation manners. Although the embodiments of the present application provide the method operation steps as shown in the following embodiments or drawings, based on routine or non-creative labor, more or fewer operation steps may be included in the method. In steps where there is no necessary causal relationship logically, the execution order of these steps is not limited to the execution order provided in the embodiments of the present application. When the method is actually processed or executed by the device, it can be executed in the method order shown in the embodiments or drawings or executed in parallel.
[0083] Figure 2 shows a flowchart of a test case generation method provided in an embodiment of the present application. This method can be executed by Figure 1 the server 12 therein, or can be executed by the terminal device 11 or other electronic devices. Exemplarily, hereinafter, a computer for generating test cases is used as the execution subject to illustrate the specific implementation process of the test case generation method in the embodiments of the present application. As Figure 2 shown, the test case generation method includes the following steps:
[0084] Step S201, obtain a preset requirement description document.
[0085] The requirement description document shall at least include each business step of the business to be tested and the logical relationships between each business step.
[0086] Step S202: Construct a corresponding directed information graph according to the requirement description document.
[0087] Among them, each graph node in the directed information graph represents a business step, and the direction between every two graph nodes represents the logical order between the corresponding two business steps. The business steps may include basic steps and extended steps. Both the basic steps and the extended steps can be used as graph nodes. First, determine the direction between the corresponding two graph nodes according to the logical relationship between every two business steps to obtain a directed relationship graph, and then, according to the requirement description document, add associated natural language information to each graph node in the directed relationship graph. Since the natural language information includes node description information and business rule information, the associated node description information can be added to the corresponding graph node in the directed relationship graph according to the description information of each business step in the requirement description document first, and then the associated business rule information can be added to the corresponding graph node in the directed relationship graph according to the business rules of each business step in the requirement description document, so that the directed information graph corresponding to the requirement description document can be obtained.
[0088] Step S203: Traverse each graph node based on the direction between every two graph nodes in the directed information graph, and respectively perform a legality check on the natural language information associated with each graph node in the requirement description document.
[0089] The depth-first search (DFS) method or the breadth-first search (BFS) method can be used to traverse each graph node based on the direction between every two graph nodes in the directed information graph, and respectively perform a legality check on the description method of the natural language information associated with each graph node. If there is a graph node that fails the check, it can be determined that the check result is that the check fails. If there is no graph node that fails the check, it can be determined that the check result is that the check passes.
[0090] In one embodiment, for each graph node in the directed information graph, the following operations can be respectively performed: match the natural language information associated with one graph node among each graph node with a preset illegal description information rule. If the match is successful, it can be determined that the graph node fails the check. The illegal description information rule may include at least one of the following: half-width punctuation marks, space characters at the beginning of each line of natural language information, space characters at the end of each line of natural language information, line break characters at the end of a single line of natural language information. This application may not be limited to performing a legality check on the natural language information according to the above four illegal description information rules.
[0091] When performing a legality check on the node description information included in the natural language information, the node description information associated with each graph node can be matched against the illegal description information rules. If the match is successful, it can be determined that the graph node fails the check. When performing a legality check on the business rule information included in the natural language information, for each graph node, the following operations can be performed separately: Based on the business rule information of a graph node, establish a reference tree corresponding to the graph node, and each leaf node in the reference tree corresponds to a business rule in the business rule information of the graph node. Traverse each leaf node in the reference tree corresponding to the graph node, and separately match the business rule corresponding to each leaf node against the illegal description information rules. If the match is successful, it can be determined that the graph node fails the check.
[0092] In another embodiment, when performing a legality check on the business rule information included in the natural language information, reference trees corresponding to each graph node can be established separately based on the business rule information associated with each graph node. Each leaf node in each reference tree corresponds to a business rule in the business rule information of the corresponding graph node, and each reference tree can include multiple leaf nodes. Moreover, the business rule information can include business rule description information and business rule types. Traverse each leaf node in the reference trees corresponding to each graph node, and for each leaf node, perform the following operations separately: Match the business rule description information of one leaf node among each leaf node against the business rule type, and the business rule description information and the business rule type are included in the business rule corresponding to the leaf node. If the match fails, it can be determined that the graph node corresponding to the leaf node fails the check.
[0093] This application is not limited to performing a legality check on the natural language information associated with each graph node in the requirements description document according to the legality check rules provided in the above embodiments. Different legality check rules can be configured according to actual business check requirements.
[0094] Step S204, if the check result is that the check passes, generate test cases according to the requirements description document.
[0095] When the check result is that the check passes, that is, when performing a legality check on the natural language information associated with each graph node in the requirements description document and there are no graph nodes that fail the check, test cases can be generated according to the requirements description document.
[0096] In one embodiment, corpus information in a requirements description document can be extracted, and corpus features corresponding to the requirements description document can be determined based on the corpus information. Furthermore, based on the corpus features and the requirements description document that passes the legality check, test cases can be generated. Specifically, the corpus information in the requirements description document can be extracted, and the corpus information can be characterized and classified to obtain corpus classification information and conflicting corpus information in the requirements description document. The corpus classification information and the conflicting corpus information can be used to guide the generation of test cases for the requirements description document that passes the legality check.
[0097] In another embodiment, when the check result is that the check fails, that is, when performing a legality check on the natural language information associated with each graph node in the requirements description document and there are graph nodes that fail the check, error prompt information can be output based on the natural language information associated with the graph nodes that fail the check. And in response to a request to generate test cases for the requirements description document modified based on the error prompt information, the natural language information in the modified requirements description document is subjected to a legality check again.
[0098] In some embodiments, instead of constructing a corresponding directed information graph according to the requirements description document, the requirements description document can be directly scanned to perform a legality check on the natural language information in the requirements description document. When no illegal natural language information is scanned in the requirements description document, test cases can be directly generated according to the requirements description document. When illegal natural language information is scanned in the requirements description document, error prompt information can be output. The advantage of using the scanning method for legality check is that the speed is faster, but the disadvantages are that some context information of the requirements description document may be lost, and it is also not conducive to checking other problems in the requirements description document except for natural language information. Therefore, the scanning method can be used for legality check in scenarios where the check speed is pursued.
[0099] The test case generation method provided by the embodiments of the present application, before generating test cases according to the requirements description document, first constructs a corresponding directed information graph according to each business step in the obtained requirements description document and the logical relationship between each business step, traverses each graph node in the directed information graph, and respectively performs a legality check on the natural language information associated with each graph node in the requirements description document. After passing the legality check, test cases are generated according to the requirements description document. Compared with the related art, it can improve the efficiency of performing a legality check on the natural language information associated with the requirements description document and ensure the correctness of the requirements description document, so that test cases can be generated according to the correct requirements description document, improving the quality of the generated test cases.
[0100] In some embodiments, model-based testing (MBT) can be used to guide the generation of test cases, that is, the generation process of test cases can be completed according to the Figure 3 requirements management system, legitimacy check system, feature library system, and test case automatic generation system therein. The requirements management system can obtain a requirements description document for generating test cases. The legitimacy check system is used to construct a corresponding directed information graph according to the requirements description document, and traverse each graph node based on the direction between every two graph nodes in the directed information graph, and respectively perform a legitimacy check on the natural language information associated with each graph node in the requirements description document to obtain a legitimate requirements description document. The feature library system is used to extract the corpus information of the requirements description document and determine the corpus features corresponding to the requirements description document according to the corpus information. The test case automatic generation system is used to generate test cases according to the corpus features and the legitimate requirements description document.
[0101] Specifically, Figure 4 shows the detailed implementation process of the test case generation method proposed in this application. As Figure 4 shown, it may include the following steps:
[0102] Step S401, obtain a preset requirements description document.
[0103] The requirements description document can be obtained through the requirements management system, and the requirements description document at least includes each business step of the service to be tested and the logical relationship between the various business steps.
[0104] Before obtaining the requirements description document, the user can first write a requirements document in docx format according to the test requirements for testing the software product, and then input the requirements document into the requirements management system, and the requirements management system can manage the requirements document according to the requirements management system format. The user can also write a requirements document in the requirements management system according to the test requirements for testing the software product and the requirements management system format.
[0105] The requirements management system format, or the business requirements information format, can be constructed according to the unified modeling language (UML) modeling method, as Figure 5 shown. By Figure 5It can be seen that the business requirement information may include the business process path and the global requirement information. Specifically, the business process path may include the information on the execution process steps of the business. In practical applications, when a business is developed, the process steps that most users are expected to follow in the future are often set. However, in reality, it is impossible to control the behavior of users. Users have their own choices. In addition, exceptions or validations may also occur in the business system itself. Therefore, the business process path may include a basic path and an extended path. Among them, the basic path may include the main process steps of the business, also known as basic steps, which are generally the process steps used by most users when the business is developed. The extended path may include the process steps other than the main process steps, also known as extended steps. Generally, the basic path and the extended path may include the steps associated with the business constraint conditions in the global requirement information. The business constraint conditions may also be referred to as business rules.
[0106] The global requirement information may include the data required during the execution of the target business other than the business process path. Specifically, the global requirement data may at least include one of the following: business constraint conditions, preconditions, postconditions, executors, and stakeholder interests. Among them, the business constraint conditions may include the constraint condition information of the target business. Specifically, the business constraint conditions may at least include one of the following: business rules, field lists, design constraints, and non-functional requirements. Business rules may include business parameter rules and business processing rules. The parameter verification rule refers to the rule required when parameter information is involved in the implementation process of the target business. The business processing rule may refer to the rule that needs to be followed in the relevant business processing process. The field list may refer to the defined fields that need to be input or output during the implementation process of the target business. For example, in the use case of successful payment, the order amount entered by the user is the field list. The design constraint may refer to various interface forms designed for the product during the R & D process. For example, after a certain operation is performed on the product, what interface should be displayed. The non-functional requirement may refer to the discounts or other requirements of the developer for the product, such as quality requirements. The precondition may include the prerequisite conditions for the execution of the target business. The postcondition may include the conditions that need to be met after the execution of the target business. The executor may include the users of the target business. For example, in the business of paying with a bank card, the user is the main executor, and the bank payment system is the auxiliary executor. The stakeholder interest may include the benefit information during the execution of the target business.
[0107] It should be noted that in the embodiments of this application, the global requirement information is not limited to at least one of the above business constraint conditions, preconditions, postconditions, executors, and stakeholder interests. In practical applications, more data may also be included according to business requirements.
[0108] The requirements management system can configure the requirements information collection page according to the above requirements management system format, such as Figure 6 and Figure 7 shown. Among them, Figure 6 shows the path step page of the requirements document in the requirements management system, Figure 7 shows the business rule page of the requirements document in the requirements management system. Users can input requirements information through the Figure 6 and Figure 7 shown pages. The requirements management system generates a requirements description document based on the requirements information input by the user. In addition, in the requirements management system, the requirements document can also be modified, and the modification page can be as Figure 8 shown. For example, after the user inputs the requirements document into the requirements management system, the requirements information in the requirements document can be modified through the Figure 8 shown page, and the requirements management system generates a requirements description document based on the modified requirements document by the user. The user can also submit a newly added requirements document to the requirements management system, and the newly added requirements document page can be as Figure 9 shown.
[0109] The requirements management system is a typical management information system, and the complete information management cycle of the requirements management system can be as Figure 10 shown. In Figure 10 , when the user needs to add a new requirements document in the requirements management system, the user can first trigger the Alt (switch) button in the requirements management system to switch to adding new requirements, and then upload the requirements document to the requirements management system. The requirements management system can parse and process the requirements document, and report the new corpus in the requirements document to the feature library system. After the requirements management system parses and processes the requirements document, it can further convert the requirements document into a structured requirements document, thus completing the addition of a new requirements document in the requirements management system. When the user needs to query the requirements document in the requirements management system, the user can first trigger the Alt button in the requirements management system to switch from adding new requirements to querying requirements. After the requirements management system receives the query requirements, it can process the corresponding query request and return the data to be queried to the user, and the user can view the returned data to be queried in the requirements management system. When the user needs to modify the requirements document in the requirements management system, the user can first trigger the Alt button in the requirements management system to switch from querying requirements to modifying requirements. After the requirements management system receives the modification requirements, it can process the corresponding modification request, and after the user modifies the requirements document, it can report the new corpus in the modified requirements document to the feature library system, and receive the modified requirements document, thus completing the modification of the requirements document in the requirements management system.
[0110] After obtaining the requirements document in the requirements management system, the requirements management system can further convert the requirements document into a semi-structured natural language description requirements document in JSON format, as shown in Figure 11 The semi-structured natural language description requirements document in JSON format is the required requirements description document.
[0111] Step S402: Use the business steps in the requirements description document as graph nodes, and determine the direction between the corresponding two graph nodes according to the logical relationship between every two business steps, to obtain a directed relationship graph.
[0112] After obtaining the requirements description document through the requirements management system, the requirements description document can be input into the legality check system. The legality check system can construct a corresponding directed information graph according to the requirements description document. The noun concept table for constructing the directed information graph can be as shown in Table 1:
[0113] Table 1
[0114]
[0115]
[0116] Since the business steps in the requirements description document can include basic steps and extended steps, the basic steps and extended steps in the requirements description document can be used as graph nodes, and the direction between the corresponding two graph nodes is determined according to the logical relationship between every two business steps, to obtain a directed relationship graph. For example, Figure 6 "1. The user submits payment information and requests payment" in
[0117] can be a basic step, so this basic step 1 can be used as graph node 1, and "1a. The user cancels the payment" can be an extended step, so this extended step 1a can be used as graph node 1a. When the next business step of the business step "1. The user submits payment information and requests payment" is "1a. The user cancels the payment", there is a directed edge between graph node 1 and graph node 1a, and it points from graph node 1 to graph node 1a.
[0118] Step S403: According to the requirements description document, add associated natural language information to each graph node in the directed relationship graph, to obtain a directed information graph corresponding to the requirements description document.
[0119] Natural language information may include node description information and business rule information. Then, according to the description information of each business step, the associated node description information can be added to the corresponding graph node, and according to the business rules of the business steps in the requirements description document, the associated business rule information can be added to the corresponding graph node in the directed graph, and then the directed information graph corresponding to the requirements description document can be obtained. For example, the description information of business step 1 is "The user submits payment information and requests payment", then the node description information of the corresponding graph node 1 is also "The user submits payment information and requests payment". When the business rule of business step 1 in the requirements description document is the business rule as shown in Figure 7 then the business rule information associated with graph node 1 is the business rule shown in Figure 7 . Finally, according to the directed graph and the node description information and business rule information associated with each graph node in the directed graph, the directed information graph corresponding to the requirements description document can be obtained.
[0120] Business rules are usually presented in the form of a table, and the specific business rule types can be as shown in Table 2:
[0121] Table 2
[0122]
[0123]
[0124] Step S404, traverse each graph node based on the direction between every two graph nodes in the directed information graph, and respectively perform a legality check on the natural language information associated with each graph node in the requirements description document.
[0125] After the legality check system constructs the corresponding directed information graph according to the requirements description document, it can use the DFS method or the BFS method to traverse each graph node based on the direction between every two graph nodes in the directed information graph, and respectively perform a legality check on the description method of the natural language information associated with each graph node. If there are graph nodes that fail the check, it can be determined that the check result is "check failed"; if there are no graph nodes that fail the check, it can be determined that the check result is "check passed".
[0126] In one embodiment, when performing a legality check on the description method of the natural language information associated with each graph node, a legality check can be performed on the node description information associated with each graph node. For each graph node, the following operations are respectively performed: match the node description information associated with one graph node in each graph node with the illegal description information rules. If the match is successful, it is determined that the graph node fails the check. And the illegal description information rules can include at least one of the following: half-width punctuation marks, space characters at the beginning of each line of natural language information, space characters at the end of each line of natural language information, line break characters at the end of a single line of natural language information. For example, when performing a legality check on the punctuation marks in the node description information associated with each graph node, the node description information associated with each graph node can be matched with half-width punctuation marks. Thus, when a half-width punctuation mark appears in the node description information associated with a certain graph node, it can be considered that the natural language information associated with the graph node is illegal and the graph node fails the check.
[0127] In another embodiment, a legality check can be performed on the business rule information associated with each graph node. And the business rule information includes a business rule name, business rule description information, and a business rule processing method. For each graph node, the following operations are respectively performed: establish a reference tree corresponding to a graph node based on the business rule information of one graph node in each graph node. Each leaf node in the reference tree corresponds to a business rule in the business rule information of a graph node. Traverse each leaf node in the reference tree corresponding to a graph node, and respectively match the business rule corresponding to each leaf node with the illegal description information rules. If the match is successful, it is determined that the graph node corresponding to the leaf node fails the check.
[0128] In another embodiment, a legality check may be performed on the types of business rules included in the business rule information associated with each graph node. Reference trees corresponding to each graph node may be established respectively based on the business rule information associated with each graph node. Each leaf node in each reference tree corresponds to a business rule in the business rule information of the corresponding graph node, and the reference tree includes multiple leaf nodes. Traverse each leaf node in the reference trees corresponding to each graph node, and for each leaf node, perform the following operations respectively: Match the business rule description information of one leaf node among each leaf node with the business rule type. The business rule description information and the business rule type may be included in the business rule corresponding to one leaf node. If the match fails, it is determined that the graph node corresponding to this leaf node fails the check. For example, various business rule types may be marked first through enumerated parameters, and then the type marks corresponding to various business rule types in Table 2 can be obtained. That is, the type mark of the system verification induction judgment type rule is 1, the type mark of the verification error reporting type rule is 2, the type mark of the verification prompt type rule is 3, the type mark of the verification user selection type rule after verification is 4, the type mark of the system processing induction judgment type rule is 5, the type mark of the selection type rule is 6, the type mark of the record type rule is 7, the type mark of the calculation type rule is 8, the type mark of the system feedback induction judgment type rule is 9, and the type mark of the display feedback type rule is 10. If the type mark of the business rule type of leaf node 1 included in graph node 1 is 1, while the business rule type corresponding to the business rule description information of leaf node 1 included in graph node 1 should be the system processing induction judgment type rule, and the type mark of the business rule type of leaf node 1 included in graph node 1 is matched with the business rule description information, it can be determined that the business rule type of leaf node 1 included in graph node 1 does not match the business rule description information, and it can be considered that the natural language information associated with graph node 1 is illegal, and this graph node fails the check.
[0129] Step S405, determine whether the check result is a pass; if not, execute step S406; if so, execute step S407.
[0130] After performing a legality check on the natural language information associated with each graph node in the requirements description document, the legality check system can determine the check result. If there are graph nodes that fail the check, it can be determined that the check result is a fail; if there are no graph nodes that fail the check, it can be determined that the check result is a pass.
[0131] Step S406, output an error prompt message based on the natural language information associated with the graph node that fails the check.
[0132] When the inspection result is that the inspection fails, the legality inspection system can output an error prompt message based on the natural language information associated with the graph node that fails the inspection. Moreover, in response to a request to generate test cases based on the requirement description document modified according to the error prompt message, the legality of the natural language information in the modified requirement description document can be inspected.
[0133] Step S407, generate test cases according to the requirement description document.
[0134] When the inspection result is that the inspection passes, the legality inspection system can output a legal requirement description document. The feature library system can extract the corpus information of the requirement description document and determine the corpus features corresponding to the requirement description document according to the corpus information. The test case automatic generation system can generate test cases according to the legal requirement description document and the corpus features. The generated test cases can be as Figure 12 shown. The test cases are presented in the form of a table, with each row being a test case, and the table headers are: test case type, automation, test case name, preconditions, test case steps, and expected results.
[0135] In some other embodiments, it is also possible to first perform a legality inspection on the requirement document using the legality inspection system before the requirement management system converts the structured requirement document into a requirement description document. After the requirement document passes the legality inspection, the requirement management system then converts the requirement document that has passed the legality inspection into a requirement description document, and finally the test case automatic generation system generates test cases according to the requirement description document and the corpus features extracted by the feature library system.
[0136] Refer to Figure 13 shown. The following uses a specific application scenario to further elaborate on the above embodiments in detail:
[0137] Suppose the business steps of a requirement description document can be as Figure 14 shown. It can be Figure 14 seen that the requirement description document includes 6 business steps: basic step 1, basic step 2, basic step 3, basic step 4, extended step 2a, and extended step 2b. Only business step 1 in the requirement description document has business rules, and the business rules of business step 1 can be as Figure 15 shown.
[0138] Step S1301, regard the 6 business steps in the requirement description document as graph nodes, and determine the direction between the corresponding two graph nodes according to the logical relationship between every two business steps to obtain a directed relationship graph.
[0139] The 6 business steps, including 4 basic steps and 2 extended steps included in the requirements document, can all be used as graph nodes, and thus 6 corresponding graph nodes can be obtained. Then, based on the logical relationship between every two business steps, the direction between the corresponding two graph nodes can be determined to construct a directed relationship graph. The obtained directed relationship graph can be as shown in Figure 16 as shown, in Figure 16 , graph node S is a virtual starting graph node, and graph node E is a virtual ending graph node.
[0140] Step S1302: According to the description information of each business step, add associated node description information to the corresponding graph node.
[0141] Based on the description information of each of the 6 business steps included in the requirements description document, associated node description information can be added to the corresponding graph nodes in the directed relationship graph. For example, based on the description information of basic step 1, "The user submits payment information and requests payment", the associated node description information "The user submits payment information and requests payment" can be added to graph node 1.
[0142] Step S1303: According to the business rules in each business step, add associated business rule information to the corresponding graph node.
[0143] Based on the business rules of each of the 6 business steps included in the requirements description document, associated business rule information can be added to the corresponding graph nodes in the directed relationship graph. For example, based on the business rule shown in Figure 15 for basic step 1, the associated business rule information can be added to graph node 1.
[0144] Step S1304: Based on the node description information and business rule information associated with each graph node, obtain the directed information graph corresponding to the requirements description document.
[0145] Based on the node description information and business rule information associated with each graph node in the directed relationship graph, the directed information graph corresponding to the requirements description document can be obtained. This directed information graph can be as shown in Figure 17 as shown.
[0146] Step S1305: Traverse each graph node based on the direction between every two graph nodes in the directed information graph, and respectively perform a legality check on the natural language information associated with each graph node in the requirements description document.
[0147] The DFS method or the BFS method can be adopted to traverse each of the six graph nodes based on the directions between every two graph nodes in the directed information graph, and respectively perform a legality check on the description methods of the natural language information associated with each graph node. If there are graph nodes that fail the check, it can be determined that the check result is "failed". If there are no graph nodes that fail the check, it can be determined that the check result is "passed".
[0148] A legality check can be performed on the node description information associated with the six graph nodes, that is, the node description information associated with each of the six graph nodes is respectively matched with the illegal description information rules. If the match is successful, it is determined that the graph node fails the check. For example, Figure 17 when performing a legality check on the node description information "The user submits payment information and requests payment" associated with graph node 1 in
[0149] If the "," in "The user submits payment information and requests payment" is a half-width symbol, and the matching result of matching this node description information with the half-width symbol "," is successful, it can be determined that graph node 1 fails the check.
[0150] It is also possible to perform a legality check on the business rule types included in the business rule information associated with graph node 1. First, a reference tree corresponding to graph node 1 can be established based on the business rule information associated with graph node 1. Each leaf node in each reference tree corresponds to a business rule in the business rule information of graph node 1, and the reference tree can include multiple leaf nodes. Then, each leaf node in the reference tree corresponding to graph node 1 can be traversed, and for each leaf node, the following operations can be performed respectively: match the business rule description information of one of the leaf nodes with the business rule type. The business rule description information and the business rule type can be included in the business rule corresponding to a leaf node. If the business rule description information corresponding to at least one leaf node fails to match the business rule type, it can be determined that graph node 1 fails the check.
[0151] Step S1306, if the check result is passed, generate test cases according to the requirements description document.
[0152] When the check result is passed, test cases can be generated according to the requirements description document that has passed the legality check. When the check result is not passed, error prompt information can be output based on the natural language information associated with the graph node that fails the check, and in response to a request to generate test cases for the modified requirements description document, a legality check is performed on the natural language information in the modified requirements description document.
[0153] And Figure 2 The test case generation method shown is based on the same inventive concept. In an embodiment of the present application, a test case generation device is also provided. This test case generation device can be deployed in a server or a terminal device. Since this device is the device corresponding to the test case generation method of the present application, and the principle of this device to solve problems is similar to that of this method, the implementation of this device can refer to the implementation of the above method, and the repeated parts will not be described again.
[0154] Figure 18 shows a structural schematic diagram of a test case generation device provided by an embodiment of the present application, as Figure 18 shown, this test case generation device includes a document acquisition unit 1801, a directed graph construction unit 1802, a legality check unit 1803, and a test case generation unit 1804.
[0155] Among them, the document acquisition unit 1801 is used to acquire a preset requirements description document; the requirements description document includes at least each business step of the business to be tested and the logical relationship between each business step;
[0156] A directed graph construction unit 1802 is configured to construct a corresponding directed information graph according to a requirements description document. Each graph node in the directed information graph represents a business step, and the direction between every two graph nodes represents the logical order between the corresponding two business steps.
[0157] A legality check unit 1803 is configured to traverse each graph node based on the direction between every two graph nodes in the directed information graph, and respectively perform a legality check on the natural language information associated with each graph node in the requirements description document.
[0158] A test case generation unit 1804 is configured to generate test cases according to the requirements description document if the check result is passed.
[0159] In an optional embodiment, the legality check unit 1803 is further configured to:
[0160] If the check result is not passed, an error prompt message is output based on the natural language information associated with the graph node that fails the check.
[0161] In response to a request for generating test cases based on the modified requirements description document after the error prompt message, a legality check is performed on the natural language information in the modified requirements description document.
[0162] In an optional embodiment, the business steps include basic steps and extended steps. The directed graph construction unit 1802 is specifically configured to:
[0163] Both the basic steps and the extended steps are used as graph nodes, and the direction between the corresponding two graph nodes is determined according to the logical relationship between every two business steps, so as to obtain a directed relationship graph.
[0164] According to the requirements description document, associated natural language information is added to each graph node in the directed relationship graph to obtain a directed information graph corresponding to the requirements description document.
[0165] In an optional embodiment, the natural language information includes node description information and business rule information. The directed graph construction unit 1802 is further configured to:
[0166] According to the description information of each business step, associated node description information is added to the corresponding graph node.
[0167] According to the business rules in the requirements description document, associated business rule information is added to the graph nodes in the directed relationship graph.
[0168] In an optional embodiment, the legality check unit 1803 is specifically configured to:
[0169] Using the depth - first search method or the breadth - first search method, traverse each graph node based on the direction between every two graph nodes in the directed information graph;
[0170] Respectively perform a legality check on the description methods of the natural language information associated with each graph node; if there is a graph node that fails the check, determine that the check result is "check failed", and if there is no graph node that fails the check, determine that the check result is "check passed".
[0171] In an alternative embodiment, the legality check unit 1803 is further configured to:
[0172] For each graph node, respectively perform the following operations:
[0173] Match the natural language information associated with one graph node among each graph node with a preset illegal description information rule; the illegal description information rule includes at least one of the following: half - width punctuation marks, space characters at the beginning of each line of natural language information, space characters at the end of each line of natural language information, line - feed characters at the end of a single line of natural language information;
[0174] If the match is successful, determine that one graph node fails the check.
[0175] In an alternative embodiment, the natural language information includes node description information; the legality check unit 1803 is further configured to: match the node description information associated with one graph node with the illegal description information rule; or,
[0176] The natural language information includes business rule information; the legality check unit 1803 is further configured to: establish a reference tree corresponding to one graph node based on the business rule information of one graph node; each leaf node in the reference tree corresponds to a business rule in the business rule information of one graph node; traverse each leaf node in the reference tree corresponding to one graph node, and respectively match the business rule corresponding to each leaf node with the illegal description information rule.
[0177] In an alternative embodiment, the natural language information includes business rule information; the legality check unit 1803 is further configured to:
[0178] Respectively establish reference trees corresponding to each graph node based on the business rule information associated with each graph node; each leaf node in each reference tree respectively corresponds to a business rule in the business rule information of the corresponding graph node; the reference tree includes multiple leaf nodes; the business rule information includes business rule description information and business rule type;
[0179] Traverse each leaf node in the reference tree corresponding to each graph node, and for each leaf node, respectively perform the following operations:
[0180] Match the business rule description information of one leaf node among each leaf node with the business rule type; the business rule description information and the business rule type are included in the business rule corresponding to one leaf node;
[0181] If the matching fails, it is determined that the graph node corresponding to one leaf node fails the check.
[0182] In an optional embodiment, the test case generation unit 1804 is specifically configured to:
[0183] Extract the corpus information of the requirement description document, and determine the corpus features corresponding to the requirement description document according to the corpus information;
[0184] Generate test cases according to the corpus features and the requirement description document.
[0185] Based on the same inventive concept as the above method embodiments and apparatus embodiments, an electronic device is further provided in the embodiments of the present application. The electronic device may be a server, such as Figure 1 the server 100 shown. In this embodiment, the structure of the electronic device may be as Figure 19 shown, including a memory 1901, a communication module 1903, and one or more processors 1902.
[0186] The memory 1901 is used to store the computer program executed by the processor 1902. The memory 1901 may mainly include a program storage area and a data storage area. Among them, the program storage area may store an operating system and programs required to run the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0187] The memory 1901 may be a volatile memory, such as a random-access memory (RAM); the memory 1901 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD), or the memory 1901 is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 1901 may be a combination of the above memories.
[0188] The processor 1902 may include one or more central processing units (CPUs) or be a digital processing unit, etc. The processor 1902 is used to implement the above test case generation method when calling the computer program stored in the memory 1901.
[0189] The communication module 1903 is used to communicate with the terminal device and other electronic devices. If the electronic device is a server, the server can receive the requirement description document sent by the terminal device through the communication module 1903.
[0190] In the embodiments of the present application, the specific connection medium between the above-mentioned memory 1901, communication module 1903 and processor 1902 is not limited. In the embodiments of the present disclosure Figure 19 it is shown that the memory 1901 and the processor 1902 are connected through a bus 1904. The bus 1904 is represented by a thick line in Figure 19 The connection manners between other components are only for illustrative purposes and are not to be construed as limiting. The bus 1904 can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 19 only a thick line is used to represent it in, but it does not mean that there is only one bus or one type of bus.
[0191] In another embodiment, the electronic device can also be a tablet computer, a desktop computer, a laptop computer, etc.
[0192] According to one aspect of the present application, there is provided a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the test case generation method in the above embodiments. The program product can adopt any combination of one or more readable media. The readable media can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0193] As described above, it is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of changes or substitutions, which should all be covered within the protection scope of the present application.
Claims
1. A test case generation method, characterized in that, The method includes: Obtaining a preset requirement description document; the requirement description document at least includes each business step of the business to be tested and the logical relationship between each business step; Constructing a corresponding directed information graph according to the requirement description document; wherein, each graph node in the directed information graph represents a business step, and the direction between every two graph nodes represents the logical order between the corresponding two business steps; Traversing each graph node based on the direction between every two graph nodes in the directed information graph, and respectively performing a legality check on the description manner of the natural language information associated with each graph node in the requirement description document. If the check result is passed, generating test cases according to the requirement description document; wherein, when the natural language information includes business rule information, the legality check includes: Respectively establishing a reference tree corresponding to each graph node based on the business rule information associated with each graph node; each leaf node in each reference tree respectively corresponds to a business rule in the business rule information of the corresponding graph node; the reference tree includes multiple leaf nodes; the business rule information includes business rule description information and business rule type; Traversing each leaf node in the reference tree corresponding to each graph node, and for each leaf node, respectively performing the following operations: matching the business rule description information of one leaf node among the leaf nodes with the business rule type; the business rule description information and the business rule type are included in the business rule corresponding to the one leaf node; if the matching fails, determining that the graph node corresponding to the one leaf node fails the check.
2. The method according to claim 1, wherein The method further includes: If the check result is that the check fails, outputting an error prompt message based on the natural language information associated with the graph node that fails the check; In response to a request for generating test cases for the modified requirement description document, performing a legality check on the natural language information in the modified requirement description document.
3. The method according to claim 1, characterized in that, The business step includes a basic step and an extended step; the constructing a corresponding directed information graph according to the requirement description document includes: Regarding both the basic step and the extended step as graph nodes, and determining the direction between the corresponding two graph nodes according to the logical relationship between every two business steps, to obtain a directed relationship graph; According to the requirement description document, adding associated natural language information to each graph node in the directed relationship graph, to obtain the directed information graph corresponding to the requirement description document.
4. The method according to claim 3, wherein The natural language information includes node description information and business rule information; the adding associated natural language information to each graph node in the directed relationship graph according to the requirement description document includes: Adding associated node description information to the corresponding graph node according to the description information of each business step; Adding associated business rule information to the graph nodes in the directed relationship graph according to the business rules in the requirement description document.
5. The method according to claim 1 or 2, characterized in that Traverse each graph node based on the direction between every two graph nodes in the directed information graph, and respectively perform a legality check on the description method of the natural language information associated with each graph node in the requirement description document, including: Adopt a depth-first search method or a breadth-first search method to traverse each graph node based on the direction between every two graph nodes in the directed information graph; Respectively perform a legality check on the description method of the natural language information associated with each graph node; if there is a graph node that fails the check, determine that the check result is a failed check, and if there is no graph node that fails the check, determine that the check result is a passed check.
6. The method according to claim 5, characterized in that, The respectively performing a legality check on the description method of the natural language information associated with each graph node includes: For each graph node, respectively perform the following operations: Match the natural language information associated with one of the graph nodes with a preset illegal description information rule; the illegal description information rule includes at least one of the following: half-width punctuation marks, space characters at the beginning of each line of natural language information, space characters at the end of each line of natural language information, line break characters at the end of a single line of natural language information; If the match is successful, determine that the one graph node fails the check.
7. The method according to claim 6, wherein The natural language information includes node description information; the matching of the natural language information associated with the one graph node with the illegal description information rule includes: matching the node description information associated with the one graph node with the illegal description information rule; or, The natural language information includes business rule information; the matching of the natural language information associated with the one graph node with the illegal description information rule includes: establishing a reference tree corresponding to the one graph node based on the business rule information of the one graph node; each leaf node in the reference tree corresponds to a business rule in the business rule information of the one graph node; traverse each leaf node in the reference tree corresponding to the one graph node, and respectively match the business rules corresponding to the respective leaf nodes with the illegal description information rule.
8. The method according to any one of claims 1 to 4, 6 to 7, characterized in that The generating test cases according to the requirement description document includes: Extract the corpus information of the requirement description document, and determine the corpus features corresponding to the requirement description document according to the corpus information; Generate test cases according to the corpus features and the requirement description document.
9. A test case generation device, characterized in that, Including: A document acquisition unit for acquiring a preset requirement description document; The requirement description document at least includes each business step of the business to be tested and the logical relationship between each business step; A directed graph construction unit for constructing a corresponding directed information graph according to the requirement description document; wherein, each graph node in the directed information graph represents a business step, and the direction between every two graph nodes represents the logical order between the corresponding two business steps; A legality check unit for traversing each graph node based on the direction between every two graph nodes in the directed information graph, and respectively performing a legality check on the description method of the natural language information associated with each graph node in the requirement description document; wherein, when the natural language information includes business rule information, the legality check includes: Respectively establishing a reference tree corresponding to each graph node based on the business rule information associated with each graph node; each leaf node in each reference tree respectively corresponds to a business rule in the business rule information of the corresponding graph node; the reference tree includes a plurality of leaf nodes; the business rule information includes business rule description information and business rule type; Traversing each leaf node in the reference tree corresponding to each graph node, and for each leaf node, respectively performing the following operations: matching the business rule description information of one leaf node among the leaf nodes with the business rule type; the business rule description information and the business rule type are included in the business rule corresponding to the one leaf node; if the matching fails, it is determined that the graph node corresponding to the one leaf node fails the check; A test case generation unit for generating test cases according to the requirement description document if the check result is that the check passes.
10. The device according to claim 9, characterized in that, The legality check unit is further configured to: If the check result is that the check fails, output an error prompt message based on the natural language information associated with the graph node that fails the check; In response to a request for generating test cases for the modified requirement description document, perform a legality check on the natural language information in the modified requirement description document.
11. The device according to claim 9, wherein The business steps include basic steps and extended steps; the directed graph construction unit is specifically configured to: Taking both the basic steps and the extended steps as graph nodes, and determining the direction between the corresponding two graph nodes according to the logical relationship between every two business steps, to obtain a directed relationship graph; According to the requirement description document, adding associated natural language information to each graph node in the directed relationship graph to obtain the directed information graph corresponding to the requirement description document.
12. The device according to claim 11, wherein The natural language information includes node description information and business rule information; the directed graph construction unit is further configured to: Adding associated node description information to the corresponding graph node according to the description information of each business step; Adding associated business rule information to the graph nodes in the directed relationship graph according to the business rules in the requirement description document.
13. A computer-readable storage medium storing a computer program therein, characterized in that: When the computer program is executed by a processor, the method described in any one of claims 1 to 8 is implemented.
14. An electronic device, characterized in that, Comprising a memory and a processor, with a computer program stored on the memory that can run on the processor, and when the computer program is executed by the processor, the method described in any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Test case generation method, device and server
CN109117363A
Document improperness detection program, document improperness detector, and document improperness detection method
JP2018010349A