CN113590453A - Test case generation method and device and storage medium - Google Patents

Test case generation method and device and storage medium Download PDF

Info

Publication number
CN113590453A
CN113590453A CN202110120346.5A CN202110120346A CN113590453A CN 113590453 A CN113590453 A CN 113590453A CN 202110120346 A CN202110120346 A CN 202110120346A CN 113590453 A CN113590453 A CN 113590453A
Authority
CN
China
Prior art keywords
directed graph
demand data
information
data
business rule
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110120346.5A
Other languages
Chinese (zh)
Inventor
郑睿莘
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110120346.5A priority Critical patent/CN113590453A/en
Publication of CN113590453A publication Critical patent/CN113590453A/en
Pending legal-status Critical Current

Links

Images

Classifications

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

Abstract

The embodiment of the application provides a method, a device and a storage medium for generating a test case, wherein the method comprises the following steps: acquiring demand data and first information contained in the demand data, wherein the first information comprises one or both of step information and business rule information; constructing a directed graph of the required data according to the first information; carrying out validity check on the directed graph of the demand data to obtain valid demand data; and generating a test case based on legal requirement data. The validity of the demand data is checked by checking the validity of the directed graph of the demand data, so that the validity of the demand data generated by the test case is effectively guaranteed. In addition, according to the method and the device, manual inspection is not needed, the legality of the demand data is automatically inspected through the directed graph of the demand data, the labor cost is greatly saved, the inspection accuracy is high, and the reliability of the test case is guaranteed.

Description

Test case generation method and device and storage medium
Technical Field
The embodiment of the application relates to the technical field of software testing, in particular to a method and a device for generating a test case and a storage medium.
Background
With the rapid development of internet technology, various software products enter people's daily life. Before the software product is released, the software product needs to be tested to check whether the software product can implement the intended functionality.
Current software product testing procedures typically include: writing a requirement document, processing the requirement document to obtain a test case, and testing the software product by using the test case. Since the requirement document is usually written manually, there may be errors, and therefore, it is necessary to check the validity of the requirement document.
At present, the legality of a required document is checked manually, the workload is large, the checking efficiency is low, and the checking is inaccurate.
Disclosure of Invention
The embodiment of the application provides a method and a device for generating a test case and a storage medium, which are used for checking the legality of required data so as to improve the generation efficiency of the test case.
In a first aspect, an embodiment of the present application provides a method for generating a test case, including:
acquiring demand data and first information contained in the demand data, wherein the first information comprises one or both of step information and business rule information;
constructing a directed graph of the demand data according to the first information;
carrying out validity check on the directed graph of the demand data to obtain valid demand data;
and generating a test case based on legal requirement data.
In a second aspect, an embodiment of the present application provides an apparatus for generating a test case, including:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring demand data and first information contained in the demand data, and the first information comprises one or both of step information and business rule information;
the construction unit is used for constructing a directed graph of the demand data according to the first information;
the checking unit is used for checking the legality of the directed graph of the required data to obtain legal required data;
and the generating unit is used for generating the test case based on the legal requirement data.
In a possible implementation manner of the second aspect, the first information includes step information, and the construction unit is specifically configured to construct a step directed graph of the demand data according to the step information included in the demand data.
For example, the constructing unit is specifically configured to construct the step directed graph of the demand data by using the steps in the step information as nodes of the directed graph and using the sequence relationship among the steps in the step information as edges of the directed graph.
In a possible implementation manner of the second aspect, the first information includes business rule information, and the construction unit is specifically configured to obtain the first business rule information associated with each step from the business rule information included in the demand data; and constructing a business rule directed graph corresponding to each step according to the first business rule information associated with each step.
In an example, the constructing unit is specifically configured to construct the directed graph of the business rules corresponding to the step according to a reference relationship between the first business rules in the first business rule information associated with the step.
For example, the building unit is specifically configured to determine, according to a reference relationship between the first business rules in the first business rule information associated in the step, a second business rule whose number of times of reference in each first business rule is 0; and taking the second business rule as a starting point of the directed graph, the first business rule as a node of the directed graph, and the reference relation between the first business rules as an edge of the directed graph, and constructing the business rule directed graph corresponding to the step.
In a possible implementation manner of the second aspect, if the directed graph of the demand data includes a step directed graph, the checking unit is specifically configured to check whether each step in the step directed graph belongs to the demand data; and if all the steps in the directed graph in the checking step belong to the required data, determining that the step node of the required data is checked to be legal.
In a possible implementation manner of the second aspect, if the directed graph of the demand data includes a step directed graph, the checking unit is specifically configured to obtain each turn link in the step directed graph according to a turn to which each step in the step directed graph of the demand data belongs; checking whether each round link is single-chain; and if the links in each round are checked to be single chains, determining that the round check of the demand data is legal.
In a possible implementation manner of the second aspect, the checking unit is further configured to determine that the demand data is illegal if the checking round link does not point to a next round link and does not point to a step of case ending.
In a possible implementation manner of the second aspect, if the directed graph of the demand data includes a business rule directed graph, the checking unit is specifically configured to check whether each business rule in the business rule directed graph belongs to the demand data; and if all the service rules in the service rule directed graph are checked to belong to the required data, determining that the service rule node of the required data is legal to check.
In a possible implementation manner of the second aspect, if the directed graph of the demand data includes a business rule directed graph, the checking unit is specifically configured to check whether the business rule directed graph is a loopback; and if the checking that the business rule directed graph is not a loop, determining that the loop check of the required data is legal.
In a possible implementation manner of the second aspect, the checking unit is further configured to check whether a node next to the current node exists in the demand data in a process of constructing a directed graph of the demand data according to the first information; and if the next node is detected to exist in the required data, taking the next node as the node of the directed graph.
In a possible implementation manner of the second aspect, the checking unit is further configured to display the warning information if it is determined that the next node does not exist in the demand data.
In a possible implementation manner of the second aspect, if the requirement data is a semi-structured requirement document based on a natural language, the obtaining unit is specifically configured to analyze the semi-structured requirement document based on the natural language to obtain structured requirement data; first information included in the structured demand data is obtained.
In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory;
the memory for storing a computer program;
the processor is configured to execute the computer program to implement the method for generating a test case according to the first aspect.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where the storage medium includes computer instructions, and when the instructions are executed by a computer, the computer is enabled to implement the method for generating a test case according to the first aspect.
In a fifth aspect, the present application provides a computer program product, where the program product includes a computer program, where the computer program is stored in a readable storage medium, and at least one processor of a computer can read the computer program from the readable storage medium, and the at least one processor executes the computer program to make the computer implement the method for generating a test case according to the first aspect.
According to the method, the device and the storage medium for generating the test case, the requirement data and the first information contained in the requirement data are acquired, wherein the first information comprises one or both of step information and business rule information; constructing a directed graph of the required data according to the first information; carrying out validity check on the directed graph of the demand data to obtain valid demand data; and generating a test case based on legal requirement data. According to the method and the device, the legality of the directed graph of the demand data is checked, so that the legality of the demand data is checked, the legality of the demand data for generating the test cases is effectively guaranteed, and the stability and the high efficiency of a test case generation mechanism are guaranteed. In addition, according to the method and the device, manual inspection is not needed, the legality of the demand data is automatically inspected through the directed graph of the demand data, the labor cost is greatly saved, the inspection accuracy is high, and the reliability of the generated test case is guaranteed.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic view of an application scenario according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a method for generating a test case according to an embodiment of the present application;
FIG. 3 is a diagram illustrating a relationship between requirement data and test cases;
fig. 4 is a schematic flowchart of a method for generating a test case according to an embodiment of the present application;
FIG. 5A is a diagram illustrating the relationship between steps included in the step information;
FIG. 5B is a step directed graph;
FIG. 6 is another schematic flow chart diagram of a method for generating a test case according to an embodiment of the present application;
FIG. 7A is a business rule directed graph;
FIG. 7B is another business rule directed graph;
FIG. 8 is another schematic flow chart diagram illustrating a method for generating test cases according to an embodiment of the present application;
FIG. 9 is a diagram of an overall architecture for validity checking according to an embodiment of the present application;
FIG. 10A is a schematic diagram of a path step in a demand management system;
FIG. 10B is a schematic diagram of business rules in a demand management system;
FIG. 10C is a schematic diagram illustrating the editing of business rules in a demand management system;
FIG. 10D is a diagram illustrating the entry of a new demand document in the demand management system;
FIG. 11 is a block diagram illustrating an overall architecture of test case generation according to an embodiment of the present application;
FIG. 12 is a timing diagram of a demand management system according to an embodiment of the present application;
fig. 13 is a schematic structural diagram of a device for generating test cases according to an embodiment of the present application
Fig. 14 is a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
It should be understood that, in the present embodiment, "B corresponding to a" means that B is associated with a. In one implementation, B may be determined from a. It should also be understood that determining B from a does not mean determining B from a alone, but may be determined from a and/or other information.
In the description of the present application, "plurality" means two or more than two unless otherwise specified.
In addition, in order to facilitate clear description of technical solutions of the embodiments of the present application, in the embodiments of the present application, terms such as "first" and "second" are used to distinguish the same items or similar items having substantially the same functions and actions. Those skilled in the art will appreciate that the terms "first," "second," etc. do not denote any order or quantity, nor do the terms "first," "second," etc. denote any order or importance.
The embodiment of the application is applied to the technical field of software testing, and particularly applied to the legality check of the requirement data, so that the test case can be stably and efficiently generated according to the legal requirement data.
In order to facilitate understanding of the embodiments of the present application, the related concepts related to the embodiments of the present application are first briefly described as follows:
defects in a software product generally refer to errors that exist in the software product, and are sometimes referred to as "errors," "BUGs," and the like. By executing the test cases, some or all of the defects in a software product can be discovered. Whether defects can be found as much as possible or not can be found in a limited time, which depends on the design and screening of the test cases.
The test requirement generally refers to the content to be tested, for example, whether a certain function is embodied in a software product or not.
The requirements document generally refers to test requirements content written in natural language.
Unified Modeling Language (UML) Modeling: a modeling language refers to a model for building an entire system by using model elements, wherein the model elements comprise classes in the system, associations between the classes, and instances of the classes, and the classes are matched with each other to realize dynamic behaviors of the system.
Model based testing (Model based testing, MBT): a model-based test belongs to a test method in the field of software test.
Directed graph: the graph theory concept is a graph consisting of a set of vertices and a set of directed edges connecting ordered pairs of vertices, i.e., pointing from one vertex to another vertex of an edge.
And (3) traversing the directed graph: the graph theory concept refers to that all the vertices in the directed graph are visited once and only once along the edges in the graph according to a certain search method from a certain vertex in the directed graph. Common traversal algorithms are depth-first search (DFS) and breadth-first search (BFS).
Fig. 1 is a schematic view of an application scenario according to an embodiment of the present application, and includes a terminal device 10 and a server 20.
Before testing the software product, a user understands and combs the requirement function of the software product, describes the requirement function of the software product by using a natural language and writes a requirement document. The user may upload the composed requirement document to the terminal device 10.
In one example, the terminal device 10 may process the requirement document to obtain a test case.
In one example, the terminal device 10 may process the requirement document to obtain the structured requirement data, and then send the structured requirement data to the server 20. The server 20 generates a test case according to the structured demand data.
In one example, as shown in fig. 1, the terminal device 10 uploads the obtained requirement document to the server 20, and the server 20 processes the requirement document to obtain a test case.
In the embodiment of the present application, a server 20 is taken as an execution subject to process a requirement document, and a test case is obtained as an example for explanation. Specifically, the server 20 may parse the requirement document and convert the semi-structured test requirement document based on natural language into structured requirement data, that is, convert the requirement document into data convenient for being structurally processed by the computer. Then, semantic analysis is performed on the structured demand data, and people-related benefits, preconditions, postconditions, path steps, supplementary constraints and the like contained in the structured demand data can be identified. Then, according to the content included in the structured demand data, the path steps and the business rule information associated with each step are determined, wherein the business rule information can be understood as business constraint information. And finally, automatically generating a test case according to the path steps and the business rule information associated with each step.
In some embodiments, after the server 20 generates the test case, the generated test case may be sent to the terminal device 10 for displaying on the terminal device 10. In one example, the terminal device 10 may summarize the test cases sent by the server 20, and present the test cases on a display screen in a table form for the user to view.
The terminal device 10 may include a mobile phone, a tablet computer, a notebook computer, a palm computer, a Mobile Internet Device (MID), or other terminal devices with a browser installation function.
The server 20 may be a rack server, a blade server, a tower server, or a rack server. The server 20 may be an independent test server or a test server cluster composed of a plurality of test servers.
In this embodiment, the server 20 is connected to the terminal device 10 via a network. The network may be a wireless or wired network such as an Intranet (Intranet), the Internet (Internet), a Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth (Bluetooth), Wi-Fi, or a communication network.
It should be noted that fig. 1 exemplarily shows a schematic diagram of an application scenario of the present application, which includes but is not limited to that shown in fig. 1.
The technical solutions of the embodiments of the present application are described in detail below with reference to some embodiments. The following several embodiments may be combined with each other and may not be described in detail in some embodiments for the same or similar concepts or processes.
Example one
Fig. 2 is a schematic flow diagram of a method for generating a test case according to an embodiment of the present application, and as shown in fig. 2, the method includes:
s201, acquiring requirement data and first information contained in the requirement data, wherein the first information comprises one or both of step information and business rule information.
The execution subject of the embodiment of the present application is a test case generation apparatus, which is hereinafter referred to as a generation apparatus for short, and the generation apparatus may include the terminal device 10 located at the front end and the server 20 located at the back end shown in fig. 1.
In some embodiments, the upload requirement data may be structured requirement data. For example, the user uploads a semi-structured requirement document based on natural language to another device 1 having a parsing function, and the device 1 is connected to the generation device of the present application through a network. The apparatus 1 may convert the natural language based requirement document into structured requirement data and transmit the structured requirement data to the generating means.
In some embodiments, the requirement data is a semi-structured requirement document based on a natural language, and at this time, after the generating device obtains the semi-structured requirement document based on the natural language, the generating device parses the semi-structured requirement document based on the natural language to obtain the structured requirement data. For example, a user may upload a demand document described in a natural language on a web browser of the generating device, and after the user uploads the demand document successfully, the generating device may acquire the demand document uploaded by the user, parse the demand document, and convert the parsed demand document into structured demand data. That is, the application converts unstructured data in the requirement document into structured data for storage in a database or structured processing by a computer. The unstructured data refers to data stored in various file forms, the file content cannot be directly known usually, and the data can be opened and browsed only through corresponding tools. The structured data refers to a certain structural element which can be divided into fixed basic elements, and the structured data can be stored in a relational database and has a certain logical structure.
Optionally, after the requirement document is analyzed, the format of the test requirement document and the legality of the grammar can be checked, and the test requirement document qualified in grammar check is converted into structured requirement data.
In some embodiments, the present application may take the Form of Backus-Naur Form (BNF), which is a formal grammar representation used to describe a formal system of grammars, to write the requirement document. The BNF paradigm has a fixed syntax structure, so before converting a test requirement document written according to the BNF paradigm into structured requirement data, it is necessary to check whether the syntax of the text data in the test requirement document conforms to the syntax structure of the BNF paradigm, i.e. to check the validity of the syntax. When the text information with illegal grammar is detected to exist in the test requirement document, a prompt window can be popped up on a browser of the terminal equipment to remind a user of uploading the modified test requirement document again. When the grammatical structures of all text data in the test requirement document conform to the grammatical structures of the BNF paradigm, the test requirement document written according to the BNF paradigm can be converted into structured requirement data.
Optionally, the structured demand data may be entered into a database, so that a user may perform operations such as querying and modifying.
The structured demand data includes step information, business rule information, and the like. The generating device may analyze the structured demand data described using the natural language using a Neuro-Linguistic Programming (NLP) technique such as automatic word segmentation, part-of-speech analysis, syntactic analysis, and semantic analysis, and recognize step information, business rules, and other information in the structured demand data.
In one example, the first information includes step information included in the demand data.
In one example, the first information includes business rule information included in the demand data.
In one example, the first information includes step information and business rule information included in the demand data.
S202, constructing a directed graph of the demand data according to the first information.
In this step, a directed graph of the demand data is constructed according to the first information, and the manner of constructing the directed graph of the demand data is different according to different contents included in the first information.
In one example, the first information includes step information, and a directed graph of the demand data is constructed according to the step information. For example, the steps in the step information are used as nodes of the directed graph, the sequence relation among the steps in the step information is used as an edge of the directed graph, and the step directed graph of the required data is constructed.
In one example, the first information includes business rule information, and a directed graph of the demand data is constructed according to the business rule information. For example, each service rule in the service rule information is taken as a node of the directed graph, and the reference relationship between the service rules is taken as an edge of the directed graph, so that the directed graph of the required data is constructed.
In one example, the first information includes step information and business rule information, a step directed graph of the demand data is constructed according to the step information, a business rule directed graph of the demand data is constructed according to the business rule information, and the step directed graph of the demand data and the business rule directed graph of the demand data form a directed graph when demand is required.
And S203, carrying out validity check on the directed graph of the demand data to obtain valid demand data.
The method and the device for checking the validity of the directed graph of the demand data detect whether the directed graph meets the actual situation or not, and do not enter endless loop and the like. If the directed graph of the demand data is checked to be legal, the demand data is determined to be legal, and the following step S204 is continuously executed to generate a test case based on the legal demand data. If the directed graph of the required data is determined to be illegal when the directed graph of the required data is checked to be illegal, the following step S204 is not executed, and further illegal required data is prevented from being sent to the test case generation system to generate wrong test cases.
Optionally, when the demand data is checked to be illegal, a reminding message may be sent to the user, for example, a reminding frame is displayed on the terminal device to remind the user to modify the demand data or upload the demand data from a new place.
According to the method and the device, the legality of the directed graph of the demand data is checked, so that the legality of the demand data is checked, the legality of the demand data generated by the use case test case is effectively guaranteed, and the stability and the high efficiency of a test case generation mechanism are guaranteed. In addition, according to the method and the device, manual inspection is not needed, the legality of the demand data is automatically inspected through the directed graph of the demand data, the labor cost is greatly saved, and the inspection accuracy is high.
In some embodiments, a user may set different checking logics according to the characteristics of the structured information and the service requirements, so as to perform validity checking on the directed graph of the required data.
Exemplary, the checking logic set by the user may include: one or more of a node check, a round check, and a loop check.
The node check may be used to check the step directed graph and the service rule directed graph, for example, to check whether nodes in the step directed graph and the service rule directed graph exist in the required data, and if the nodes do not exist in the required data, it is determined that the required data is illegal.
The round check is used for checking the step directed graph, for example, checking whether the round in the step directed graph meets the round requirement, for example, judging whether the round is a single chain, and if the round is not the single chain, determining that the demand data is illegal.
The loopback is used for checking the business rule directed graph, for example, checking whether the business rule directed graph is a loopback, and if the business rule directed graph is a loopback, determining that the required data is illegal.
The method and the device can also collect other checking logics to check the legality of the demand data, and are specifically determined according to actual demands.
The method and the device for checking the validity of the directed graph of the demand data detect whether the directed graph meets the actual situation or not, and do not enter endless loop and the like. If the directed graph of the demand data is checked to be legal, the demand data is determined to be legal, and the following step S204 is continuously executed to generate a test case based on the legal demand data. If the directed graph of the required data is determined to be illegal when the directed graph of the required data is checked to be illegal, the following step S204 is not executed, and further illegal required data is prevented from being sent to the test case generation system to generate wrong test cases.
Optionally, when the demand data is checked to be illegal, a reminding message may be sent to the user, for example, a reminding frame is displayed on the terminal device to remind the user to modify the demand data or upload the demand data from a new place.
According to the method and the device, the legality of the directed graph of the demand data is checked, so that the legality of the demand data is checked, the legality of the demand data generated by the use case test case is effectively guaranteed, and the stability and the high efficiency of a test case generation mechanism are guaranteed. In addition, according to the method and the device, manual inspection is not needed, the legality of the demand data is automatically inspected through the directed graph of the demand data, the labor cost is greatly saved, and the inspection accuracy is high.
In some embodiments, a user may set different checking logics according to the characteristics of the structured information and the service requirements, so as to perform validity checking on the directed graph of the required data.
Exemplary, the checking logic set by the user may include: one or more of a node check, a round check and a loopback check, wherein the node check can be used for checking the step directed graph and the business rule directed graph, the round check is used for checking the step directed graph, and the loopback is used for checking the business rule directed graph.
And S204, generating a test case based on legal requirement data.
FIG. 3 is a diagram illustrating a relationship between requirement data and test cases, and as shown in FIG. 3, the generation of the test cases depends on descriptions in the requirement data, wherein the most important data for the generation of the test cases includes a basic path, an extended path, a precondition, a postcondition, and a business rule and a field list in a supplemental constraint.
The precondition may be a condition that should be satisfied to start the use case.
The post condition may refer to what operation needs to be performed after the use case is completed, such as an account restore.
The basic path may refer to the steps that the use case completes at the trigger event to the target.
The extension path may refer to an extension to the basic path described above.
The supplementary constraint may refer to a rule and a constraint condition that need to be considered when implementing the use case, and the supplementary constraint may include a field list, a business rule, a non-functional requirement (i.e., a quality requirement), and a design constraint. The field list may refer to a limited field that needs to be input or output in the implementation process of the use case, for example, in a successful payment use case, the amount of an order input by a user is the field list. The business rules refer to rules that need to be followed by the use case related business processing procedures. Quality requirements may refer to the quality requirements of a product by a user or developer. The design constraint may refer to various interface forms designed for the product in the development process, for example, what interface should be displayed after a certain operation is performed on the product, which is designed in advance by the product developer in the design process.
The content of the supplemental constraints is mostly presented in tabular form. Tables can be broadly classified into three major categories, as shown in table 1, including system verification, system processing, and system feedback, according to step type and supplemental constraint type.
TABLE 1
Figure BDA0002922125570000111
Figure BDA0002922125570000121
After the table 1 is preprocessed, each line of content of the table can be extracted according to the header format, and the extracted content can be further used as the extension data of the use case path.
The generating device automatically generates the test case according to the description in the legal requirement data, for example, the generating device automatically generates the test case based on the description in the legal requirement data by using the existing test case automatic generating system.
The test case comprises: example types, automation, example names, preconditions, example steps, expected results, etc.
After the test cases are automatically generated according to legal requirement data, all the generated test cases can be displayed on the terminal equipment. Alternatively, the display may be in a table form (e.g. excel table) for the user to browse, for example, as shown in table 2:
TABLE 2
Figure BDA0002922125570000122
Figure BDA0002922125570000131
If the user is satisfied with the generated test case, the test case can be saved or downloaded.
If the user is not satisfied with the generated test case, an empirical test case may be added. After the user inputs the experience test case, the test case table can be updated and stored, or the test case can be downloaded.
According to the method for generating the test case, the requirement data and the first information contained in the requirement data are obtained, and the first information comprises one or both of the step information and the business rule information; constructing a directed graph of the required data according to the first information; carrying out validity check on the directed graph of the demand data to obtain valid demand data; and generating a test case based on legal requirement data. According to the method and the device, the legality of the directed graph of the demand data is checked, so that the legality of the demand data is checked, the legality of the demand data for generating the test cases is effectively guaranteed, and the stability and the high efficiency of a test case generation mechanism are guaranteed. In addition, according to the method and the device, manual inspection is not needed, the legality of the demand data is automatically inspected through the directed graph of the demand data, the labor cost is greatly saved, the inspection accuracy is high, and the reliability of the generated test case is guaranteed.
On the basis of the above-described embodiment, the following describes in detail the validity check process of the demand data according to the difference of the first information.
Example two
If the first information includes step information and the directed graph of the demand data includes a step directed graph, the embodiment of the present application will be described in detail with reference to fig. 4.
Fig. 4 is a flowchart illustrating a method for generating a test case according to an embodiment of the present application, as shown in fig. 4, including:
s401, acquiring requirement data and step information in the requirement data.
S402, constructing a step directed graph of the demand data according to the step information.
For example, the steps in the step information are used as nodes of the directed graph, the sequence relation among the steps in the step information is used as an edge of the directed graph, and the step directed graph of the required data is constructed.
Before constructing the step directed graph of the demand data, the related concepts of the step directed graph of the demand data are introduced:
and (3) node: each step of the main path or the extended path.
And (3) child nodes: the step immediately next to the current step is called a child node of the current node.
And (4) parent node: the parent step immediately above the current step is called the parent node of the current node.
The brother nodes: the steps at the same level as the current step are called siblings of the current node.
The node type is as follows: the types of the path steps are mainly classified into four types, namely user selection, system verification, system processing and system feedback.
Leaf node: the type is a user selection type, a system verification type with feedback and a node of a system feedback type.
Side: the sequence relationship between steps, namely the up-down step association relationship between nodes.
The following drawings: the whole formed by all nodes and all edges
Parallel/serial relationship: for the siblings, if the type relationships of the siblings are the same, the siblings are parallel, otherwise the siblings are serial.
The next step is: and simulating the process of the executor for traversing the rules of the case path and transferring from the current node to the next node.
The step of creating the directed graph of the requirement data mainly comprises the following steps:
step 1, generating nodes of the step directed graph, wherein the nodes of the step directed graph mainly comprise two types, and the first type is each step in step information and comprises a main step and an expansion step. The second is a virtual node, such as the start node S and the end node E of the step directed graph, the occurrence of S and E is to ensure the integrity of the step directed graph.
And 2, recursively and serially connecting nodes of the directed graph of all the steps according to the relation among the steps in the step information. For example, the next step associated with each step can be obtained from the demand data, and the directed graph mapped to the step is the directed relationship between the nodes of the graph. Starting from the virtual starting node S through the directed relation, the whole step directed graph can be established according to the directed relation recursion.
And 3, adding corresponding business rules (or constraint conditions) for each step in the step directed graph according to the business rules associated with each step. After the step directed graph is established, adding a business rule to each node of the step directed graph according to the incidence relation of the business rule information in the required data, wherein adding the business rule is also called adding supplementary constraint data.
Through the steps, the step directed graph of the required data can be constructed.
For example, it is assumed that the step information included in the demand data includes the steps of: adding staff, deleting staff, inquiring staff, modifying staff basic information and calculating staff wages in the month. The relationship between the steps included in the step information is shown in fig. 5A, two steps of deleting staff members and inquiring staff members can be executed after adding staff members, and the steps of deleting staff members, modifying basic staff member information and calculating the salary of the staff member in the month can be executed after the step of inquiring staff members is executed. After the step of modifying the basic information of the staff member is executed, the steps of deleting the staff member, calculating the salary of the month of the staff member and ending can be executed. After the step of calculating the salary of the employee this month is performed, the steps of employee basic information, staff deletion and end may be performed.
The step directed graph shown in fig. 5B is constructed by using the steps as nodes of the directed graph and the order relationship between the steps as edges of the directed graph according to the order relationship between the steps in the step information shown in fig. 5A. Wherein, S represents the starting point of the step, E represents the ending point of the step, A represents an adding staff member, D represents a deleting staff member, Q represents an inquiring staff member, M represents basic information of a modifying staff member, and C represents the payroll of a calculating staff member in the month.
Further, after the step directed graph is established, adding a business rule to each node of the step directed graph according to the incidence relation of the business rule information in the required data.
It should be noted that the requirement data includes a step directed graph.
In this example, the step directed graph is taken as the directed graph of the demand data.
And S403, checking the validity of the step directed graph.
The above manner for checking the validity of the directed graph of the demand data in S403 includes, but is not limited to, the following:
in a first mode, if the preset checking condition includes node checking, the S403 includes S403-a1 and S403-a 2:
S403-A1, checking whether each step in the step directed graph belongs to demand data;
S403-A2, if the steps in the check step directed graph belong to the requirement data, determining that the step node of the requirement data is legal.
The validity check of the structural information firstly ensures the integrity of the whole directed graph, so that the whole requirement structure can be completely described. This requires that the structured information in the semi-structured demand document should satisfy the closure, i.e. all successor nodes of the directed graph should exist in the demand data, and there is no case that any error is associated with a node that is not in the demand data.
Based on this, the generating means checks whether each step in the step directed graph belongs to the demand data when generating the step directed graph, that is, checks whether each step in the step directed graph exists in the demand data. If each step in the directed graph in the step belongs to the required data, the directed graph in the step is determined to be legal, and further the node inspection in the step of the required data can be determined to be legal.
In the second mode, if the predetermined checking condition includes a round check, the S403 includes S403-B1, S403-B2, and S403-B3:
S403-B1, obtaining each round link in the step directed graph according to the round to which each step in the step directed graph of the demand data belongs;
S403-B2, checking whether each round link is single-chain;
and S403-B3, if the link of each round is checked to be single-chain, determining that the round check of the demand data is legal.
It should be noted that the requirement data includes step information, and the step information includes not only the sequence relationship among the steps, but also the round to which each step belongs and the sequence relationship among the rounds. A round consists of several steps to mark a complete sequence of actions in the actual business domain. Each round step is required to be a single chain without any branching. For example, step 1, step 2, step 3, step 4, and step 5 are included in the step information, where step 1 and step 2 belong to round 1, step 3, step 4, and step 5 belong to round 2, and round 2 is executed after execution of round 1 is finished. The round link formed by each step in each round is a single chain, wherein the single chain can be understood as that only one next step of each step is formed, and no loop is formed. For example, the round 1 link is: step 1 → step 2, round 2 link is: step 3 → step 5 → step 4, wherein arrow "→" indicates the next step.
However, because the round pass is manually marked, situations that the round link is incomplete or the round link abnormally jumps often occur.
Based on the above, the round links in the step directed graph can be obtained according to the round to which each step in the step directed graph of the required data belongs. Checking whether each round link is single chain or not, and recording and alarming if detecting that a certain round is not single chain. And if all round links in the directed graph in the detection step are single-chain, determining that the round check of the demand data is legal.
Further, when the round link has no extension, that is, when there is no next executable round for the round link, the end step of the round link must be marked as "end of use case", and correspondingly, the round link should be connected to the virtual end node E in the step directed graph. In this way, if it is checked that the round link does not point to the next round link or point to the step of case ending, it is determined that the round link is illegal, and further it is determined that the demand data is illegal.
Optionally, when the validity check is performed on the directed graph in step, the validity check of the demand data may be performed in any one of the first mode and the second mode, for example, the first mode is selected, when the step node check of the demand data is determined to be valid, and when the step node check of the demand data is determined to be invalid, the demand data is determined to be invalid. For example, in the second option, when the round check of the demand data is determined to be legal, and when the round check of the demand data is determined to be illegal, the demand data is determined to be illegal.
Optionally, when the step directed graph is checked for validity, two ways from the first way to the second way may be selected for checking, for example, when the step node check of the demand data is determined to be valid, and the round check of the demand data is determined to be valid, and when any one of the step node check and the round check of the demand data is not valid, the demand data is determined to be invalid.
In this embodiment, the validity check of the demand data is realized by constructing the step directed graph of the demand data and performing the validity check on the step directed graph of the demand data.
EXAMPLE III
If the first information includes the service rule information and the directed graph of the demand data includes the service rule directed graph, the embodiment of the present application will be described in detail with reference to fig. 6.
Fig. 6 is another schematic flow chart of a method for generating a test case according to an embodiment of the present application, and as shown in fig. 6, the method includes:
s601, acquiring requirement data and business rule information in the requirement data.
S602, according to the business rule information in the demand data, a business rule directed graph of the demand data is constructed.
It should be noted that the demand data includes service rule information, and the service rule information includes a plurality of service rules.
In one example, the service rules in the service rule information are used as nodes of the directed graph, and the reference relationship among the service rules in the service rule information is used as an edge of the directed graph, so that the directed graph of the service rules is constructed.
In an example, the business rules have association with the steps, first business rule information associated with each step may be obtained from the business rule information included in the demand data, and a business rule directed graph corresponding to each step is constructed according to the first business rule information associated with each step.
In the present application, the first business rule directed graph corresponding to each step is constructed in the same manner, and for convenience of explanation, one step is taken as an example for explanation.
The step of associated first business rule information comprises one or more first business rules.
In case 1, when the first service rule information associated in the step includes a first service rule, the first service rule is a node in the directed graph, and the directed graph of the service rule corresponding to the step is formed.
In case 2, when the first business rule information associated in this step includes a plurality of first business rules, a complex reference relationship exists between the plurality of first business rules, and is used for expressing various non-atomized hierarchical requirement logics in the business requirements. Therefore, the business rule directed graph corresponding to the step can be constructed according to the reference relation among the first business rules in the first business rule information. For example, each first business rule in the first business information is taken as a node of the directed graph, and the reference relation among the first business rules is taken as an edge of the directed graph, so that the business rule directed graph corresponding to the step is constructed.
In a specific example of the case 2, the second business rule with the number of times of being referred to being 0 in each first business rule may be determined according to the reference relationship between each first business rule in the first business rule information associated in the step; and taking the second business rule as a starting point of the directed graph, the first business rule as a node of the directed graph, and the reference relation between the first business rules as an edge of the directed graph, and constructing the business rule directed graph corresponding to the step, wherein other first business rules are the first business rules except the second business rule in the first business rule information.
For example, the first business rule information of the step relationship includes 10 first business rules, where the first business rule 8 is referred to by the first business rule 1 and the first business rule 7, the first business rule 1 and the first business rule 7 are referred to by the first business rule 2, the first business rule 2 is referred to by the first business rule 3, the first business rule 3 and the first business rule 4 are referred to by the first business rule 5, and the first business rule 10 and the first business rule 6 are referred to by the first business rule 9. As can be seen from the above, the number of times that the first business rule 5 and the first business rule 9 are referred to by the other first business rules is 0, and therefore, the first business rule 5 and the first business rule 9 are referred to as the second business rule.
For example, the business rule directed graph shown in fig. 7A can be obtained by using the first business rule 5 as the starting point of the directed graph, the first business rule as the node of the directed graph, and the reference relationship between the first business rules as the edge of the directed graph, and using a recursive method. The service rule directed graph shown in fig. 7B can be obtained by using the first service rule 9 as the starting point of the directed graph, the first service rule as the node of the directed graph, and the reference relationship between the first service rules as the edge of the directed graph, and using a recursive method.
Fig. 7A and 7B are both directed graphs of business rules corresponding to the step, that is, there may be a plurality of directed graphs of business rules corresponding to one step, and each directed graph of business rules is understood as a tree, and then one step corresponds to a forest of directed graphs of business rules. And the number of the business rule directed graphs included in the business rule directed graph forest is equal to the number of the second business rules.
With reference to the above manner, the business rule directed graph corresponding to each step in the demand data can be obtained, and the business rule directed graph corresponding to each step is taken as the directed graph of the demand data.
S603, checking the validity of the business rule directed graph.
The above-mentioned method for checking the validity of the service rule directed graph in S603 includes, but is not limited to, the following:
in a first mode, if the preset checking condition includes node checking, the step S603 includes steps S603-C1 and S603-C2:
S603-C1, checking whether each business rule in the business rule directed graph belongs to the demand data;
S603-C2, if each business rule in the business rule directed graph is checked to belong to the required data, determining that the business rule node of the required data is checked to be legal.
Specifically, for each business rule directed graph, whether each business rule in the business rule directed graph belongs to the demand data is checked, that is, whether each business rule in the business rule directed graph exists in the demand data is checked. If each business rule in the business rule directed graph is checked to belong to the required data, the business rule directed graph is determined to be legal, and then the required data business rule node can be determined to be legal for checking.
In the second mode, if the predetermined inspection condition includes a round inspection, the step S603 includes steps S603-D1 and S603-D2:
S603-D1, checking whether the service rule directed graph is a loop;
S603-D2, if the check business rule directed graph is not a loop, determining that the loop check of the demand data is legal.
The correct business rule reference relationship should be a Directed Acyclic Graph (DAG). Since business rules exist only layer-by-layer decomposition from non-atomic to atomic, no loopback is possible. Looping can result in test cases being trapped in an open dead loop.
Based on this, for each business rule directed graph, whether the business rule directed graph is a loop is checked, for example, whether the business rule directed graph is a loop is checked by using Topological Sorting (Topological Sorting). And if the directed graph of the business rule is checked not to be a loop, determining that the loop check of the required data is legal. And if the directed graph of the business rule is checked to be a loop, determining that the required data is illegal, and recording and alarming.
Optionally, when the validity check is performed on the service rule directed graph, any one of the first mode and the second mode may be selected for checking, for example, the first mode is selected, when it is determined that the service rule node of the required data checks legally, it is determined that the required data is legal, and when it is determined that the service rule node of the required data checks illegally, it is determined that the required data is illegal. For example, in the second selection mode, when the loopback check of the demand data is determined to be legal, and when the loopback check of the demand data is not legal, the demand data is determined to be illegal.
Optionally, when the validity check is performed on the service rule directed graph, two manners, namely the first manner and the second manner, may be selected to perform the check, for example, when it is determined that the service rule node check of the demand data is valid, and it is determined that the loopback check of the demand data is valid, it is determined that the demand data is valid, and when any one of the service rule node check and the loopback check of the demand data is not valid, it is determined that the demand data is not valid.
In this embodiment, the validity check of the demand data is realized by constructing the business rule directed graph of the demand data and performing the validity check on the business rule directed graph of the demand data.
Example four
If the first information includes step information and business rule information, and the directed graph of the demand data includes a step directed graph and a business rule directed graph, the embodiment of the present application will be described in detail with reference to fig. 8.
Fig. 8 is another schematic flow chart of a method for generating a test case according to an embodiment of the present application, and as shown in fig. 8, the method includes:
s801, acquiring requirement data, and step information and business rule information in the requirement data.
S802, constructing a step directed graph of the demand data according to the step information in the demand data.
Reference is made specifically to the description of S402 above.
And S803, constructing a business rule directed graph of the demand data according to the business rule information in the demand data.
And after the step directed graph is constructed, adding first business rule information to each step of the step directed graph according to the incidence relation of the business rule information in the required data. Adding the first business rule information to each step, and constructing a business rule directed graph corresponding to each step, wherein the specific construction process refers to the detailed description in the above-mentioned S602.
S804, checking the validity of the step directed graph and the business rule directed graph.
The specific way of checking the validity of the step directed graph refers to the description of S403, which is not described herein again.
The specific way of checking the validity of the business rule directed graph refers to the description of S603, and is not described herein again.
In this embodiment, the validity check of the demand data is realized by constructing the step directed graph and the business rule directed graph of the demand data and performing the validity check on the step directed graph and the business rule directed graph of the demand data.
In an embodiment of the present application, as shown in fig. 9, fig. 9 is a diagram of an overall architecture of a validity check according to an embodiment of the present application, as shown in fig. 9, including: a user, a demand management system and a validity checking system. That is, the generation apparatus of the present application includes a requirement management system and a legality checking system, and converts a semi-structured requirement document based on a natural language into structured requirement data by the requirement management system. The generating device checks the validity of the demand data by a validity check system.
The requirement management system and the validity check system are arranged on a background service. The requirement management system is a Browser/Server (BS) structure, a user working interface under the structure can be realized by a web Browser, a small part of business logic can be realized at a front end (namely a Browser), and main business logic can be realized at a Server.
In particular, the requirements management system is configured to receive user-entered requirements information, which is typically a semi-structured requirements document based on natural language. The demand management system analyzes the demand information and converts the demand information into structured demand data. After converting the requirement document into the structured requirement data, the requirement management system can store the structured requirement data in the database and provide pages for users to query and modify. And when the user inputs information such as use case names and the like on the page of the demand management system, responding to the query operation of the user and displaying a query result on the page of the demand management system.
For example, for a functional test requirement document of an application software payment system, when a user inputs a use case name for query, description content matched with the use case name can be displayed on a display page. For example, the use case name input by the user is "a certain application payment simplified registered user-payment", as shown in fig. 10A, a relevant description of the use case "a certain application payment simplified registered user-payment" may be displayed on the page, including information and menu columns of a target system (i.e., a system to be tested), the use case name, a main executor, an auxiliary executor, and the like corresponding to the use case, and may provide functions of editing, collecting, and the like for the user. The target system is the application payment system, the main executor is the simplified registered user of the payment of the application, the auxiliary executor is the bank system, and the test object of the case and the target to be reached by the case can be known from the target system and the case name. The menu bar may include options for crowd benefits (meaning benefits of people or organizations affected by the application payment system), preconditions, postconditions, path steps, and supplemental constraints, and the user may select different options to view the corresponding content. For example, the user selects a path step option, may view detailed steps corresponding to the use case, may display basic paths included in the use case in the detailed steps, and may represent the basic paths by numbers 1, 2, and …, for example: the base path 1 can be represented as: 1. the user submits payment information, requests payment, and the basic path 2 can be expressed as: 2. the system checks the validity of the payment information and the transaction information, etc. The detailed steps may further include extension paths, where numbers 1a, 1b, and … may be used to indicate an extension path corresponding to the basic path 1, and numbers 2a, 2b, and … may be used to indicate an extension path corresponding to the basic path 2, such as: the extended path 1a may be represented as: user cancellation, extended path 1b can be expressed as: and 1b, the user selects to add a bank card for payment and the like. The extension path may further include an extension sub-path, and the extension sub-path corresponding to the extension path 1a may be represented by numbers 1a1, 1a2, …, for example, the extension sub-path 1a1 may be represented as: 1a1. system entry 9 (i.e., base path 9). In the detailed steps, to facilitate viewing of each step, an unfolding and folding operation may be performed for each base path.
When the user selects the supplemental constraint option in the menu bar, as shown in fig. 10B, a sub-menu bar corresponding to the supplemental constraint option may be displayed on the presentation page, and the sub-menu bar may include options such as a field list, business rules, quality requirements, design constraints, and the like. When the user selects the business rule option, the specific rules included in the business rules in the use case can be displayed on the display page.
The testing device can provide a structural requirement data modification function for the user on the display interface, namely, if the user needs to modify the structural requirement data. As shown in fig. 10C, if the user needs to modify the business rule shown in fig. 10B, the user may select an edit function.
Further, when the requirement document uploaded by the user is not complete enough, the user may select a new requirement document, as shown in fig. 10D, the user may select the new requirement document on the display page of the requirement management system to enter the new requirement document inlet, in the new requirement document inlet, the user may upload the new requirement document in the document uploading area, in the process of uploading the new requirement document, the uploading progress of the new requirement document may be displayed in the progress bar, and after the uploading of the new requirement document is completed, the information of the file name, the file size, the file uploading time, the uploading state, and the like of the new requirement document may be displayed.
The demand management system converts the demand document into structured demand data and outputs the structured demand data. Optionally, the requirement management system outputs the structured requirement data in json format, for example, as follows:
Figure BDA0002922125570000231
Figure BDA0002922125570000241
the legality checking system reads the structured demand data from the demand management system, acquires step information and/or business rule information in the structured demand data, and generates a directed graph of the demand data based on the step information and/or the business rule information; and checking the validity of the directed graph of the demand data, for example, judging whether the structured demand data is legal or not in the process of constructing the directed graph, and establishing the directed graph to meet the specification. And if the structural information which does not conform to the specification is found through checking, alarming and preventing further generation of the test case.
Fig. 11 is a general architecture diagram of test case generation according to an embodiment of the present application, and as shown in fig. 11, the generation apparatus according to the embodiment of the present application may further include: the system comprises a demand management system, a validity check system, a feature library system and an automatic test case generation system. The requirement management system, the validity check system, the feature library system and the test case automatic generation system are all deployed on the server.
The demand management system is used for receiving demand information input by a user, and the demand information is a semi-structured demand document based on natural language. The requirements management system is used for converting a semi-structured requirements document based on natural language into structured requirements data.
The legality checking system reads the structured demand data from the demand management system to execute the method of the embodiment of the application, and the legality checking of the demand data is completed. For example, step information and/or business rule information in the structured demand data are obtained, and a directed graph of the demand data is generated based on the step information and/or the business rule information; and carrying out validity check on the directed graph of the demand data to judge whether the structured demand data is legal or not. And if the required data is checked to be illegal, alarming and preventing further generation of the test case. And if the requirement data is checked to be legal, outputting the legal requirement data to the automatic test case generation system.
The feature library system provides corpora from the structured demand data in the demand management system, performs characterization and classification, and generates corpus classification information and conflict corpus information.
The automatic test case generation system reads the corpus classification information and the conflict corpus information from the feature library system, and automatically generates the test case by combining legal requirement data obtained from the legality checking system.
In some embodiments, in order to find out the problem earlier and feed back the effect of modification in time, the validity checking system may be triggered to start up to check the validity of the structured demand data after the demand management system generates the structured demand data and before the demand data is output.
FIG. 12 is a timing diagram of a demand management system according to an embodiment of the present application. As shown in FIG. 12, the requirements management system may include a web browser, a requirements management system logic layer, and a requirements management system data processing layer. The user can upload the requirement document described by the natural language on the web browser to add new requirements. After the requirement document is uploaded successfully, the webpage browser can analyze and process the requirement document, check the format and the grammar validity of the requirement document through a logic layer of a requirement management system, and feed back a check result to a feature library system. After the feature library system receives the inspection result and the inspection is qualified, the requirement management system logic layer can convert the requirement document described by the natural language into structured document data (namely structured requirement data) and transmit the structured document data to the requirement management system data processing layer, so that the requirement management system data processing layer can input the structured document data into the database. For structured document data input in a database, a logic layer of a demand management system, a web browser and a user can receive data input results.
In the demand management system, a user can inquire the structured document data, after the user initiates an inquiry request, a web browser can process the inquiry request, and a logic layer of the demand management system can assemble data matched with the inquiry request in the structured document data according to the inquiry request of the user. And the data processing layer of the demand management system reads the structured document data stored in the database and returns the read data to the web browser through the logic layer of the demand management system. A user may browse data on a web browser.
In the demand management system, a user can also modify a demand document, and after the user initiates a modification request, the web browser can process the modification request, i.e. provide an editing window for the user. The user can re-edit the requirements in the edit window. The logic layer of the demand management system can check the validity of the modified data after demand and feed back the result of validity check to the feature library system. After the feature library system receives the inspection result and the inspection is qualified, the data processing layer of the demand management system can modify the structured document data according to the modification request and input the modified data into the database. The data processing layer of the demand management system can also return the data modification result to the web browser through the logic layer of the demand management system. The user may confirm the modification result on the web browser.
Method embodiments of the present application are described in detail above in conjunction with fig. 2-12, and apparatus embodiments of the present application are described in detail below in conjunction with fig. 13-14.
Fig. 13 is a schematic structural diagram of a device for generating a test case according to an embodiment of the present application. The test case may be generated by an electronic device, which may be the server shown in fig. 1, or may be a component (e.g., an integrated circuit, a chip, etc.) of the test case generation. As shown in fig. 13, the apparatus 100 for generating a test case may include: an acquisition unit 110, a construction unit 120, an inspection unit 130 and a generation unit 140.
An obtaining unit 110, configured to obtain requirement data and first information included in the requirement data, where the first information includes one or both of step information and business rule information;
the constructing unit 120 is configured to construct a directed graph of the demand data according to the first information;
a checking unit 130, configured to perform validity checking on the directed graph of the demand data to obtain valid demand data;
the generating unit 140 is configured to generate a test case based on legal requirement data.
In some embodiments, the first information includes step information, and the constructing unit 120 is specifically configured to construct a step directed graph of the demand data according to the step information included in the demand data.
For example, the constructing unit 120 is specifically configured to construct the step directed graph of the demand data by taking the steps in the step information as nodes of the directed graph and taking the sequence relationship among the steps in the step information as edges of the directed graph.
In some embodiments, the first information includes business rule information, and the constructing unit 120 is specifically configured to obtain, from the business rule information included in the demand data, the first business rule information associated with each step; and constructing a business rule directed graph corresponding to each step according to the first business rule information associated with each step.
In an example, the constructing unit 120 is specifically configured to construct a directed graph of the business rules corresponding to the step according to a reference relationship between the first business rules in the first business rule information associated with the step.
For example, the constructing unit 120 is specifically configured to determine, according to a reference relationship between the first business rules in the first business rule information associated in the step, a second business rule whose number of times of reference in each first business rule is 0; and constructing the service rule directed graph corresponding to the step by taking the second service rule as a starting point of the directed graph, taking the first service rule as a node of the directed graph and taking the reference relation between the first service rules as an edge of the directed graph.
In some embodiments, the directed graph of the demand data includes a step directed graph, and the checking unit 130 is specifically configured to check whether each step in the step directed graph belongs to the demand data; and if all the steps in the step directed graph belong to the required data, determining that the step nodes of the required data are legal to check.
In some embodiments, the directed graph of the demand data includes a step directed graph, and the checking unit 130 is specifically configured to obtain each round link in the step directed graph according to a round to which each step in the step directed graph of the demand data belongs; checking whether each round link is single-chain; and if the round links are checked to be single-chain, determining that the round check of the demand data is legal.
In some embodiments, the checking unit 130 is further configured to determine that the demand data is illegal if the checking indicates that the round link does not point to a next round link, or indicates a step of case ending.
In some embodiments, the directed graph of the demand data includes a business rule directed graph, and the checking unit 130 is specifically configured to check whether each business rule in the business rule directed graph belongs to the demand data; and if the service rules in the service rule directed graph are checked to belong to the required data, determining that the service rule node of the required data is legal to check.
In some embodiments, the directed graph of the demand data includes a business rule directed graph, and the checking unit 130 is specifically configured to check whether the business rule directed graph is a loopback; and if the directed graph of the business rules is checked not to be a loop, determining that the loop check of the required data is legal.
In some embodiments, the checking unit 130 is further configured to check whether a node next to the current node exists in the demand data in the process of constructing the directed graph of the demand data according to the first information; and if the next node is detected to exist in the required data, taking the next node as the node of the directed graph.
In some embodiments, the checking unit 130 is further configured to display warning information if it is determined that the next node does not exist in the demand data.
In some embodiments, the requirement data is a semi-structured requirement document based on a natural language, and the obtaining unit 110 is specifically configured to analyze the semi-structured requirement document based on the natural language to obtain the structured requirement data; and acquiring first information included in the structured demand data.
It is to be understood that apparatus embodiments and method embodiments may correspond to one another and that similar descriptions may refer to method embodiments. To avoid repetition, further description is omitted here. Specifically, the apparatus shown in fig. 13 may correspond to a corresponding main body in executing the method of the embodiment of the present application, and the foregoing and other operations and/or functions of each module in the generating apparatus 100 are respectively for implementing corresponding flows in each method in fig. 2, fig. 4, fig. 6, or fig. 8, and are not described again here for brevity.
The apparatus of the embodiments of the present application is described above in connection with the drawings from the perspective of functional modules. It should be understood that the functional modules may be implemented by hardware, by instructions in software, or by a combination of hardware and software modules. Specifically, the steps of the method embodiments in the present application may be implemented by integrated logic circuits of hardware in a processor and/or instructions in the form of software, and the steps of the method disclosed in conjunction with the embodiments in the present application may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in a processor. Alternatively, the software modules may be located in random access memory, flash memory, read only memory, programmable read only memory, electrically erasable programmable memory, registers, and the like, as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps in the above method embodiments in combination with hardware thereof.
Fig. 14 is a block diagram of an electronic device according to an embodiment of the present application, where the electronic device may be the server shown in fig. 1, and is used to execute the method according to the foregoing embodiment, specifically referring to the description in the foregoing method embodiment.
The electronic device 200 shown in fig. 14 includes a memory 201, a processor 202, and a communication interface 203. The memory 201, the processor 202 and the communication interface 203 are connected with each other in communication. For example, the memory 201, the processor 202, and the communication interface 203 may be connected by a network connection. Alternatively, the electronic device 200 may further include a bus 204. The memory 201, the processor 202 and the communication interface 203 are connected to each other by a bus 204. Fig. 14 is an electronic apparatus 200 in which a memory 201, a processor 202, and a communication interface 203 are communicatively connected to each other via a bus 204.
The Memory 201 may be a Read Only Memory (ROM), a static Memory device, a dynamic Memory device, or a Random Access Memory (RAM). The memory 201 may store programs, and the processor 202 and the communication interface 203 are used to perform the above-described methods when the programs stored in the memory 201 are executed by the processor 202.
The processor 202 may be implemented as a general purpose Central Processing Unit (CPU), a microprocessor, an Application Specific Integrated Circuit (ASIC), a Graphics Processing Unit (GPU), or one or more Integrated circuits.
The processor 202 may also be an integrated circuit chip having signal processing capabilities. In implementation, the method of the present application may be performed by instructions in the form of hardware, integrated logic circuits, or software in the processor 202. The processor 202 may also be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, or discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 201, and the processor 202 reads the information in the memory 201 and completes the method of the embodiment of the application in combination with the hardware thereof.
The communication interface 203 enables communication between the electronic device 200 and other devices or communication networks using transceiver modules such as, but not limited to, transceivers. For example, the data set may be acquired through the communication interface 203.
When electronic device 200 includes bus 204, as described above, bus 204 may include a pathway for communicating information between various components of electronic device 200 (e.g., memory 201, processor 202, communication interface 203).
There is also provided according to the present application a computer storage medium having stored thereon a computer program which, when executed by a computer, enables the computer to perform the method of the above-described method embodiments. In other words, the present application also provides a computer program product containing instructions, which when executed by a computer, cause the computer to execute the method of the above method embodiments.
There is also provided according to the present application a computer program product or computer program comprising computer instructions 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 to cause the computer device to perform the method of the above-described method embodiment.
In other words, when implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The procedures or functions described in accordance with the embodiments of the present application occur, in whole or in part, when the computer program instructions are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that includes one or more of the available media. The usable medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a Digital Video Disk (DVD)), or a semiconductor medium (e.g., a Solid State Disk (SSD)), among others.
Those of ordinary skill in the art will appreciate that the various illustrative modules and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the module is merely a logical division, and other divisions may be realized in practice, for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
Modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. For example, functional modules in the embodiments of the present application may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. In addition, the method embodiments and the device embodiments may also refer to each other, and the same or corresponding contents in different embodiments may be referred to each other, which is not described in detail.

Claims (15)

1. A method for generating a test case is characterized by comprising the following steps:
acquiring demand data and first information contained in the demand data, wherein the first information comprises one or both of step information and business rule information;
constructing a directed graph of the demand data according to the first information;
carrying out validity check on the directed graph of the demand data to obtain valid demand data;
and generating a test case based on legal requirement data.
2. The method of claim 1, wherein the first information comprises step information, wherein the directed graph of demand data comprises a step directed graph, and wherein constructing the directed graph of demand data from the first information comprises:
and constructing a step directed graph of the demand data according to the step information contained in the demand data.
3. The method according to claim 2, wherein the step directed graph for constructing the demand data according to the step information included in the demand data comprises:
and constructing the step directed graph of the required data by taking the steps in the step information as nodes of the directed graph and taking the sequence relation among the steps in the step information as the edges of the directed graph.
4. The method according to any one of claims 1 to 3, wherein the first information includes business rule information, the directed graph of the demand data includes a business rule directed graph, and the constructing the directed graph of the demand data according to the first information includes:
acquiring first business rule information associated with each step from the business rule information contained in the demand data;
and constructing a business rule directed graph corresponding to each step according to the first business rule information associated with each step.
5. The method according to claim 4, wherein the constructing the directed graph of the business rules corresponding to each step according to the first business rule information associated with each step includes:
and constructing a business rule directed graph corresponding to the step according to the reference relation among the first business rules in the first business rule information associated with the step.
6. The method according to claim 5, wherein the constructing the directed graph of the business rules corresponding to the step according to the reference relationship between the first business rules in the first business rule information associated with the step includes:
determining a second business rule with the number of times of being referred to as 0 in each first business rule according to the reference relation among the first business rules in the associated first business rule information of the step;
and constructing the service rule directed graph corresponding to the step by taking the second service rule as a starting point of the directed graph, taking the first service rule as a node of the directed graph and taking the reference relation between the first service rules as an edge of the directed graph.
7. The method according to claim 1 or 2, wherein the directed graph of the demand data comprises a step directed graph, and the checking the validity of the directed graph of the demand data comprises:
checking whether each step in the step directed graph belongs to the requirement data;
and if all the steps in the step directed graph belong to the required data, determining that the step nodes of the required data are legal to check.
8. The method according to claim 1 or 2, wherein the directed graph of the demand data comprises a step directed graph, and the checking the validity of the directed graph of the demand data comprises:
obtaining each round link in the step directed graph according to the round to which each step in the step directed graph of the demand data belongs;
checking whether each round link is single-chain;
and if the round links are checked to be single-chain, determining that the round check of the demand data is legal.
9. The method of claim 4, wherein the directed graph of demand data comprises a business rule directed graph, and wherein the legality checking the directed graph of demand data comprises:
checking whether each service rule in the service rule directed graph belongs to the requirement data;
and if the service rules in the service rule directed graph are checked to belong to the required data, determining that the service rule node of the required data is legal to check.
10. The method of claim 4, wherein the directed graph of demand data comprises a business rule directed graph, and wherein the legality checking the directed graph of demand data comprises:
checking whether the business rule directed graph is a loop;
and if the directed graph of the business rules is checked not to be a loop, determining that the loop check of the required data is legal.
11. The method of claim 1, further comprising:
in the process of constructing the directed graph of the demand data according to the first information, checking whether a next node of a current node exists in the demand data;
and if the next node is detected to exist in the required data, taking the next node as the node of the directed graph.
12. The method according to claim 1, wherein the demand data is a semi-structured demand document based on natural language, and acquiring first information included in the demand data comprises:
analyzing a semi-structured requirement document based on natural language to obtain structured requirement data;
first information included in the structured demand data is acquired.
13. An apparatus for generating a test case, comprising:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring demand data and first information contained in the demand data, and the first information comprises one or both of step information and business rule information;
the construction unit is used for constructing a directed graph of the demand data according to the first information;
the checking unit is used for checking the legality of the directed graph of the demand data to obtain legal demand data;
and the generating unit is used for generating the test case based on the legal requirement data.
14. An electronic device, comprising: a processor and a memory;
the memory for storing a computer program;
the processor is configured to execute the computer program to implement the test case generation method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that the storage medium comprises computer instructions which, when executed by a computer, cause the computer to implement the method of test case generation according to any one of claims 1 to 12.
CN202110120346.5A 2021-01-28 2021-01-28 Test case generation method and device and storage medium Pending CN113590453A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110120346.5A CN113590453A (en) 2021-01-28 2021-01-28 Test case generation method and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110120346.5A CN113590453A (en) 2021-01-28 2021-01-28 Test case generation method and device and storage medium

Publications (1)

Publication Number Publication Date
CN113590453A true CN113590453A (en) 2021-11-02

Family

ID=78238108

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110120346.5A Pending CN113590453A (en) 2021-01-28 2021-01-28 Test case generation method and device and storage medium

Country Status (1)

Country Link
CN (1) CN113590453A (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090178021A1 (en) * 2007-12-28 2009-07-09 Federal Home Loan Mortgage Corporation (Freddie Mac) Systems and Methods for Modeling and Generating Test Requirements for Software Applications
US20110066490A1 (en) * 2009-09-11 2011-03-17 International Business Machines Corporation System and method for resource modeling and simulation in test planning
US20140172512A1 (en) * 2012-12-14 2014-06-19 International Business Machines Corporation Efficiently generating test cases
US20140344788A1 (en) * 2013-05-15 2014-11-20 Oracle International Corporation Logic validation and deployment
CN106951368A (en) * 2017-03-12 2017-07-14 北京工业大学 Automatic example generation method based on UML timing diagrams
CN108319547A (en) * 2017-01-17 2018-07-24 阿里巴巴集团控股有限公司 Method for generating test case, device and system
CN110162468A (en) * 2019-04-26 2019-08-23 腾讯科技(深圳)有限公司 A kind of test method, device and computer readable storage medium
CN111258911A (en) * 2020-02-13 2020-06-09 深圳航天科技创新研究院 Software test case generation method, system and storage medium based on data driving and multiple coverage strategies
CN111506511A (en) * 2020-04-21 2020-08-07 腾讯科技(深圳)有限公司 Test case generation method and device, electronic equipment and medium
WO2020233089A1 (en) * 2019-05-21 2020-11-26 深圳壹账通智能科技有限公司 Test case generating method and apparatus, terminal, and computer readable storage medium
CN112015639A (en) * 2020-07-31 2020-12-01 北京轩宇信息技术有限公司 Method and device for generating satellite-borne software test case
WO2020240482A1 (en) * 2019-05-28 2020-12-03 Lexica S.A.S. Process and system for automatic generation of functional architecture documents and software design and analysis specification documents from natural language

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090178021A1 (en) * 2007-12-28 2009-07-09 Federal Home Loan Mortgage Corporation (Freddie Mac) Systems and Methods for Modeling and Generating Test Requirements for Software Applications
US20110066490A1 (en) * 2009-09-11 2011-03-17 International Business Machines Corporation System and method for resource modeling and simulation in test planning
US20140172512A1 (en) * 2012-12-14 2014-06-19 International Business Machines Corporation Efficiently generating test cases
US20140344788A1 (en) * 2013-05-15 2014-11-20 Oracle International Corporation Logic validation and deployment
CN108319547A (en) * 2017-01-17 2018-07-24 阿里巴巴集团控股有限公司 Method for generating test case, device and system
CN106951368A (en) * 2017-03-12 2017-07-14 北京工业大学 Automatic example generation method based on UML timing diagrams
CN110162468A (en) * 2019-04-26 2019-08-23 腾讯科技(深圳)有限公司 A kind of test method, device and computer readable storage medium
WO2020233089A1 (en) * 2019-05-21 2020-11-26 深圳壹账通智能科技有限公司 Test case generating method and apparatus, terminal, and computer readable storage medium
WO2020240482A1 (en) * 2019-05-28 2020-12-03 Lexica S.A.S. Process and system for automatic generation of functional architecture documents and software design and analysis specification documents from natural language
CN111258911A (en) * 2020-02-13 2020-06-09 深圳航天科技创新研究院 Software test case generation method, system and storage medium based on data driving and multiple coverage strategies
CN111506511A (en) * 2020-04-21 2020-08-07 腾讯科技(深圳)有限公司 Test case generation method and device, electronic equipment and medium
CN112015639A (en) * 2020-07-31 2020-12-01 北京轩宇信息技术有限公司 Method and device for generating satellite-borne software test case

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
王秀玄;: "基于UML状态图的列控中心软件测试路径生成方法", 铁路计算机应用, no. 08, 25 August 2016 (2016-08-25) *
荣辉桂;周宁;陆绍飞;肖爽;: "基于有向生成图的需求验证方法", 计算机工程, no. 22, 20 November 2008 (2008-11-20) *
陈慧峰;余晓菲;蒋建民;: "UML活动图的正确性检测", 软件工程, no. 03, 5 March 2018 (2018-03-05) *

Similar Documents

Publication Publication Date Title
JP7371141B2 (en) Tools and methods for real-time dataflow programming languages
US11093240B2 (en) Automating identification of code snippets for library suggestion models
US20220269594A1 (en) Automating Identification of Test Cases for Library Suggestion Models
CN108415832B (en) Interface automation test method, device, equipment and storage medium
US20200264870A1 (en) Automating Generation of Library Suggestion Engine Models
US20220253308A1 (en) Library Model Addition
US8161459B2 (en) Method and system for generating functional test cases
US9424115B2 (en) Analysis engine for automatically analyzing and linking error logs
US20180011780A1 (en) Web application test script generation to test software functionality
CN110018955A (en) Automatic test script is generated by conversion manual test use-case
US20130239098A1 (en) Source code conversion method and source code conversion program
US20170192955A1 (en) System and method for sentiment lexicon expansion
CN110688307B (en) JavaScript code detection method, device, equipment and storage medium
CN110928763A (en) Test method, test device, storage medium and computer equipment
US20190004934A1 (en) Automated path generator for optimized application testing
CN111159016A (en) Standard detection method and device
CN110096395A (en) Interface joint debugging test method, device, computer equipment and storage medium
CN107679051A (en) Transaction system error-detecting method and device
Li et al. Enabling automated requirements reuse and configuration
JP7161538B2 (en) Systems, apparatus and methods for processing and managing web traffic data
CN111260336B (en) Service checking method, device and equipment based on rule engine
EP2199905A1 (en) Lifecycle management and consistency checking of object models using application platform tools
US20240086165A1 (en) Systems and methods for building and deploying machine learning applications
CN113760721A (en) Page testing method and device
CN113590453A (en) Test case generation method and device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40055293

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination