Automated Test Case Generation Method, Device, Equipment, Medium and Program Product

Through the method of cyclically extracting and analyzing sample test cases, a keyword set is generated to analyze full test cases, solving the problems of keyword packaging accuracy and tool customization in the existing technology, and achieving efficient and flexible automated test case generation.

CN114168474BActive Publication Date: 2025-06-10CHINA CONSTRUCTION BANK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111502304.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2025-06-10
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

When editing automated test cases, the packaging accuracy of keywords affects actual execution and maintenance, and the degree of tool customization is high. Testers need to strictly follow the operating methods, and the equipment requirements are high.

Method used

An automated test case generation method is provided. By extracting sample test cases based on the preset granularity extraction unit, obtaining keywords, and performing the extraction and analysis steps cycle until the proportion of cases that fail to parse the threshold, forming a keyword set for analyzing the full test cases.

Benefits of technology

It improves the efficiency and accuracy of automated test cases, reduces the threshold for testers' intervention, reduces the requirements for test equipment, and improves the flexibility and maintainability of test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114168474B_ABST
    Figure CN114168474B_ABST
Patent Text Reader

Abstract

The present disclosure provides an automated test case generation method, which can be applied to the field of testing technology. The automated test case generation method includes: S1 extracting a first keyword from a sample test case based on an extraction unit with a preset granularity; S2 performing a first parsing on a first training test case according to the first keyword; S3 performing an (i + 1)-th extraction on the i-th training test case with parsing failure to obtain an (i + 1)-th keyword; S4 performing an (i + 1)-th parsing on the (i + 1)-th training test case according to the (i + 1)-th keyword; S5 repeating steps S3 - S4 until the proportion of training test cases with parsing failure is less than a threshold to obtain a keyword set; S7 performing parsing on all test cases based on the keyword set to obtain automated test cases. The present disclosure also provides an automated test case generation device, equipment, storage medium and program product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of testing, specifically to automated testing, and more specifically to a method, apparatus, device, medium, and program product for generating automated test cases. Background Art

[0002] In existing automated testing frameworks, to reduce the difficulty of editing automated test cases, a commonly used method is to encapsulate functions into keywords, using the name of the keyword to describe the function objective of the function. Testers edit automated test cases by combining keywords with data; the other is that when the tester selects an operation object, the code automatically completes the interface parsing to complete the editing of the automated test case. In the first method, the accuracy of keyword encapsulation will have a greater impact on the actual execution and later maintenance of automated test cases. In the second method, for the automated framework that completes the editing of automated test cases based on interface parsing, the function is not open source and cannot be independently extended; moreover, the tool customization degree is high, and testers need to strictly execute according to the operation method; the requirements for test equipment are relatively high. Summary of the Invention

[0003] In view of the above problems, embodiments of the present disclosure provide an efficient and flexible method, apparatus, device, medium, and program product for generating automated test cases.

[0004] According to a first aspect of the present disclosure, there is provided a method for generating an automated test case, characterized by comprising the following steps: S1. Based on an extraction unit of a preset granularity, perform a first extraction on a sample test case to obtain a first keyword; S2. Perform a first parsing on a first training test case according to the first keyword; S3. Perform an (i + 1)-th extraction on the i-th training test case with parsing failure to obtain an (i + 1)-th keyword, where the (i + 1)-th extraction is performed based on an extraction unit of a preset granularity, and i is a positive integer greater than or equal to 1; S4. Perform an (i + 1)-th parsing on the (i + 1)-th training test case according to the (i + 1)-th keyword; S5. Loop and execute steps S3 - S4 until the proportion of the n-th training test case with parsing failure in the n-th training test case is less than a preset threshold; S6. When the proportion of the training test case with parsing failure in the n-th training test case is less than a preset threshold, obtain a keyword set, where the keyword set includes the n-th keyword, where n is the number of extractions when the proportion of the training test case with parsing failure in the current training test case is less than a preset threshold, and n is a positive integer greater than or equal to i + 1; and S7. Parse the full amount of test cases based on the keyword set to obtain an automated test case.

[0005] According to an embodiment of the present disclosure, parsing the first training and testing case based on the first keyword includes: based on the first keyword, parsing the first training and testing case into a case keyword name and a case input value, where the first keyword includes a first keyword name and a first keyword input value type; performing a first judgment, the first judgment including judging whether the case keyword name matches the first keyword name; and when the case keyword name matches the first keyword name, performing a second judgment, the second judgment including judging whether the case input value matches the first keyword input value type, and when both the first judgment and the second judgment are successfully matched, determining that the case parsing is successful.

[0006] According to an embodiment of the present disclosure, performing the (i + 1)-th extraction on the i-th training and testing case to obtain the (i + 1)-th keyword includes: analyzing the failure reason type based on the i-th training and testing case with parsing failure; and performing the (i + 1)-th extraction on the training and testing case with parsing failure based on the failure reason type and its corresponding supplementary extraction method to obtain the (i + 1)-th keyword.

[0007] According to an embodiment of the present disclosure, when the failure reason type includes that the training and testing case with parsing failure contains a functional module with a large difference from the functional module corresponding to the i-th keyword, the (i + 1)-th extraction includes: based on the functional module with parsing failure, supplementarily extracting the (i + 1)-th keyword.

[0008] According to an embodiment of the present disclosure, when the parsing failure reason type includes that the keyword name of the training and testing case with parsing failure matches the i-th keyword name, but its case data does not match the i-th keyword input value type, the (i + 1)-th extraction includes: adjusting the keyword input type or adding special rules for the keyword input type to obtain the (i + 1)-th keyword.

[0009] According to an embodiment of the present disclosure, when the parsing failure reason type includes that the parsing is not successful, but the training and testing case with parsing failure contains a functional module with a small difference from the functional module corresponding to the i-th keyword, the (i + 1)-th extraction includes: adding fuzzy matching for the i-th keyword to form a keyword name group to obtain the (i + 1)-th keyword.

[0010] According to an embodiment of the present disclosure, before parsing all test cases based on the keyword set to obtain automated test cases, the method further includes; establishing a mapping relationship between the keyword set and automated test code to obtain an automated test script.

[0011] According to an embodiment of the present disclosure, parsing the full - volume test cases based on the keyword set to obtain automated test cases includes: recording information of parsing - failed cases; calculating the ratio of the number of parsing - failed cases to the number of parsed - completed cases; and when the ratio is greater than or equal to a preset threshold, manually maintaining the keyword set.

[0012] According to an embodiment of the present disclosure, when the ratio is less than the preset threshold, the method further includes: archiving the parsed full - volume test cases and randomly conducting manual spot checks irregularly.

[0013] According to an embodiment of the present disclosure, the first extraction of the sample test cases with a preset - granularity extraction unit includes: when the sample - test - case statement corresponds to a single page, using the sample - test - case statement as the extraction unit for the first extraction to obtain the first keyword.

[0014] According to an embodiment of the present disclosure, the first extraction of the sample test cases based on a preset - granularity extraction unit further includes: when the sample - test - case statement corresponds to m pages, using the statement part corresponding to each page as the first extraction unit to extract m sub - keywords; and encapsulating the m sub - keywords to obtain the first keyword corresponding to the sample - test - case statement, where m is a positive integer greater than or equal to 1.

[0015] A second aspect of the present disclosure provides an automated - test - case generation device, including: a first extraction module configured to perform a first extraction on sample test cases based on a preset - granularity extraction unit to obtain the first keyword; a first parsing module configured to perform a first parsing on the first training test cases according to the first keyword; a second extraction module configured to perform an (i + 1)-th extraction on the i - th training test case with parsing failure to obtain the (i + 1)-th keyword, where the (i + 1)-th extraction is performed based on a preset - granularity extraction unit, and i is a positive integer greater than or equal to 1; a second parsing module configured to perform an (i + 1)-th parsing on the (i + 1)-th training test case according to the (i + 1)-th keyword; a loop module configured to loop through the steps in the second extraction module and the second parsing module until the proportion of the n - th training test case with parsing failure in the n - th training test cases is less than a preset threshold, where n is the number of extractions when the proportion of the training test cases with parsing failure in the current training test cases is less than the preset threshold, and n is a positive integer greater than or equal to i + 1; a keyword - obtaining module configured to obtain a keyword set including the n - th keyword when the proportion of the training test cases with parsing failure in the n - th training test cases is less than the preset threshold; and an obtaining module configured to parse the full - volume test cases based on the keyword set to obtain automated test cases.

[0016] A third aspect of the present disclosure provides an electronic device, including: one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are caused to execute the above method.

[0017] A fourth aspect of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, and when the instructions are executed by a processor, the processor is caused to execute the above method.

[0018] A fifth aspect of the present disclosure further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the above method is implemented. Description of the Drawings

[0019] Through the following description of the embodiments of the present disclosure with reference to the drawings, the above content and other objects, features, and advantages of the present disclosure will become clearer. In the drawings:

[0020] Figure 1 Schematically shows an application scenario diagram of the automated test case generation method according to an embodiment of the present disclosure.

[0021] Figure 2 Schematically shows a flowchart of the automated test case generation method according to an embodiment of the present disclosure.

[0022] Figure 3 Schematically shows a flowchart of the method for the first extraction of sample test cases according to an embodiment of the present disclosure.

[0023] Figure 4 Schematically shows a flowchart of the method for the first extraction of sample test cases according to some other embodiments of the present disclosure.

[0024] Figure 5 Schematically shows a flowchart of the method for parsing the first training test case according to a first keyword according to an embodiment of the present disclosure.

[0025] Figure 6 Schematically shows a flowchart of the method for the (i + 1)-th extraction of the i-th training test case to obtain the (i + 1)-th keyword according to an embodiment of the present disclosure.

[0026] Figure 7 Schematically shows a flowchart of the method for parsing all test cases based on the keyword set to obtain automated test cases.

[0027] Figure 8 Schematically shows a structural block diagram of the automated test case generation device according to an embodiment of the present disclosure.

[0028] Figure 9 A block diagram of an electronic device suitable for implementing an automated test case generation method according to an embodiment of the present disclosure is schematically shown. Detailed implementation manners

[0029] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present disclosure. In the following detailed description, for the sake of explanation, many specific details are set forth in order to provide a thorough understanding of the embodiments of the present disclosure. However, it is obvious that one or more embodiments may be implemented without these specific details. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily obscuring the concepts of the present disclosure.

[0030] The terms used herein are merely for describing specific embodiments and are not intended to limit the present disclosure. The terms "including", "comprising" and the like used herein indicate the presence of the described features, steps, operations and / or components, but do not exclude the presence or addition of one or more other features, steps, operations or components.

[0031] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those of ordinary skill in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0032] In the case of using expressions such as "at least one of A, B, and C", generally, it should be interpreted according to the meaning commonly understood by those of ordinary skill in the art (for example, "a system having at least one of A, B, and C" should include, but is not limited to, a system having only A, only B, only C, having A and B, having A and C, having B and C, and / or having A, B, and C).

[0033] It should be noted that the automated test case generation methods, devices, equipment, media, and program products provided by the embodiments of the present disclosure can be used in the field of testing technology for aspects related to automated test case generation, and can also be used in a variety of fields other than the testing technology field, such as the financial field. The application fields of the automated test case generation methods, devices, equipment, media, and program products provided by the embodiments of the present disclosure are not limited.

[0034] Embodiments of the present disclosure provide an automated test case generation method, which is characterized by including the following steps: S1. Based on an extraction unit with a preset granularity, perform a first extraction on a sample test case to obtain a first keyword; S2. Parse the first training test case for the first time according to the first keyword; S3. Perform an (i + 1)-th extraction on the i-th training test case with a parsing failure to obtain an (i + 1)-th keyword, where the (i + 1)-th extraction is performed based on an extraction unit with a preset granularity, and i is a positive integer greater than or equal to 1; S4. Parse the (i + 1)-th training test case for the (i + 1)-th time according to the (i + 1)-th keyword; S5. Loop through steps S3 - S4 until the proportion of the n-th training test case with a parsing failure in the n-th training test cases is less than a preset threshold; S6. When the proportion of the training test cases with a parsing failure in the n-th training test cases is less than a preset threshold, obtain a keyword set, where the keyword set includes the n-th keyword; and S7. Parse the full-scale test cases based on the keyword set to obtain automated test cases, where n is the number of extractions when the proportion of the training test cases with a parsing failure in the current training test cases is less than a preset threshold, and n is a positive integer greater than or equal to i + 1.

[0035] Figure 1 FIG. schematically shows an application scenario diagram of the automated test case generation method according to an embodiment of the present disclosure.

[0036] As Figure 1 shown, the application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0037] Users may use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0038] The terminal devices 101, 102, 103 may be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, and desktop computers, etc.

[0039] Server 105 may be a server that provides various services, such as a background management server (for example only) that supports websites browsed by users using terminal devices 101, 102, and 103. The background management server may analyze and process data such as user requests received, and feedback the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.

[0040] It should be noted that the automatic test case generation method provided by the embodiments of the present disclosure can generally be executed by server 105. Correspondingly, the automatic test case generation device provided by the embodiments of the present disclosure can generally be set in server 105. The automatic test case generation method provided by the embodiments of the present disclosure can also be executed by a server or a server cluster different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the automatic test case generation device provided by the embodiments of the present disclosure can also be set in a server or a server cluster different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105.

[0041] It should be understood that Figure 1 the numbers of terminal devices, networks, and servers in

[0042] are merely illustrative. According to the implementation requirements, there can be any number of terminal devices, networks, and servers. Figure 1 The following will be based on Figures 2 to 7 the described scenario, and will describe the automatic test case generation method of the public embodiments in detail through

[0043] Figure 2 FIG. schematically shows a flowchart of the automatic test case generation method according to an embodiment of the present disclosure.

[0044] As Figure 2 shown, the automatic test case generation method of this embodiment includes operations S210 to S270.

[0045] In operation S210, based on an extraction unit of a preset granularity, a first extraction is performed on the sample test case to obtain a first keyword.

[0046] According to an embodiment of the present disclosure, the first keyword is a keyword obtained from sample test cases. In an embodiment of the present disclosure, sample test cases can be selected in units of functional modules. Among them, the functional modules can be selected based on the coarsest granularity that ordinary testers are used to. For example, the functional module can be a front-end program product, such as the main functional modules in Web applications and desktops. In a typical example, the front-end program product can be an online bank, and the functional module can be the transfer function in the online bank. It can be understood that the main functional module may include multiple scenario modules. At this time, in order to improve the accuracy of keyword extraction, the single scenario in the main function can be further used as the functional module. For example, the public-to-public transfer of the transfer function in the online bank is used as the functional module. By selecting test cases in different scenarios, sample test cases can be obtained, that is, the sample test cases can be a case set of test cases containing multiple scenarios. Among them, for the number of test cases selected in each application scenario, it can be selected as needed based on the keyword accuracy requirements and data processing volume requirements. Correspondingly, the first keyword can be a keyword set, which can contain one or more keywords. Each keyword input can include modes such as empty, single value, and single group value. Among them, "empty" can correspond to no input box, and typically can include forms such as drop-down boxes and selections for input. "Single value" can correspond to a form in which the input content includes one parameter. A typical single value can be "query and reply content", and a single group value can correspond to a form in which the input content includes two or more parameters. A typical single group value includes "username|password".

[0047] It can be understood that sample test cases are usually composed of statements. Each case statement can correspond to the operation process of one page in a functional module; one case statement can also correspond to the operation process of multiple pages in a functional module. In order to further improve the accuracy of keyword extraction and improve the robustness of the automated test case generation method in the embodiments of the present disclosure, it can be combined with Figure 3 or Figure 4 The method presets the extraction unit granularity and performs a first extraction on the sample test cases to obtain the first keyword.

[0048] Figure 3 The flowchart of the method for performing the first extraction on the sample test cases according to the embodiments of the present disclosure is schematically shown.

[0049] As Figure 3 shown, the method for performing the first extraction on the sample test cases in this embodiment includes operation S310.

[0050] In operation S310, when the sample test case statement corresponds to a single page, the sample test case statement is used as the extraction unit for the first extraction to obtain the first keyword.

[0051] According to an embodiment of the present disclosure, when the sample test case statement exactly corresponds to a single page, it preferably adheres to the test habits of ordinary testers, and thus the first keyword extraction can be performed with this single statement as the extraction unit.

[0052] According to some other embodiments of the present disclosure, when the sample test case statement corresponds to multiple pages, in order to achieve better granularity encapsulation, double encapsulation can be performed to extract the first keyword.

[0053] Figure 4 A flowchart of a method for first extraction of a sample test case according to some other embodiments of the present disclosure is schematically shown.

[0054] As Figure 4 shown, the method for first extraction of a sample test case in this embodiment includes operations S410 to S420.

[0055] In operation S410, when the sample test case statement corresponds to m pages, the statement part corresponding to each page is used as the first extraction unit to extract m sub-keywords.

[0056] In operation S420, the m sub-keywords are encapsulated to obtain the first keyword corresponding to the sample test case statement.

[0057] According to some other embodiments of the present disclosure, when the sample test case statement corresponds to m pages (m is a positive integer greater than or equal to 1), in order to achieve better granularity encapsulation, the sample test case statement can be first divided according to the part corresponding to a single page to obtain extraction sub-units, keywords are extracted for each extraction sub-unit to obtain m sub-keywords corresponding to m pages, which is the first-level encapsulation; the m sub-keywords are encapsulated again to obtain the first keyword corresponding to a single sample test case statement, which is the second-level encapsulation. Through the second-level encapsulation, the tester friendliness is improved and it is beneficial to keyword maintenance.

[0058] In operation S220, the first training test case is first parsed according to the first keyword.

[0059] Figure 5 A flowchart of a method for parsing the first training test case according to the first keyword according to an embodiment of the present disclosure is schematically shown.

[0060] As Figure 5 shown, the method for parsing the first training test case according to the first keyword in this embodiment includes operations S510 to S530.

[0061] In operation S510, based on the first keyword, the training and testing case is parsed into a case keyword name and a case input value, where the first keyword includes a first keyword name and a first keyword input value type.

[0062] In operation S520, a first judgment is performed. The first judgment includes determining whether the case keyword name matches the first keyword name; and

[0063] In operation S530, when the case keyword name matches the first keyword name, a second judgment is performed. The second judgment includes determining whether the case input value matches the first keyword input value type.

[0064] According to an embodiment of the present disclosure, when both the first judgment and the second judgment are successfully matched, it is determined that the case parsing is successful.

[0065] According to an embodiment of the present disclosure, the first keyword includes a first keyword name and a first keyword input value type. The first training and testing case can be parsed into a combination of a case keyword name and a case input value. And based on the matching degree between the case keyword name and the first keyword name, and the matching degree between the case input value and the first keyword input value type, it is determined whether the parsing is successful. A typical example is that a certain statement in the first training and testing case is "Log in as operator ABC, password 123456". The keyword names in the extracted first keyword (actually a keyword set containing multiple keywords) are taken one by one to match the affixes in the statement; when the keyword name "Log in" is successfully matched, according to the defined first keyword input value type, for example, defined as "{Username (type English) (Special rule: The username field can be omitted)|Password (type number)}", the subsequent fields of the same type in the statement, "ABC" and "123456", are extracted as the input values of the keyword; the part that cannot be matched is the part of the matching failure, and finally the parsing result is generated. Among them, special rules can be set according to the testing habits of testers to reduce the impact of differences in case writing styles on the parsing result and improve the effectiveness of the automated test case generation method of the embodiment of the present disclosure. For example, according to the above typical example, when the case statement does not contain the username field, parsing can still be achieved due to the existence of special rules. It should be noted that in order to perform parsing more conveniently, the first training and testing case that conforms to the general test case template can be selected.

[0066] In an embodiment of the present disclosure, the parsing languages that can be used include but are not limited to JYTHON, PYTHON, JAVA, etc. The parsing language of the embodiment of the present disclosure is not limited. The method of the embodiment of the present disclosure does not depend on a specific environment, and the method of the embodiment of the present disclosure can be transplanted to each platform compatible with the language that can parse the training and testing case, and cooperate with other functional modules.

[0067] In operation S230, the (i + 1)-th extraction is performed on the i-th training and testing case with parsing failure to obtain the (i + 1)-th keyword, where the (i + 1)-th extraction is performed based on an extraction unit with a preset granularity, and i is a positive integer greater than or equal to 1.

[0068] In operation S240, the (i + 1)-th parsing is performed on the (i + 1)-th training and testing case according to the (i + 1)-th keyword.

[0069] In operation S250, it is determined whether the proportion of the n-th training and testing case with parsing failure in the n-th training and testing cases is less than a preset threshold, where n is the extraction times when the proportion of the training and testing cases with parsing failure in the current training and testing cases is less than the preset threshold, and n is a positive integer greater than or equal to i + 1. When the proportion of the n-th training and testing case with parsing failure in the n-th training and testing cases is greater than the preset threshold, steps S230 - S240 are repeatedly executed;

[0070] In operation S260, when the proportion of the training and testing cases with parsing failure in the n-th training and testing cases is less than the preset threshold, a keyword set is obtained, and the keyword set includes the n-th keyword.

[0071] According to an embodiment of the present disclosure, in order to improve the accuracy of keyword extraction, the idea of deep learning can be borrowed. The testing cases are divided into sample testing cases and training and testing cases. The keywords extracted from the sample testing cases are used to parse the training and testing cases. Based on the parsing results, keywords are extracted again for the training and testing cases with parsing failure, and the training and testing cases of the corresponding functional modules are supplemented to verify the accuracy of the keywords extracted again until a keyword set that meets the preset accuracy determination condition is obtained. Among them, the selection method of the training and testing cases can be roughly the same as that of the sample testing cases, and the main difference is that for the same functional module, the number of selected cases is different for the two. For example, for a certain functional module, one case can be selected as the sample testing case, and multiple other cases for the same functional module can be selected as the training and testing cases.

[0072] In some specific embodiments, after extracting the first keyword based on the sample test case, the first training test case can be matched and parsed to verify the accuracy of the first keyword. For some cases with parsing failures, a second extraction can be performed to obtain the second keyword. It can be understood that, in order to better understand the test case, when performing the second extraction, all extraction units in the case with parsing failure can be analyzed to extract the second keyword. At this time, the second keyword can be an addition or correction to some of the first keywords with parsing failures. Among them, the granularity setting of the extraction unit can be the same as that in the first extraction, or can be adjusted based on the actual situation of training and the feedback of testers to ensure that the granularity setting is close to the test habits of ordinary testers. Further, after obtaining the second keyword, the original training test case with parsing failure can be parsed again, or a training test case corresponding to the same functional module can be reselected for parsing, or training test cases of the same functional module can be added to the original training test case with parsing failure for parsing. In the embodiments of the present disclosure, the above redefined training test case is used as the second training test case, and the second keyword is used to parse the second training test case.

[0073] According to the embodiments of the present disclosure, the above process of extracting the second keyword and the process of parsing the second training test case can be executed cyclically, that is, iteratively perform the (i + 1)-th extraction on the i-th training test case with parsing failure to obtain the (i + 1)-th keyword; perform the (i + 1)-th parsing on the (i + 1)-th training test case according to the (i + 1)-th keyword, where i is a positive integer greater than or equal to 1. In the embodiments of the present disclosure, the above cyclic execution process can be executed n times until the proportion of the n-th training test case with parsing failure in the n-th training test cases is less than a preset threshold, where n can be a positive integer greater than or equal to i + 1. At this time, a keyword set with relatively high accuracy is obtained, which includes the n-th keyword, where the n-th keyword can include multiple keywords that are close to the test habits of ordinary testers, conform to the writing habits of test case editors, and have a relatively high matching degree with each functional unit.

[0074] Figure 6 Schematically shows a flowchart of a method for performing the (i + 1)-th extraction on the i-th training test case according to the embodiments of the present disclosure to obtain the (i + 1)-th keyword.

[0075] As Figure 6 shown, the (i + 1)-th extraction on the i-th training test case and obtaining the (i + 1)-th keyword in this embodiment include operations S610 to S620.

[0076] In operation S610, analyze the type of failure reason based on the i-th training test case with parsing failure.

[0077] In operation S620, the i+1th extraction is performed on the training test case for which the parsing failed based on the failure reason type and its corresponding supplementary extraction method to obtain an i+1th keyword.

[0078] According to an embodiment of the present disclosure, before reaching a preset threshold, different supplementary extraction methods can be used to extract keywords next time based on different types of parsing failure reasons.

[0079] In some specific embodiments, when the failure reason type includes that the training test case where the parsing failed contains a functional module that is significantly different from the functional module corresponding to the i-th keyword, the i+1-th extraction may include: based on the functional module where the parsing failed, supplementary extraction of the i+1-th keyword.

[0080] According to a specific embodiment of the present disclosure, when a training test case that fails to parse contains a functional module that is significantly different from the functional module corresponding to the i-th keyword, it indicates that the i-th keyword is insufficient to cover the functional module in the training test case. At this time, a supplementary extraction method can be applied to make up for the missing keyword. The supplementary extraction can be performed using uncovered functional modules, or using training test cases that fail to parse and contain uncovered functional modules, or by supplementing training test cases that contain uncovered functional modules.

[0081] In some specific embodiments, when the reason type for parsing failure includes that the keyword name of the training test case in which the parsing failed matches the i-th keyword name, but its case input value does not match the i-th keyword input value type, the i+1th extraction includes: adjusting the keyword input type or adding a special rule for the keyword input type to obtain the i+1th keyword.

[0082] According to a specific embodiment of the present disclosure, when a case keyword name matches the i-th keyword name, but its case input value does not match the i-th keyword input value type, it indicates that the defined i-th keyword input value type is insufficient to cover the input value representation method of the current case keyword. At this time, matching can be achieved by adjusting the definition of the keyword input type or adding special rules for the keyword input type.

[0083] In some specific embodiments, when the reason type for parsing failure includes unsuccessful parsing, but the training test case in which the parsing failed contains a functional module that is slightly different from the functional module corresponding to the i-th keyword, the i+1 extraction includes: adding a fuzzy match for the i-th keyword to form a keyword name group to obtain the i+1-th keyword.

[0084] According to an embodiment of the present disclosure, due to differences in the habits of training and test case writers, different keywords may be used when describing the same or similar functional modules. A typical example is that for the same "login" functional module, the keyword is "login", tester A writes it as "login", tester B writes it as "entry", and tester C writes it as "input". At this time, if only the keyword "login" is extracted, it may cause the keyword to not match the "entry" and "input" modules with the same or similar functions. In the embodiment of the present disclosure, a keyword name group can be formed by adding fuzzy matching of keywords. For example, "entry", "input", and "login" are encapsulated into a keyword name group, and the keywords in the keyword name group are matched one by one with the affixes in the training and test cases to improve the success rate of parsing and reduce the maintenance cost of automated test cases. It should be noted that when adding fuzzy matching of keywords, it can be extracted not only from the training and test cases with parsing failures, but also by collecting feedback from testers or combining the experience of developers themselves. By introducing fuzzy matching to supplement the mapping relationship between the affixes and keywords of the training and test cases, the reliability of the mapping is enhanced.

[0085] In operation S270, the full set of test cases is parsed based on the keyword set to obtain automated test cases.

[0086] According to an embodiment of the present disclosure, after obtaining the keyword set, it can be input into the parsing of automated test cases. It can be understood that after training, the keyword set at least includes the nth keyword, where n is the number of extractions when the proportion of training and test cases with parsing failures in the current training and test cases is less than a preset threshold, and n is a positive integer greater than or equal to i + 1. It can be understood that the keyword set may also include the first keyword that has been successfully parsed and is not included in the nth keyword, as well as the keywords extracted from the training and test cases that have been successfully parsed in previous times. It can be understood that in some cases, the extracted first keyword has a high success rate when parsing the first training and test case. For example, the proportion of the first training and test case with parsing failure in the full set of the first training and test cases is less than the preset threshold. At this time, the first keyword can be directly used as the keyword set and input into the parsing of the full set of test cases to generate automated test cases.

[0087] According to an embodiment of the present disclosure, before parsing the full set of test cases based on the keyword set to obtain automated test cases, the method further includes: establishing a mapping relationship between the keyword set and automated test code to obtain an automated test script.

[0088] According to an embodiment of the present disclosure, before parsing all test cases, the obtained keyword set can be implemented in code, and a relationship table between the keyword set and functions can be sorted out. Specifically, for the keyword set obtained through training, each keyword name in the keyword set can be associated with a function name, and further the function can be implemented using appropriate code to complete the two-layer mapping of all test cases-keyword-code (the mapping relationship is one-to-one), so as to obtain an automated test script, realizing the direct application of all test cases to automated testing and reducing the threshold for testers to participate in automated testing.

[0089] Figure 7 A flowchart of a method for parsing all test cases based on the keyword set to obtain automated test cases is schematically shown.

[0090] As Figure 7 shown, the parsing of all test cases based on the keyword set in this embodiment to obtain automated test cases includes operations S710 to S730.

[0091] In operation S710, information on parsing failure cases is recorded.

[0092] In operation S720, the ratio of the number of parsing failure cases to the number of completed parsing cases is calculated.

[0093] In operation S730, when the ratio is greater than or equal to a preset threshold, the keyword set is manually maintained.

[0094] According to an embodiment of the present disclosure, after parsing all test cases, the ratio of the number of parsing failure cases to the number of completed parsing cases can be calculated again to further select whether manual maintenance of the keyword set is required. Among them, the preset threshold can be determined based on the requirements for the parsing success rate of automated test cases and human resources. For example, the threshold can be lowered when there are more resources, and vice versa when there are fewer resources. When the ratio is higher than the threshold, maintenance personnel can intervene and re-extract keywords and parse the training test cases according to the keyword extraction and parsing method of the embodiment of the present disclosure.

[0095] According to an embodiment of the present disclosure, when the ratio is less than the preset threshold, the method further includes: archiving all parsed test cases and performing irregular manual spot checks. Through manual spot checks, the correctness of the parsing can be viewed irregularly. At the same time, when the test case editors make adjustments or there are large-scale changes in functions, manual maintenance can also be immediately enabled to improve the applicability of the keyword set.

[0096] According to the embodiments of the present disclosure, the keyword set can be promoted to testers from time to time to make the subsequent test case editing closer to the automated translation system. For example, the test case editor can be guided to edit the test case in combination with the keyword set. For situations where promotion is inconvenient, the tester is also advised to edit in a single test case in units of the functional modules of the embodiments of the present disclosure to reduce system maintenance costs.

[0097] The embodiments of the present disclosure directly parse test cases based on encapsulated keywords, thereby lowering the threshold for testers to intervene in automated testing. The accuracy of keyword encapsulation is improved based on deep learning algorithms, and the success rate of automated testing is greatly improved. It can also be applied to all software life cycles involved in automated testing, including development and debugging, user testing, production and maintenance green lights, etc., reducing the technical barriers from non-automated test developers to automated test developers, increasing the participation of automated testing, and thus reducing software development costs.

[0098] Based on the above method, the present disclosure also provides an automated test case generation device. Figure 8 The device is described in detail.

[0099] Figure 8 The structural block diagram of the automatic test case generation device according to the embodiment of the present disclosure is schematically shown.

[0100] like Figure 8 As shown, the automated test case generating device 800 of this embodiment includes a first extraction module 810 , a first parsing module 820 , a second extraction module 830 , a second parsing module 840 , a loop module 850 , a keyword acquiring module 860 , and a testing module 870 .

[0101] The first extraction module 810 is configured to perform a first extraction on the sample test case based on an extraction unit of a preset granularity to obtain a first keyword.

[0102] The first parsing module 820 is configured to train a first test case according to the first keyword.

[0103] The second extraction module 830 is configured to perform an i+1th extraction on the i-th training test case that failed to be parsed, and obtain the i+1th keyword, wherein the i+1th extraction is performed based on an extraction unit of a preset granularity, and i is a positive integer greater than or equal to 1.

[0104] The second parsing module 840 is configured to perform an i+1th parsing on the i+1th training test case according to the i+1th keyword.

[0105] The loop module 850 is configured to loop through the steps in the second extraction module and the second parsing module until the proportion of the nth training and testing case with parsing failure in the nth training and testing cases is less than a preset threshold, where n is the number of extractions when the proportion of the training and testing cases with parsing failure in the current training and testing cases is less than the preset threshold, and the n is a positive integer greater than or equal to i + 1.

[0106] The keyword acquisition module 860 is configured to acquire a keyword set including the nth keyword when the proportion of the training and testing cases with parsing failure in the nth training and testing cases is less than the preset threshold.

[0107] The testing module 870 is configured to parse all the testing cases based on the keyword set to obtain automated testing cases.

[0108] According to an embodiment of the present disclosure, any one or more of the first extraction module 810, the first parsing module 820, the second extraction module 830, the second parsing module 840, the loop module 850, the keyword acquisition module 860, and the testing module 870 may be combined and implemented in one module, or any one of them may be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules may be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the first extraction module 810, the first parsing module 820, the second extraction module 830, the second parsing module 840, the loop module 850, the keyword acquisition module 860, and the testing module 870 may be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on substrate, a system on package, an application specific integrated circuit (ASIC), or any other reasonable way of integrating or packaging circuits, etc., implemented by hardware or firmware, or implemented in any one of the three implementation manners of software, hardware, and firmware, or in any appropriate combination of several of them. Alternatively, at least one of the first extraction module 810, the first parsing module 820, the second extraction module 830, the second parsing module 840, the loop module 850, the keyword acquisition module 860, and the testing module 870 may be at least partially implemented as a computer program module, and when the computer program module is run, it can execute the corresponding functions.

[0109] Figure 9 Schematically shows a block diagram of an electronic device suitable for implementing the automated testing case generation method according to an embodiment of the present disclosure.

[0110] As Figure 9As shown, an electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage section 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general microprocessor (such as a CPU), an instruction set processor, and / or a related chipset, and / or a dedicated microprocessor (such as an application specific integrated circuit (ASIC)), etc. The processor 901 may also include on-board memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0111] In the RAM 903, various programs and data required for the operation of the electronic device 900 are stored. The processor 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. The processor 901 performs various operations of the method flow according to an embodiment of the present disclosure by executing the program in the ROM 902 and / or the RAM 903. It should be noted that the program may also be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also perform various operations of the method flow according to an embodiment of the present disclosure by executing the program stored in the one or more memories.

[0112] According to an embodiment of the present disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, and the input / output (I / O) interface 905 is also connected to the bus 904. The electronic device 900 may further include one or more of the following components connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed so that a computer program read from it can be installed into the storage section 908 as needed.

[0113] The present disclosure also provides a computer-readable storage medium, which may be included in the device / device / system described in the above embodiments; or may exist separately without being assembled into the device / device / system. The above computer-readable storage medium carries one or more programs, and when the one or more programs are executed, the method according to an embodiment of the present disclosure is implemented.

[0114] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example, but is not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the above-described ROM 902 and / or RAM 903 and / or one or more memories other than ROM 902 and RAM 903.

[0115] An embodiment of the present disclosure further includes a computer program product, which includes a computer program that contains program code for executing the method shown in the flowchart. When the computer program product runs in a computer system, the program code is used to cause the computer system to implement the method provided by the embodiment of the present disclosure.

[0116] When the computer program is executed by the processor 901, it executes the above functions defined in the system / apparatus of the embodiment of the present disclosure. According to an embodiment of the present disclosure, the above-described system, apparatus, module, unit, etc. may be implemented by computer program modules.

[0117] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices and magnetic storage devices. In another embodiment, the computer program may also be transmitted and distributed in the form of a signal on a network medium, and downloaded and installed through the communication part 909, and / or installed from the removable medium 911. The program code included in the computer program may be transmitted by any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0118] In such an embodiment, the computer program may be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, it executes the above functions defined in the system of the embodiment of the present disclosure. According to an embodiment of the present disclosure, the above-described system, device, apparatus, module, unit, etc. may be implemented by computer program modules.

[0119] According to embodiments of the present disclosure, program code for executing the computer programs provided by the embodiments of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. The programming languages include, but are not limited to, programming languages such as Java, C++, Python, the "C" language, or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., by using an Internet service provider to connect through the Internet).

[0120] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks can occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, and combinations of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0121] Those skilled in the art can understand that the features recited in the various embodiments and / or claims of the present disclosure can be combined or / and combined in various ways, even if such combinations or combinations are not explicitly recited in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features recited in the various embodiments and / or claims of the present disclosure can be combined and / or combined in various ways. All such combinations and / or combinations fall within the scope of the present disclosure.

[0122] The embodiments of the present disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments have been described separately above, this does not mean that the measures in each embodiment cannot be used advantageously in combination. The scope of the present disclosure is defined by the appended claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art can make various substitutions and modifications, and these substitutions and modifications should fall within the scope of the present disclosure.

Claims

1. An automated test case generation method, characterized in that, it includes the following steps: S1. Based on an extraction unit with a preset granularity, perform a first extraction on the sample test case to obtain the first keyword; S2. Perform a first parsing on the first training test case according to the first keyword; S3. Perform an (i + 1)-th extraction on the second training test case to obtain the (i + 1)-th keyword, where the (i + 1)-th extraction is performed based on an extraction unit with a preset granularity, i is a positive integer greater than or equal to 1, and the second training test case is the training test case with parsing failure; S4. Perform an (i + 1)-th parsing on the second training test case according to the (i + 1)-th keyword; S5. Loop and execute steps S3 - S4 until the proportion of the n-th training test case with parsing failure in the n-th training test case is less than a preset threshold; S6. When the proportion of the training test case with parsing failure in the n-th training test case is less than a preset threshold, obtain a keyword set, the keyword set includes the n-th keyword, where n is the extraction times when the proportion of the training test case with parsing failure in the current training test case is less than a preset threshold, and n is a positive integer greater than or equal to i + 1; and S7. Based on the keyword set, perform parsing on the full-scale test case to obtain an automated test case; wherein, the performing a first parsing on the first training test case according to the first keyword includes: Based on the first keyword, parse the first training test case into a case keyword name and a case input value, where the first keyword includes a first keyword name and a first keyword input value type; Perform a first judgment, the first judgment includes judging whether the case keyword name and the first keyword name match; and When the case keyword name and the first keyword name match, perform a second judgment, the second judgment includes judging whether the case input value matches the first keyword input value type, When both the first judgment and the second judgment are successfully matched, it is determined that the case parsing is successful.

2. The method according to claim 1, wherein, the performing an (i + 1)-th extraction on the second training test case to obtain the (i + 1)-th keyword includes: Analyze the failure reason type based on the second training test case; and Based on the failure reason type and its corresponding supplementary extraction method, perform an (i + 1)-th extraction on the second training test case to obtain the (i + 1)-th keyword.

3. The method according to claim 2, wherein, When the failure reason type includes that the training test case with parsing failure contains a functional module with a large difference from the functional module corresponding to the i-th keyword, the (i + 1)-th extraction includes: Based on the functional module with parsing failure, supplement and extract the (i + 1)-th keyword.

4. The method according to claim 2, wherein, When the parsing failure reason type includes that the keyword name of the training test case with parsing failure matches the i-th keyword name, but its case input value does not match the i-th keyword input value type, the (i + 1)-th extraction includes: Adjust the keyword input type or add special rules for the keyword input type to obtain the (i + 1)-th keyword.

5. The method according to claim 2, wherein, when the cause type of the parsing failure includes unsuccessful parsing, and the training and testing cases of the parsing failure contain functional modules with minor differences from the functional modules corresponding to the i-th keyword, the (i + 1)-th extraction includes: Adding fuzzy matching of the i-th keyword to form a keyword name group to obtain the (i + 1)-th keyword.

6. The method according to claim 1, wherein, before parsing all test cases based on the keyword set to obtain automated test cases, the method further includes; Establishing a mapping relationship between the keyword set and automated test code to obtain an automated test script.

7. The method according to claim 1, wherein, the parsing all test cases based on the keyword set to obtain automated test cases includes: Recording the information of the parsing failure cases; Calculating the ratio of the number of parsing failure cases to the number of parsed cases; and When the ratio is greater than or equal to a preset threshold, manually maintaining the keyword set.

8. The method according to claim 7, wherein, when the ratio is less than the preset threshold, the method further includes: Archiving all the parsed test cases and conducting irregular manual spot checks.

9. The method according to claim 1, wherein, the first extraction of the sample test cases based on the extraction unit of the preset granularity includes: When the sample test case statement corresponds to a single page, using the sample test case statement as the extraction unit for the first extraction to obtain the first keyword.

10. The method according to claim 9, wherein, the first extraction of the sample test cases based on the extraction unit of the preset granularity further includes: When the sample test case statement corresponds to m pages, using the statement part corresponding to each page as the extraction sub-unit to extract m sub-keywords; and Encapsulating the m sub-keywords to obtain the first keyword corresponding to the sample test case statement, where m is a positive integer greater than or equal to 1.

11. An automated test case generation device, characterized in that, comprising: A first extraction module configured to perform a first extraction on sample test cases based on an extraction unit of a preset granularity to obtain a first keyword; A first parsing module configured to perform a first parsing on the first training and testing cases according to the first keyword; A second extraction module configured to perform an (i + 1)-th extraction on the second training and testing cases to obtain the (i + 1)-th keyword, wherein the (i + 1)-th extraction is performed based on an extraction unit of a preset granularity, i is a positive integer greater than or equal to 1, and the second training and testing cases are the training and testing cases of the parsing failure; A second parsing module configured to perform an (i + 1)-th parsing on the second training and testing cases according to the (i + 1)-th keyword; A loop module, configured to loop through the steps in the second extraction module and the second parsing module until the proportion of the nth training and testing case with parsing failure in the nth training and testing cases is less than a preset threshold, where n is the number of extractions when the proportion of the training and testing cases with parsing failure in the current training and testing cases is less than the preset threshold, and the n is a positive integer greater than or equal to i + 1; A keyword acquisition module, configured to acquire a keyword set when the proportion of the training and testing cases with parsing failure in the nth training and testing cases is less than the preset threshold, and the keyword set includes the nth keyword, and A testing module, configured to parse all test cases based on the keyword set to obtain automated test cases; A first parsing module, configured to parse the first training and testing case into a case keyword name and a case input value based on the first keyword, where the first keyword includes a first keyword name and a first keyword input value type; perform a first judgment, the first judgment includes judging whether the case keyword name matches the first keyword name; and when the case keyword name matches the first keyword name, perform a second judgment, the second judgment includes judging whether the case input value matches the first keyword input value type, and when both the first judgment and the second judgment are successfully matched, determine that the case parsing is successful.

12. An electronic device, comprising: One or more processors; A storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are caused to execute the method according to any one of claims 1 to 10.

13. A computer-readable storage medium, having executable instructions stored thereon, which when executed by a processor cause the processor to execute the method according to any one of claims 1 to 10.

14. A computer program product, including a computer program, which when executed by a processor implements the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Application program testing method and device and storage medium

    CN110471858A

  • Interface testing method and device, equipment and storage medium

    CN113312258A