A test case generation method and apparatus

By generating standardized forms for test cases through segmentation of function labels and definition of input methods, the problem of time-consuming and incomplete manual design is solved, and test cases with comprehensive coverage are generated efficiently and automatically.

CN116662165BActive Publication Date: 2026-01-06WUHAN HONGXIN TECH SERVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310557984.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-15
Publication Date
2026-01-06
Estimated Expiration
2043-05-15

AI Technical Summary

Technical Problem

In existing technologies, manually designing and writing test cases is labor-intensive and time-consuming, and different testers have different design habits, resulting in incomplete test case coverage.

Method used

By segmenting test cases according to their functional categories, multiple functional labels are obtained. Different mouse click events and input methods are defined, a test case generation specification form is generated, a hierarchical mapping relationship is established, a test point mind map is automatically generated, and test requirement points are extracted to generate test cases.

Benefits of technology

It improves the efficiency of test case generation, ensures comprehensive test case coverage, reduces human error, and optimizes the test design process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116662165B_ABST
    Figure CN116662165B_ABST
Patent Text Reader

Abstract

The present application relates to the field of code testing, and relates to a test case generation method and device, the method comprising: obtaining a function label according to a function category of a test case; for each function label, classifying types of to-be-input content into multiple first-class classification columns; presetting an input mode of the to-be-input content and classifying the to-be-input content into second-class classification columns; setting an input attribute for each second-class classification column to generate a test case point; generating a generation specification form of the test case, generating a test point mind map, extracting test requirement points in the mind map and the generation specification form, and generating the test case. The present application classifies test functions into different categories, induces corresponding test case generation specifications, avoids missing points when different testers design test cases, automatically generates a test point mind map template, facilitates to-be-tested requirement analysis and point extraction, automatically generates a test case according to the mind map and the test case generation specification, and is beneficial to improving test efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of code testing, and more particularly to a method and apparatus for generating test cases. Background Technology

[0002] With the continuous development of internet technology, software is becoming increasingly larger and more complex in scale and structure during software development, and the application areas of software are constantly expanding, making software system testing more difficult and complex. To test repetitive and simple operations in software in batches and reduce human error caused by repetitive manual testing, automated testing is commonly used. A test case is a description of a specific software product testing task, reflecting the test plan, methods, techniques, and strategies. Test cases include test objectives, test environment, input data, test steps, expected results, and test scripts, ultimately forming a document. Simply put, a test case is a set of test inputs, execution conditions, and expected results compiled for a specific goal to verify whether a specific software requirement is met.

[0003] Currently, the common method for generating test cases is to manually write test cases in Excel, or to first write test points using a mind map and then expand the mind map into Excel to generate test cases. However, this method has the following drawbacks:

[0004] 1) Manually designing and writing test cases is labor-intensive and time-consuming;

[0005] 2) Different testers have different habits and focuses when designing test cases, resulting in incomplete coverage of the test cases they write;

[0006] 3) Writing test cases is inefficient, and it is difficult to generate a large number of compliant and comprehensive test cases. Summary of the Invention

[0007] This invention provides a test case generation method and apparatus to address the shortcomings of existing technologies, such as the large workload and long time consumption when manually designing and writing test cases, thereby improving the efficiency of test case writing and generating a batch of compliant and comprehensive test cases.

[0008] A test case generation method provided by the present invention includes:

[0009] Multiple functional labels are obtained by segmenting the test cases according to their functional categories;

[0010] For each of the aforementioned function tags, the type of the content to be input is divided into multiple primary category columns;

[0011] Define different mouse click events for each of the first-level category columns, preset the input method for the content to be entered, and divide each different input method into a second-level category column;

[0012] Set input attributes for each secondary category column, and generate corresponding test case points based on the input attributes;

[0013] A test case generation specification form is generated based on the functional tags, the primary category column, the secondary category column, the input attributes, and the test case key points.

[0014] Based on the generated standard form, a hierarchical mapping relationship is established sequentially for the function tags, the first-level category column, the second-level category column, the input attributes, and the test case key points, generating a test key point mind map;

[0015] Extract the test requirements from the mind map of test points and the test requirement points from the generated specification form, and generate test cases.

[0016] According to a test case generation method provided by the present invention, the function tags include adding, editing, querying, and uploading.

[0017] According to a test case generation method provided by the present invention, the input methods for the secondary category column include input boxes, drop-down boxes, radio buttons, check boxes, and buttons.

[0018] According to a test case generation method provided by the present invention, if the input method of the secondary category column is an input box, and the input attributes include not empty, input format, and input character type, the content input in the input box is extracted, and it is determined whether it meets the input requirements of the input attributes;

[0019] If the input method of the secondary category column is a drop-down list, the input attributes include empty set judgment, default value, multiple options, whether to select multiple options, whether to create an input event, and create a mouse click event for the drop-down list based on the input attributes;

[0020] If the input method for the secondary category column is a radio button, the input attributes include empty set judgment, default value, and multiple options;

[0021] If the input method for the secondary category column is a checkbox, the input attributes include empty set judgment, number of selected options, and multiple options;

[0022] If the input method for the secondary category column is a button and the input attribute is click, a mouse click event is created based on the input attribute.

[0023] According to a test case generation method provided by the present invention, the generation specification form includes five columns of elements in sequence: the function label, the primary category column, the secondary category column, the input attribute, and the test case key points;

[0024] Each of the functional labels corresponds to at least one of the primary category columns, and each primary category column is located in a different row; each primary category column corresponds to at least one of the secondary category columns, and each secondary category column is located in a different row; each secondary category column corresponds to at least one of the input attribute columns, and each input attribute column is located in a different row.

[0025] Each of the input attribute columns corresponds to one of the test case points.

[0026] According to a test case generation method provided by the present invention, based on the generation specification form, a hierarchical mapping relationship is established sequentially for the function tags, the first-level category column, the second-level category column, the input attributes, and the test case key points to generate a test key point mind map, including:

[0027] The mind map of the test points includes first-level nodes, second-level nodes, third-level nodes, fourth-level nodes, fifth-level nodes, sixth-level nodes, and seventh-level nodes in sequence.

[0028] Specifically, the test requirement name of the project to be tested is extracted and used as the first-level node;

[0029] Based on the function tags in the generated specification form, extract the function points to be tested in the project to be tested and classify them. Use the function tags corresponding to the classified function points as the second-level nodes and the function names corresponding to the function tags as the third-level nodes.

[0030] Based on the secondary category column in the generated specification form, extract each input method of the corresponding secondary node in the project to be tested as the fourth-level node;

[0031] The fifth-level node is the name of the input element corresponding to the input method selected based on the fourth-level node;

[0032] Based on the input attributes in the generated specification form, extract the input attribute requirements for each functional point in the project to be tested, and use them as the sixth-level nodes;

[0033] Based on the attribute requirements and constraints corresponding to the input elements of each function point in the project to be tested, fill them into the seven-level nodes respectively.

[0034] According to a test case generation method provided by the present invention, test cases are generated by extracting the test point mind map and the test requirement points from the generation specification form, including:

[0035] Extract the requirement names from the first-level nodes of the mind map of the test points;

[0036] The content to be written in the test cases includes the test case number, functional module, sub-functional point, test case title, test case type, preconditions, test steps and expected results;

[0037] The content of the test cases is written in a loop, including:

[0038] Loop through the function names of all third-level nodes in the mind map of the test points;

[0039] For each functional point, iterate through the input element names of all fifth-level nodes corresponding to the functional point in the mind map of the test points;

[0040] For each input element, obtain the fourth-level node corresponding to the input element in the test point mind map, obtain the second-level category column corresponding to the generated specification form, and iterate through all input attributes of the second-level category column in the generated specification form.

[0041] Iterate through the test case details in the generated specification form, separating the test case details using delimiters.

[0042] According to a test case generation method provided by the present invention, if any of the test case points include variables, the elements in the seven-level nodes of the test point mind map are traversed in a loop, the extracted elements are separated by a separator, the value corresponding to each element is obtained, and each element is traversed and the corresponding variable is replaced.

[0043] On the other hand, the present invention also provides a test case generation device, including a rule input module, a template generation module, and a test case generation module;

[0044] The rule input module is used to obtain the generated specification form; the steps for generating the specification form include:

[0045] Multiple functional labels are obtained by segmenting the test cases according to their functional categories;

[0046] For each of the aforementioned function tags, the type of the content to be input is divided into multiple primary category columns;

[0047] Define different mouse click events for each of the first-level category columns, preset the input method for the content to be entered, and divide each different input method into a second-level category column;

[0048] Set input attributes for each secondary category column, and generate corresponding test case points based on the input attributes;

[0049] A test case generation specification form is generated based on the functional tags, the primary category column, the secondary category column, the input attributes, and the test case key points.

[0050] The template generation module is used to establish a hierarchical mapping relationship between the functional tags, the first-level category column, the second-level category column, the input attributes, and the test case points based on the generated specification form, and generate a test point mind map.

[0051] The test case generation module is used to extract the test requirements from the test point mind map and the test requirement form to generate test cases.

[0052] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the test case generation method as described above.

[0053] The test case generation method and apparatus provided by this invention have at least the following technical effects:

[0054] (1) This invention divides all test functions into different categories, summarizes and categorizes the corresponding test case generation specifications according to the function categories and their characteristics, continuously optimizes and accumulates them, and avoids missing key points when different testers design test cases.

[0055] (2) The present invention can automatically generate a test point mind map template according to the test case generation specification. Based on this mind map template, testers can conveniently and quickly analyze the requirements to be tested and extract the key points.

[0056] (3) Based on the test point mind map extracted by the testers and the established test case generation specifications, the present invention automatically generates test cases, thereby improving testing efficiency. Attached Figure Description

[0057] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0058] Figure 1 This is a flowchart illustrating the test case generation method provided by the present invention;

[0059] Figure 2 This is one of the schematic diagrams of the test point mind map of the test case generation method provided by the present invention;

[0060] Figure 3This is the second schematic diagram of the mind map of the test case generation method provided by this invention. Detailed Implementation

[0061] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0062] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or modules is not limited to the steps or modules listed, but may optionally include steps or modules not listed, or may optionally include other steps or modules inherent to such process, method, product, or apparatus.

[0063] It should be noted that the terms "first" and "second" used in this invention merely distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first" and "second" can be interchanged in a specific order or sequence where permissible. It should be understood that the objects distinguished by "first" and "second" can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those described or illustrated herein.

[0064] It should be noted that test cases mainly include four parts: test case title, preconditions, test steps, and expected results. The purpose of setting test cases is to highlight the key points and clarify the objectives of software testing. Designing test cases before starting testing can avoid blind testing and improve testing efficiency.

[0065] like Figure 1 As shown, a test case generation method according to the present invention includes:

[0066] Multiple functional labels are obtained by segmenting the test cases according to their functional categories;

[0067] For each of the aforementioned function tags, the type of the content to be input is divided into multiple primary category columns;

[0068] Define different mouse click events for each of the first-level category columns, preset the input method for the content to be entered, and divide each different input method into a second-level category column;

[0069] Set input attributes for each secondary category column, and generate corresponding test case points based on the input attributes;

[0070] A test case generation specification form is generated based on the functional tags, the primary category column, the secondary category column, the input attributes, and the test case key points.

[0071] Based on the generated standard form, a hierarchical mapping relationship is established sequentially for the function tags, the first-level category column, the second-level category column, the input attributes, and the test case key points, generating a test key point mind map;

[0072] Extract the test requirements from the mind map of test points and the test requirement points from the generated specification form, and generate test cases.

[0073] According to a test case generation method provided by the present invention, the function tags include adding, editing, querying, and uploading.

[0074] According to a test case generation method provided by the present invention, the input methods for the secondary category column include input boxes, drop-down boxes, radio buttons, check boxes, and buttons.

[0075] According to a test case generation method provided by the present invention, if the input method of the secondary category column is an input box, and the input attributes include not empty, input format, and input character type, the content input in the input box is extracted, and it is determined whether it meets the input requirements of the input attributes;

[0076] If the input method of the secondary category column is a drop-down list, the input attributes include empty set judgment, default value, multiple options, whether to select multiple options, whether to create an input event, and create a mouse click event for the drop-down list based on the input attributes;

[0077] If the input method for the secondary category column is a radio button, the input attributes include empty set judgment, default value, and multiple options;

[0078] If the input method for the secondary category column is a checkbox, the input attributes include empty set judgment, number of selected options, and multiple options;

[0079] If the input method for the secondary category column is a button and the input attribute is click, a mouse click event is created based on the input attribute.

[0080] According to a test case generation method provided by the present invention, the generation specification form includes five columns of elements in sequence: the function label, the primary category column, the secondary category column, the input attribute, and the test case key points;

[0081] Each of the functional labels corresponds to at least one of the primary category columns, and each primary category column is located in a different row; each primary category column corresponds to at least one of the secondary category columns, and each secondary category column is located in a different row; each secondary category column corresponds to at least one of the input attribute columns, and each input attribute column is located in a different row.

[0082] Each of the input attribute columns corresponds to one of the test case points.

[0083] Specifically, in the generated standard form, each functional category occupies one form page, and the functional name is the form name. Each form page contains five columns: functional type, primary category, secondary category, input attribute, and test case key points, namely the functional label, the primary category column, the secondary category column, the input attribute, and the test case key points.

[0084] The "Function Type" column indicates the function type of the current form page.

[0085] The primary category column represents the directional category when designing test cases for this function type, with each primary category occupying a different row;

[0086] Secondary category columns are used to expand the classification for different primary categories, with each secondary category occupying a different row;

[0087] The input attribute column is used to target different design directions in test case design for different primary and secondary categories, with each requirement point occupying a different row;

[0088] The Test Case Highlights column is used to list all the test case highlights for different primary and secondary categories and their corresponding input attributes, based on test case design methods such as equivalence classes and boundary values. All the test case highlights for each input attribute are placed in one cell, separated by Chinese commas or other delimiters.

[0089] Taking the function category as "Add" as an example, the name of this form page in the generated standard form is "Add", which will be referred to as the Add page below. The content of each column of the Add page is as follows:

[0090] Includes a function type column, which is set to "New";

[0091] First-level category columns include two types: "Elements" and "Functional Categories";

[0092] Secondary category column: When the primary category is "Element", the secondary categories include "Input Box", "Dropdown Box", "Radio Button", "Check Box", and "Button"; when the primary category is "Function", the secondary categories are empty.

[0093] The input attribute column includes the following: When the second-level category is "Input Box", the input attributes include "Required", "Format", "Length", and "Size"; when the second-level category is "Dropdown List", the input attributes include "Required", "Option", "Default Value", "Multiple Selection", "Input Allowed", and "Linked Dropdown List"; when the second-level category is "Radio Button", the input attributes include "Required", "Option", and "Default Value"; when the second-level category is "Checkbox", the input attributes include "Required", "Option", and "Select Multiple"; when the second-level category is "Button", the input attribute includes "Click"; when the first-level category is "Functional", the input attributes include "Submission Parameters", "Uniqueness Validation", and "Response Time".

[0094] The key points of the test cases include: when the input attribute is "required", the key points of the test cases are "empty or not empty", that is, to determine whether the content filled in is an empty set. If it is required to be a required field, it is necessary to be able to identify whether the content filled in is empty or not empty.

[0095] When the input attribute is "format", the key content of the test case is "numbers, letters, Chinese characters, special characters, spaces, and newlines";

[0096] When the input attribute is "length", the key points of the test case are "less than min, equal to min, greater than min and less than max, equal to max, greater than max", where min represents the minimum value of the variable and max represents the maximum value of the variable;

[0097] When the input attribute is "size", the key points of the test case are "less than min, equal to min, greater than min and less than max, equal to max, greater than max", where min represents the minimum value of the variable and max represents the maximum value of the variable;

[0098] When the input attribute is "option", the key content of the test case is "select each option value X", where X represents each specific option value of the variable;

[0099] When the input attribute is "default value", the key point of the test case is "automatically select default value".

[0100] When the input attribute is "multiple selection", the key points of the test case are "select 2, select max-1, select max", where max represents the number of variable options;

[0101] When the input attribute is "whether it can be entered", the key points of the test case are "auto-suggestion when entering, inputting a compliant value, and inputting an incompliant value".

[0102] When the input attribute is "drop-down list linkage", the key content of the test case is "the corresponding drop-down list options change accordingly";

[0103] When the input attribute is "click", the key points of the test case are "click to jump, click the button to return after jumping, click the browser / system to return after jumping";

[0104] When the input attribute is "submit parameters", the key points of the test case are "submit all required fields, submit all required fields and all optional fields";

[0105] When the input attribute is "uniqueness check", the key points of the test case are "adding non-existent data and adding existing data".

[0106] When the input attribute is "response time", the key content of the test case is "response time within 3 seconds";

[0107] The following is an example of a generated form with the function type column set to "Add":

[0108]

[0109] The above are further examples of the present invention and should not be regarded as further limitations on the present invention;

[0110] According to a test case generation method provided by the present invention, based on the generation specification form, a hierarchical mapping relationship is established sequentially for the function tags, the first-level category column, the second-level category column, the input attributes, and the test case key points to generate a test key point mind map. Specifically, the test key point mind map is as follows: Figure 2-3 As shown, it includes:

[0111] The mind map of the test points includes first-level nodes, second-level nodes, third-level nodes, fourth-level nodes, fifth-level nodes, sixth-level nodes, and seventh-level nodes in sequence.

[0112] Specifically, the test requirement name of the project to be tested is extracted and used as the first-level node;

[0113] Based on the function tags in the generated specification form, extract the function points to be tested from the project to be tested and classify them. The function tags corresponding to the classified function points are used as the second-level nodes, with Chinese square brackets added, including "[Add]", "[Edit]", "[Query]", "[Delete]", and "[File Upload]". The function names corresponding to the function tags are used as the third-level nodes.

[0114] Based on the secondary category column in the generated specification form, extract each input method of the corresponding secondary node in the project to be tested as the fourth-level node; for example, when the secondary node is "[Add]", the corresponding fourth-level node is "[Input Box]", "[Dropdown Box]", "[Radio Button]", "[Check Box]", "[Button]". If a function category has an empty secondary category column in the generated specification form, then there is no fourth-level node in the mind map.

[0115] The fifth-level node is the name of the input element corresponding to the input method selected based on the fourth-level node;

[0116] Based on the input attributes in the generated specification form, extract the input attribute requirements for each function point in the project to be tested, and use them as the sixth-level nodes; for example, if the second-level node is "[Add]" and the fourth-level node is "[Input Box]", the corresponding sixth-level nodes are "[Required]", "[Format]", "[Length]", and "[Size]".

[0117] Based on the attribute requirements and constraints corresponding to the input elements of each functional point in the project to be tested, fill them into the seven-level nodes respectively;

[0118] According to a test case generation method provided by the present invention, test cases are generated by extracting the test point mind map and the test requirement points from the generation specification form, including:

[0119] Extract the requirement names from the first-level nodes of the mind map of the test points;

[0120] The content to be written in the test cases includes the test case number, functional module, sub-functional point, test case title, test case type, preconditions, test steps and expected results;

[0121] The content of the test cases is written in a loop, including:

[0122] Loop through the function names of all third-level nodes in the mind map of the test points;

[0123] For each functional point, iterate through the input element names of all fifth-level nodes corresponding to the functional point in the mind map of the test points;

[0124] For each input element, obtain the fourth-level node corresponding to the input element in the test point mind map, obtain the second-level category column corresponding to the generated specification form, and iterate through all input attributes of the second-level category column in the generated specification form.

[0125] Iterate through the test case details in the generated specification form, separating the test case details using delimiters.

[0126] According to a test case generation method provided by the present invention, if any of the test case points include variables, the elements in the seven-level nodes of the test point mind map are traversed in a loop, the extracted elements are separated by a separator, the value corresponding to each element is obtained, and each element is traversed and the corresponding variable is replaced.

[0127] As an example, the steps to generate test cases include:

[0128] 1. The test case number column is automatically generated in the format "01.001". The first 01 represents the function point number. The same function point has the same number. The number is automatically incremented for each new function point. The last 001 represents the test case number for the current function point. The number is automatically incremented for each new test case. When the function point number changes, the test case number is automatically reset to 001.

[0129] 2. The functional modules are listed as the requirement names of the first-level nodes in the test point mind map;

[0130] 3. The sub-functional points are the names of the functional points of the third-level nodes in the test point mind map;

[0131] 4. The test case title column consists of the function point name of the third-level node in the test point mind map, concatenated with the element name of the fifth-level node, then concatenated with the input attribute of that element type in the generated specification form file, and finally concatenated with the test case point corresponding to that input attribute, all connected by a hyphen, such as "Add Ordinary User - Name - Required - Not Empty"; In the test case title column, if a test case point contains the variable names min and max, then replace them with the numbers extracted from the point values ​​of the corresponding seventh-level node in the test point mind map; for example, if the length of the name input box in the test point mind map is 1-10, then 1 replaces min and 10 replaces max;

[0132] 5. The case type is listed as either a positive case or a negative case. The judgment rules include the following points:

[0133] 1) When the input attribute in the generated standard form file is "required", the value of the seventh-level node after the corresponding sixth-level node "[required]" in the test point mind map is extracted. If it is "required", then "not empty" in the test case points is a positive case and "empty" is a negative case; if it is "not required", then both "not empty" and "empty" are positive cases.

[0134] 2) When the input attribute in the generated specification form file contains "format", the value of the seventh-level node after the corresponding sixth-level node "[format]" in the test point mind map is extracted and saved as a list. The value in this list in the test case points is a positive case, and the value not in this list is a negative case.

[0135] 3) When the input attribute in the generated specification form file contains "length" or "size", then "equal to min", "greater than min and less than max", and "equal to max" in the test case key points are positive cases, and "less than min" and "greater than max" are negative cases;

[0136] 4) Other use cases without special judgment are assumed to be positive cases;

[0137] 6. The preconditions column is empty and will be added by testers later.

[0138] 7. The test steps column is empty and will be added by subsequent testers;

[0139] 8. The expected result column is empty and will be filled in by subsequent testers.

[0140] Through the above steps, this invention can automatically generate test cases based on the test point mind map extracted by the testers and the established test case generation specifications, thereby improving testing efficiency.

[0141] On the other hand, the present invention also provides a test case generation device, including a rule input module, a template generation module, and a test case generation module;

[0142] The rule input module is used to obtain the generated specification form; the steps for generating the specification form include:

[0143] Multiple functional labels are obtained by segmenting the test cases according to their functional categories;

[0144] For each of the aforementioned function tags, the type of the content to be input is divided into multiple primary category columns;

[0145] Define different mouse click events for each of the first-level category columns, preset the input method for the content to be entered, and divide each different input method into a second-level category column;

[0146] Set input attributes for each secondary category column, and generate corresponding test case points based on the input attributes;

[0147] A test case generation specification form is generated based on the functional tags, the primary category column, the secondary category column, the input attributes, and the test case key points.

[0148] The template generation module is used to establish a hierarchical mapping relationship between the functional tags, the first-level category column, the second-level category column, the input attributes, and the test case points based on the generated specification form, and generate a test point mind map.

[0149] The test case generation module is used to extract the test requirements from the test point mind map and the test requirement form to generate test cases.

[0150] The present invention also provides an electronic device, which may include a processor, a communications interface, a memory, and a communication bus, wherein the processor, the communications interface, and the memory communicate with each other via the communication bus. The processor can invoke logical instructions in the memory to execute the steps of the test case generation methods provided by the above methods.

[0151] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, and can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0152] On the other hand, the present invention also provides a computer program product, the computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, and when the program instructions are executed by a computer, the computer is able to execute the steps of the test case generation method provided by the above methods.

[0153] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the test case generation method provided by the above methods.

[0154] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0155] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0156] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A test case generation method characterized by, The application relates to a test case generation method and device. According to the function category of the test case, a plurality of function labels are obtained by segmentation; For each function label, the type of the input content is divided into a plurality of first classification columns; For each first classification column, a different mouse click event is defined, a preset input mode of the input content is divided into a second classification column, and each different input mode is divided into a second classification column; For each second classification column, an input attribute is set, and a corresponding test case point is generated based on the input attribute; Based on the function label, the first classification column, the second classification column, the input attribute, and the test case point, a generation specification form of the test case is generated; Based on the generation specification form, a step-by-step mapping relationship of the function label, the first classification column, the second classification column, the input attribute, and the test case point is established in sequence, and a test point mind map is generated; The test point mind map sequentially includes a first node, a second node, a third node, a fourth node, a fifth node, a sixth node, and a seventh node; The test requirement name of the to-be-tested project is extracted as the first node; According to the function label in the generation specification form, the to-be-tested function point in the to-be-tested project is extracted and classified, the function label corresponding to the classified function point is taken as the second node, and the function name corresponding to the function label is taken as the third node; According to the second classification column in the generation specification form, each input mode of the second node in the to-be-tested project is extracted as the fourth node; The fifth node is the input element name corresponding to the selected input mode of the fourth node; According to the input attribute in the generation specification form, the input attribute requirement of each function point in the to-be-tested project is extracted as the sixth node; Based on the attribute requirement and the limitation condition of the input element corresponding to each function point in the to-be-tested project, the seventh node is filled in; The test requirement points in the test point mind map and the generation specification form are extracted to generate a test case, and the generation specification form sequentially includes five columns of elements, namely the function label, the first classification column, the second classification column, the input attribute, and the test case point; Each function label corresponds to at least one first classification column, and each first classification column is located in a different row; each first classification column corresponds to at least one second classification column, and each second classification column is located in a different row; and each second classification column corresponds to at least one input attribute column, and each input attribute column is located in a different row. Each input attribute column corresponds to one test case point.

2. The test case generation method of claim 1, wherein, The function label includes adding, editing, querying, and uploading.

3. The test case generation method of claim 1, wherein, The input mode of the second classification column includes an input box, a drop-down box, a single selection box, a check box, and a button.

4. The test case generation method of claim 3, wherein, If the input mode of the second classification column is an input box, the input attribute includes non-empty, input format, and input character type, the input content in the input box is extracted, and whether the input content meets the input requirement of the input attribute is judged. If the input mode of the secondary classification column is a drop-down box, the input attributes include empty set judgment, default value, multiple options, multiple selection, and key input event, and the mouse click event of the drop-down box is established based on the input attributes; If the input mode of the secondary classification column is a radio button, the input attributes include empty set judgment and multiple options; If the input mode of the secondary classification column is a check box, the input attributes include empty set judgment, selected number, and multiple options; If the input mode of the secondary classification column is a button, the input attribute is click, and the mouse click event is established based on the input attribute.

5. The test case generation method of claim 4, wherein, Extracting the test point mind map and the test requirement points in the generated specification form, generating test cases, including: Extracting the requirement name of the first-level node in the test point mind map; Writing the content of the test case, including case number, function module, sub-function point, case title, case type, preconditions, test steps, and expected results; Cyclically writing the content of the test case, including: Cyclically traversing the function names of all third-level nodes in the test point mind map; For each function point, cyclically traversing the input element names of all fifth-level nodes corresponding to the function point in the test point mind map; For each input element, obtaining the fourth-level node corresponding to the input element in the test point mind map, obtaining the secondary classification column corresponding to the generated specification form, and cyclically traversing all input attributes of the secondary classification column in the generated specification form; Cyclically traversing the test case points in the generated specification form and separating the test case points by a delimiter.

6. The test case generation method of claim 5, wherein, If any of the test case points includes a variable, cyclically traverse the elements in the seventh-level node in the test point mind map, separate the extracted elements by a delimiter, obtain the value corresponding to each element, and traverse each element to replace the corresponding variable.

7. A test case generation apparatus characterized by comprising: It includes a rule input module, a template generation module, and a case generation module; The rule input module is used to obtain a generated specification form; the generation steps of the generated specification form include: According to the function category of the test case, multiple function labels are obtained by segmentation; For each function label, the type of the to-be-input content is divided into multiple first-level classification columns; For each first-level classification column, define different mouse click events, preset the input mode of the to-be-input content, and divide each different input mode into a second-level classification column; For each second-level classification column, set input attributes, and generate corresponding test case points based on the input attributes; Based on the function label, the first-level classification column, the second-level classification column, the input attribute, and the test case point, a generated specification form of the test case is generated; The template generation module is used to generate a test point mind map based on the generated specification form, and sequentially establish the hierarchical mapping relationship of the function label, the first-level classification column, the second-level classification column, the input attribute, and the test case point; the test point mind map sequentially includes a first-level node, a second-level node, a third-level node, a fourth-level node, a fifth-level node, a sixth-level node, and a seventh-level node. The test requirement name of the test item to be tested is extracted as the first-level node. According to the function label in the generated specification form, the test function points in the test item to be tested are extracted and classified, the function label corresponding to the classified function points is taken as the second-level node, and the function name corresponding to the function label is taken as the third-level node. According to the second-class column in the generated specification form, each input mode corresponding to the second-level node in the test item to be tested is extracted as the fourth-level node. The fifth-level node is the input element name corresponding to the input mode selected based on the fourth-level node. According to the input attribute in the generated specification form, the input attribute requirement of each function point in the test item to be tested is extracted as the sixth-level node. Based on the attribute requirement and the restriction condition of the input element corresponding to each function point in the test item to be tested, the seventh-level node is filled in respectively. The use case generation module is used to extract the test requirement points in the mind map and the generated specification form, generate test cases, and the generated specification form includes five columns of elements: the function label, the first-class column, the second-class column, the input attribute, and the test case point. Each function label corresponds to at least one first-class column, and each first-class column is located in a different row. Each first-class column corresponds to at least one second-class column, and each second-class column is located in a different row.

8. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, Each second-class column corresponds to at least one input attribute column, and each input attribute column is located in a different row. Each input attribute column corresponds to one test case point. The computer program is executed by the processor to realize the steps of the test case generation method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Matrix-model-based software testing method

    CN104346278A

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

    CN108595338A