Test case generation method and device, terminal equipment and storage medium
By obtaining and parsing test requirement documents, extracting generation strategies and templates, and automatically generating and optimizing test cases, the problem of poor quality of automatically generated test cases is solved, the efficiency and quality of test case generation are improved, and the comprehensiveness of software functional testing is ensured. and accuracy.
Patent Information
- Application Number
- CN202411232013.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The quality of automatically generated test cases is poor and cannot effectively meet the needs of software functional testing.
By obtaining test requirement documents, parsing requirement information, extracting generation strategies and templates, generating test cases from the knowledge base, and optimizing them, the quality and coverage of test cases can be improved.
It realizes the automatic generation of high-quality test cases, improves the efficiency and coverage of test case generation, and ensures the comprehensiveness and accuracy of software functional testing.
Smart Images

Figure CN118733476A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of test case technology, and in particular, relates to a test case generation method, apparatus, terminal device and storage medium. Background Art
[0002] In the process of software development, it is often necessary to perform functional testing on the software, and in the process of functional testing, it is usually necessary to use test cases for functional testing. A test case is a set of input data, operation steps, and expected results compiled for a specific goal in order to test a program path or verify whether a specific requirement is met.
[0003] In the related art, automated tools can be used to automatically generate test cases, but the automatically generated test cases still have the problem of poor quality. Summary of the invention
[0004] The embodiments of the present application provide a method, apparatus, terminal device and storage medium for generating a test case, which can solve the problem of poor quality of automatically generated test cases in related technologies.
[0005] In a first aspect, an embodiment of the present application provides a method for generating a test case, the method comprising: Obtain test requirements document; Parse the requirement document and extract the requirement information; Extract corresponding generation strategies, generation templates and test information from the knowledge base according to the demand information; Generate test cases based on demand information, generation strategy, generation template and test information; Optimize the test case to obtain an optimized test case.
[0006] In a second aspect, an embodiment of the present application provides a test case generation device, comprising: Acquisition module, used to obtain test requirement documents; Parsing module, used to parse the requirement document and extract the requirement information; The extraction module is used to extract the corresponding generation strategy, generation template and test information from the knowledge base according to the demand information; A generation module is used to generate test cases based on requirement information, generation strategy, generation template and test information; The optimization module is used to optimize the test cases to obtain optimized test cases.
[0007] In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned test case generation method when executing the computer program.
[0008] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the above-mentioned test case generation method are implemented.
[0009] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the above-mentioned test case generation method.
[0010] The beneficial effect of the embodiment of the present application compared with the prior art is: the embodiment of the present application obtains the test requirement document, parses the requirement document, extracts the requirement information, and then extracts the corresponding generation strategy, generation template and test information from the knowledge base according to the requirement information, and then generates test cases according to the requirement information, generation strategy, generation template and test information, and optimizes the test cases to obtain optimized test cases. The embodiment of the present application extracts the generation strategy and generation template from the knowledge base, which can realize the automatic generation of test cases and improve the generation efficiency of test cases. The generated test cases can also be optimized to improve the quality and coverage of the test cases. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0012] Figure 1 It is a schematic diagram of an implementation flow of a method for generating a test case provided in an embodiment of the present application; Figure 2 It is a structural schematic diagram of a test case generation device provided in an embodiment of the present application; Figure 3 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0013] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are protected by the present application.
[0014] It should be noted that the terms "include", "comprises" and "have" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, terminal, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices. In the claims, specification and drawings of the present application, relational terms such as "first" and "second" are merely used to distinguish one entity / operation / object from another entity / operation / object, and do not necessarily require or imply any such real-time relationship or order between these entities / operations / objects.
[0015] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0016] In the process of software development, it is often necessary to perform functional testing on the software. In the process of functional testing, test cases are usually used for functional testing. A test case is a set of input data, operation steps, and expected results compiled for a specific goal in order to test a program path or verify whether a specific requirement is met. In related technologies, test cases can be automatically generated using automation tools. However, the quality of automatically generated test cases is still poor.
[0017] In view of this, the embodiment of the present application extracts generation strategies and generation templates from the knowledge base, can realize automatic generation of test cases, improve the generation efficiency of test cases, and can also optimize the generated test cases to improve the quality and coverage of the test cases.
[0018] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0019] Figure 1A schematic diagram of the implementation flow of a test case generation method provided in an embodiment of the present application is shown. The method can be applied to terminal devices, specifically smart phones, tablet computers, laptops, ultra-mobile personal computers (UMPCs), netbooks, etc.
[0020] Specifically, the above test case generation method may include the following steps S101 to S105.
[0021] Step S101, obtaining a test requirement document.
[0022] Among them, the test requirements document is a document that describes in detail the requirements, objectives, scope, methods, and other information of software testing.
[0023] In an implementation manner of the present application, the terminal device may obtain the test requirement document uploaded by the user.
[0024] Step S102: parse the requirement document to extract requirement information.
[0025] In the implementation manner of the present application, the terminal device can extract key requirement information in the requirement document by means of natural language processing.
[0026] Step S103, extracting corresponding generation strategies, generation templates and test information from the knowledge base according to the demand information.
[0027] Among them, the knowledge base is a database or file system that stores various generation strategies, generation templates, and test information related to software testing.
[0028] In the implementation manner of the present application, the terminal device can retrieve and extract the corresponding test case generation strategy, template and test information from the knowledge base according to the demand information.
[0029] Step S104, generating test cases according to the requirement information, generation strategy, generation template and test information.
[0030] In the implementation of the present application, the terminal device can combine the demand information, generation strategy, template and test information to generate test cases using an automated tool.
[0031] Step S105, optimizing the test case to obtain an optimized test case.
[0032] In an embodiment of the present application, the terminal device may optimize and merge similar or repeated test cases in the test cases generated in step S104 to improve their quality and effectiveness.
[0033] The beneficial effect of the embodiment of the present application compared with the prior art is: the embodiment of the present application obtains the test requirement document, parses the requirement document, extracts the requirement information, and then extracts the corresponding generation strategy, generation template and test information from the knowledge base according to the requirement information, and then generates test cases according to the requirement information, generation strategy, generation template and test information, and optimizes the test cases to obtain optimized test cases. The embodiment of the present application extracts the generation strategy and generation template from the knowledge base, which can realize the automatic generation of test cases and improve the generation efficiency of test cases. The generated test cases can also be optimized to improve the quality and coverage of the test cases.
[0034] In some implementations of the present application, after optimizing the test case to obtain the optimized test case, the method may further include steps S401 to S404.
[0035] Step S401, collecting the execution results of the optimized test cases.
[0036] In the implementation mode of the present application, after obtaining the optimized test case, the terminal device can execute the corresponding optimized test case and automatically collect the corresponding execution results. Specifically, it can include collecting the execution status of the test case, the passed and failed test cases, the defects found, etc. In addition, the terminal device can also collect the user's feedback after executing the optimized test case.
[0037] Step S402, statistical analysis is performed on the execution results and failure cause analysis to obtain analysis results, which include test information to be optimized and generation strategies to be optimized.
[0038] In the implementation of the present application, the terminal device can analyze the execution results through statistical tools (such as Excel, Python, etc.) and identify frequently failed test cases, high-risk functional modules, etc. The terminal device can also classify the failure reasons of the execution results, specifically, it can be an in-depth analysis of the failed test cases to determine the reasons for the failure, including checking the code implementation to confirm whether it is a code error, a deviation in the understanding of the requirements, or a test case design problem.
[0039] Step S403: When the analysis result includes test information to be optimized, the test information is updated according to the analysis result to obtain updated test information.
[0040] In some specific implementations of the present application, the above-mentioned updating of the test information according to the analysis result to obtain the updated test information may include steps S501 to S507.
[0041] Step S501, performing error analysis on the analysis result to determine the source of the error.
[0042] Step S502: Update the test information corresponding to the error source to obtain first updated test information.
[0043] Step S503: perform demand identification on the analysis results to obtain the demand to be updated.
[0044] Step S504: collecting update scenarios and update boundary conditions according to the requirements to be updated.
[0045] Step S505: determine the priorities of the update scenarios and update boundary conditions.
[0046] Step S506: Update the test information according to the priority by updating the scenario and the update boundary condition to obtain second updated test information.
[0047] Step S507: modify the weights and priorities of the relevant knowledge points in the test information according to the analysis result to obtain third updated test information.
[0048] In the implementation of the present application, when the analysis result corresponds to the test information to be optimized, that is, there is a problem with the test information, the terminal device can analyze the failed test cases, identify and analyze the test cases that caused the test failure, and pay special attention to those failures caused by knowledge base errors, and determine the source of the error, such as rule definition errors (the size and range of numerical values) or inaccurate interpretation of terms (such as abbreviations RPA, CMMI), etc. After determining the source of the error, the terminal device can update the test information corresponding to the source of the error, for example, reinterpret the terms, redefine the rules, etc., so as to obtain the first updated test information.
[0049] In addition, the terminal device can also identify new requirements from the execution results, user feedback, and new requirement documents to obtain requirements to be updated. Uncovered update scenarios and update boundary conditions are collected according to the requirements to be updated, and the importance and urgency of these update scenarios and update boundary conditions are evaluated to determine the corresponding priorities. Finally, according to the priorities of the update scenarios and update boundary conditions, the update scenarios and update boundary conditions are added to the test information to obtain the second update test information.
[0050] In addition, the terminal device can also analyze the application effect of the knowledge base based on the analysis results and user feedback, identify the areas that need adjustment, and modify the weights and priorities of relevant knowledge points in the knowledge base according to the determined adjustment direction. Specifically, it can modify the algorithm parameters or adjust the application logic of the rules, such as adjusting the output use case ratio of functional testing and performance testing.
[0051] The implementation methods of the present application can more accurately locate problems in test cases through error analysis and demand identification, and improve the quality of test cases. The coverage and robustness of test cases can be enhanced by collecting and designing updated scenarios and boundary conditions. By adjusting the weights and priorities of knowledge points, it can ensure that test cases can focus on important or high-risk knowledge points, and improve test efficiency.
[0052] Step S404: when the analysis result includes a generation strategy to be optimized, the generation strategy is optimized according to the analysis result to obtain an updated generation strategy.
[0053] In some specific implementations of the present application, the above-mentioned optimization of the generation strategy according to the analysis results to obtain the updated generation strategy may include steps S601 to S604.
[0054] Step S601 , performing coverage analysis and defect detection rate analysis on the analysis results to determine the generation strategy to be updated.
[0055] Among them, the generation strategy to be updated includes: implementation parameters, boundary value logic, and algorithm parameters.
[0056] Step S602: When the generation strategy to be updated includes implementation parameters, the coverage strategy in the implementation parameters is converted to obtain a first update generation strategy.
[0057] Step S603: When the generation strategy to be updated includes boundary value logic, the boundary value logic is updated to obtain a second updated generation strategy.
[0058] Step S604: when the generation strategy to be updated includes algorithm parameters, weight modification and threshold modification are performed on the algorithm parameters to obtain a third updated generation strategy.
[0059] In the implementation of the present application, the terminal device can identify the parameters that may need to be adjusted by analyzing the coverage and defect detection rate of the current test case. The terminal device can adjust the implementation parameters in the test case generation strategy according to the needs, specifically adjusting the coverage strategy, for example, switching from equivalence class partitioning to boundary value analysis, or increasing the proportion of decision table testing, to obtain the first update generation strategy.
[0060] In addition, the terminal device can also optimize the boundary value logic by improving the generation logic of the boundary value to ensure that the boundary conditions can be tested more effectively, thereby obtaining the second update generation strategy.
[0061] In addition, the terminal device may also adjust algorithm parameters, which may specifically include modifying weights, thresholds, etc., to optimize the generation quality of test cases, and obtain a third update generation strategy.
[0062] The implementation method of this application can more accurately identify deficiencies in the test case generation strategy through coverage and defect detection rate analysis. And by updating different aspects (implementation parameters, boundary value logic, algorithm parameters), the quality and effectiveness of test cases can be comprehensively improved, so that the optimized test case generation strategy can better adapt to changes in test requirements and improve test efficiency and software quality.
[0063] In some implementations of the present application, the above-mentioned optimization of the test case to obtain the optimized test case may specifically include steps S701 to S703.
[0064] Step S701: perform similarity recognition on all test cases to identify duplicate test cases or similar test cases.
[0065] In an embodiment of the present application, the terminal device may compare all test cases in pairs, thereby identifying repeated or similar test cases. This may be achieved by calculating the similarity between test cases, for example, using a text comparison algorithm or a hash algorithm.
[0066] Step S702: merge repeated test cases into a first optimized test case.
[0067] In an embodiment of the present application, the terminal device may merge multiple identified repeated test cases into one test case to reduce the number of test cases and improve test efficiency. When merging, you may choose to retain a representative test case, or merge multiple test cases into a more comprehensive test case.
[0068] Step S703: merge multiple similar test cases into one test case, and pass different parameters to obtain a second optimized test case.
[0069] In the implementation of the present application, the terminal device can combine multiple similar test cases into one test case through parameterization technology, and cover different test scenarios by passing different parameters. This can reduce the number of test cases while ensuring the comprehensiveness of the test.
[0070] The implementation method of the present application reduces the number of test cases by merging repeated and similar test cases, ensuring that the test covers more scenarios, thereby improving the comprehensiveness and execution efficiency of the test.
[0071] In some specific implementations of the present application, the above-mentioned requirement information may include: keywords, parameters, attributes, dependencies, implementation priorities, conditional logic and boundary conditions. The requirement document is parsed to extract the requirement information, which may specifically include steps S801 to S805.
[0072] Among them, keywords are words used to identify important concepts, functions or features in the requirements document, which help to quickly locate and understand the requirements. Parameters are specific values or data items that need to be input or considered in the process of function implementation, which have a direct impact on the execution results of the function. Attributes are characteristics or properties that describe entities (such as functions, objects, etc.), such as type, size, color, etc. Dependencies are interdependent relationships between different function points or components. The implementation of one function point may depend on the completion of another function point. Implementation priority is the order of implementation of each function point determined by business requirements, development resources and other factors. Conditional logic is a series of rules or judgment statements that describe how functions should be executed under different conditions. Boundary cases are extreme or special cases that may be encountered during the execution of a function, such as the maximum value, minimum value, and null value of the input value.
[0073] Step S801, formatting the demand document to obtain a converted document.
[0074] In an implementation manner of the present application, the terminal device may perform formatting processing to convert all required documents into a format that is easy to process, such as converting a document in PDF or image format into a text format, thereby obtaining a converted document.
[0075] Step S802, performing data cleansing on the converted document to obtain a cleansed document.
[0076] In an implementation manner of the present application, the terminal device may perform data cleaning on the converted document to remove irrelevant content (such as headers, footers, copyright information, etc.) in the converted document to reduce interference from noise data.
[0077] Step S803, parse the content of the cleaned document to extract corresponding keywords, functional points, parameters, and attributes.
[0078] In the implementation of the present application, the terminal device can perform content analysis on the cleansing document, specifically, it can use natural language processing technology to identify keywords and phrases in the document, such as "must", "must not", "should", etc. These words usually indicate mandatory requirements of the function. It can also identify specific functional points described in the document, such as "users can log in to the system", "the system should provide a password reset function", etc. In addition, the terminal device can also extract relevant parameters and attributes from the functional description, such as input parameters, output results, expected behaviors, etc.
[0079] Step S804: Determine the dependency relationship and implementation priority between different functional points.
[0080] In the implementation of the present application, the terminal device can perform dependency analysis between different function points to determine the dependency between different function points, such as some functions may need to be executed after other functions are completed, for example, the payment function depends on the shopping cart function. In addition, the terminal device can also determine the implementation priority of different requirements. For example, the user registration and login functions may need to take precedence over the recommendation system function development.
[0081] Step S805: extract corresponding conditional logic and boundary conditions from the function points.
[0082] In the implementation of the present application, the terminal device can analyze the conditional statements in the function points and extract various conditions and boundary conditions that need to be considered in the test. And build test scenarios based on the function points and logical relationships, where each scenario describes a series of operation steps and expected results. Conditional logic can be defined based on business logic. For example, if the shopping cart is empty, the user is not allowed to enter the payment page.
[0083] The implementation method of the present application can ensure that the test cases cover all important functional points, parameters, attributes, conditional logic and boundary conditions by performing detailed parsing and extraction of the requirement documents, thereby improving the accuracy and completeness of the test cases. By clarifying the dependencies and implementation priorities between the functional points, it can ensure that the writing order of the test cases matches the function implementation order, reducing the test omissions caused by missing dependent functional points. By formatting, cleaning the data and parsing the content of the requirement documents, the writing efficiency of the test cases can be significantly improved and the test cycle can be shortened.
[0084] In some specific implementations of the present application, the above-mentioned extraction of corresponding generation strategies, generation templates and test information from the knowledge base according to the demand information may specifically include steps S901 to S905.
[0085] Step S901, determining the test type according to the requirement information; Step S902, determining a test design method according to the requirement information; Step S903, determining a generation strategy and a generation template according to the test type and the test design method; Step S904, generating corresponding test information according to the demand information, and adding the test information to the knowledge base; Step S905, extracting generation strategies, generation templates and test information from the knowledge base.
[0086] In the implementation mode of the present application, the terminal device can determine the test type according to the nature of the demand information, such as functional test, performance test, safety test, etc. It is also possible to select a suitable test design method according to the test purpose in the demand information, such as equivalence class partitioning, boundary value analysis, decision table test, state transition test, etc. Then, according to different test types and test design methods, define the template of the test case, which may specifically include the basic structure and necessary fields of the test case, such as test case number, test title, precondition, test step, expected result, actual result, status, etc. And select or adapt the corresponding test case template according to the specific function point and test requirements. In addition, the terminal device can also define the test data according to the input parameters and attributes of the demand information. Specifically, it may include normal values, boundary values, abnormal values, etc., and use data generation tools or scripts to automatically generate corresponding test information, and add the test information to the knowledge base. At this time, the terminal device can extract the generation strategy, generation template and test information from the knowledge base.
[0087] The embodiment of the present application can greatly shorten the writing time of test cases and improve the test efficiency by preparing the generation strategy and template in the knowledge base in advance. The use of verified generation strategy and template helps to generate more comprehensive and accurate test cases, reduce omissions and errors, and improve the quality of test cases. In addition, by storing the test information in the knowledge base, it is convenient to reuse, modify and maintain the test cases in the future, which enhances the repeatability and maintainability of the test.
[0088] Figure 2 The schematic diagram of the structure of a test case generation device provided in an embodiment of the present application is shown. The test case generation device 2 can be configured on a terminal device. Specifically, the test case generation device 2 can include: Acquisition module 201, used to acquire test requirement document; The parsing module 202 is used to parse the demand document and extract the demand information; Extraction module 203, used to extract corresponding generation strategy, generation template and test information from the knowledge base according to the demand information; A generation module 204, for generating test cases according to the requirement information, generation strategy, generation template and test information; The optimization module 205 is used to optimize the test case to obtain an optimized test case.
[0089] The beneficial effect of the embodiment of the present application compared with the prior art is: the embodiment of the present application obtains the test requirement document, parses the requirement document, extracts the requirement information, and then extracts the corresponding generation strategy, generation template and test information from the knowledge base according to the requirement information, and then generates test cases according to the requirement information, generation strategy, generation template and test information, and optimizes the test cases to obtain optimized test cases. The embodiment of the present application extracts the generation strategy and generation template from the knowledge base, which can realize the automatic generation of test cases and improve the generation efficiency of test cases. The generated test cases can also be optimized to improve the quality and coverage of the test cases.
[0090] In some embodiments of the present application, the above-mentioned test case generation device 2 also includes an update module, which is used to: collect and optimize the execution results of the test cases; perform statistical analysis on the execution results and analyze the causes of failure to obtain analysis results, and the analysis results include test information to be optimized and generation strategies to be optimized; when the analysis results include test information to be optimized, update the test information according to the analysis results to obtain updated test information; when the analysis results include generation strategies to be optimized, optimize the generation strategies according to the analysis results to obtain updated generation strategies.
[0091] In some embodiments of the present application, the above-mentioned update module is also used to: perform error analysis on the analysis results to determine the source of the error; update the test information corresponding to the source of the error to obtain first updated test information; identify requirements on the analysis results to obtain requirements to be updated; collect update scenarios and update boundary conditions according to the requirements to be updated; determine the priority of the update scenarios and update boundary conditions; update the test information according to the priority scenarios and update boundary conditions to obtain second updated test information; modify the weights and priorities of relevant knowledge points in the test information according to the analysis results to obtain third updated test information.
[0092] In some embodiments of the present application, the update module is also used to: perform coverage analysis and defect detection rate analysis on the analysis results to determine the generation strategy to be updated, the generation strategy to be updated includes: implementation parameters, boundary value logic, and algorithm parameters; when the generation strategy to be updated includes implementation parameters, the coverage strategy in the implementation parameters is converted to obtain a first updated generation strategy; when the generation strategy to be updated includes boundary value logic, the boundary value logic is updated to obtain a second updated generation strategy; when the generation strategy to be updated includes algorithm parameters, the algorithm parameters are modified by weight and threshold to obtain a third updated generation strategy.
[0093] In some embodiments of the present application, the above-mentioned optimization module 205 is also used to: perform similarity recognition on all test cases to identify repeated test cases or similar test cases; merge repeated test cases into a first optimized test case; merge multiple similar test cases into one test case, and pass different parameters to obtain a second optimized test case.
[0094] In some embodiments of the present application, the requirement information includes: keywords, parameters, attributes, dependencies, implementation priorities, conditional logic and boundary conditions. The parsing module 202 is also used to: format the requirement document to obtain a converted document; perform data cleansing on the converted document to obtain a cleansed document; perform content parsing on the cleansed document to extract corresponding keywords, functional points, parameters, and attributes; determine the dependencies and implementation priorities between different functional points; and extract corresponding conditional logic and boundary conditions from the functional points.
[0095] In some embodiments of the present application, the extraction module 203 is also used to: determine the test type based on the requirement information; determine the test design method based on the requirement information; determine the generation strategy and generation template based on the test type and the test design method; generate corresponding test information based on the requirement information, and add the test information to the knowledge base; extract the generation strategy, generation template and test information from the knowledge base.
[0096] like Figure 3 3 is a schematic diagram of a terminal device provided in an embodiment of the present application. The terminal device 3 may include: a processor 301, a memory 302, and a computer program 303 stored in the memory 302 and executable on the processor 301, such as a test case generation program. When the processor 301 executes the computer program 303, the steps in the above-mentioned test case generation method embodiments are implemented, such as Figure 1 Alternatively, when the processor 301 executes the computer program 303, the functions of each module / unit in the above-mentioned device embodiments are implemented, for example Figure 2 The shown acquisition module 201, analysis module 202, extraction module 203, generation module 204, and optimization module 205.
[0097] The computer program may be divided into one or more modules / units, one or more modules / units are stored in the memory 302 and executed by the processor 301 to complete the present application. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.
[0098] The terminal device may include, but is not limited to, a processor 301 and a memory 302. Those skilled in the art will appreciate that Figure 3 It is only an example of a terminal device and does not constitute a limitation of the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.
[0099] The processor 301 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0100] The memory 302 may be an internal storage unit of the terminal device, such as a hard disk or memory of the terminal device. The memory 302 may also be an external storage device of the terminal device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device. Further, the memory 302 may also include both an internal storage unit of the terminal device and an external storage device. The memory 302 is used to store computer programs and other programs and data required by the terminal device. The memory 302 may also be used to temporarily store data that has been output or is to be output.
[0101] It should be noted that, for the convenience and brevity of description, the structure of the above-mentioned terminal device can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.
[0102] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0103] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned test case generation method can be implemented.
[0104] An embodiment of the present application provides a computer program product. When the computer program product is run on a mobile terminal, the steps in the above-mentioned test case generation method can be implemented when the mobile terminal executes the computer program product.
[0105] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0106] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0107] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0108] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0109] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0110] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0111] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for generating a test case, characterized in that: The method comprises: Obtain test requirements document; Parsing the requirement document to extract requirement information; Extracting corresponding generation strategies, generation templates and test information from the knowledge base according to the demand information; Generate a test case according to the requirement information, the generation strategy, the generation template and the test information; The test case is optimized to obtain an optimized test case.
2. The method for generating a test case according to claim 1, wherein: After optimizing the test case to obtain the optimized test case, the method further includes: Collecting the execution results of the optimized test cases; Performing statistical analysis on the execution results and failure cause analysis to obtain analysis results, wherein the analysis results include test information to be optimized and generation strategies to be optimized; When the analysis result includes test information to be optimized, updating the test information according to the analysis result to obtain updated test information; When the analysis result includes a generation strategy to be optimized, the generation strategy is optimized according to the analysis result to obtain an updated generation strategy.
3. The method for generating a test case according to claim 2, wherein: The updating of the test information according to the analysis result to obtain updated test information includes: Performing error analysis on the analysis results to determine the source of the error; Updating the test information corresponding to the error source to obtain first updated test information; Performing demand identification on the analysis results to obtain the demand to be updated; Collect update scenarios and update boundary conditions according to the requirements to be updated; Determining priorities of the update scenarios and the update boundary conditions; The test information is updated according to the priority by using the update scenario and the update boundary condition to obtain second updated test information; The weights and priorities of the relevant knowledge points in the test information are modified according to the analysis result to obtain third updated test information.
4. The method for generating a test case according to claim 2, wherein: The step of optimizing the generation strategy according to the analysis result to obtain an updated generation strategy includes: Performing coverage analysis and defect detection rate analysis on the analysis results to determine a generation strategy to be updated, wherein the generation strategy to be updated includes: implementation parameters, boundary value logic, and algorithm parameters; When the generation strategy to be updated includes the implementation parameter, converting the coverage strategy in the implementation parameter to obtain a first update generation strategy; When the generation strategy to be updated includes the boundary value logic, updating the boundary value logic to obtain a second updated generation strategy; When the generation strategy to be updated includes the algorithm parameters, the algorithm parameters are modified in weight and threshold to obtain a third updated generation strategy.
5. The method for generating a test case according to claim 1, wherein: The step of optimizing the test case to obtain an optimized test case includes: Performing similarity recognition on all the test cases to identify duplicate test cases or similar test cases; Merging the repeated test cases into a first optimized test case; The multiple similar test cases are merged into one test case, and different parameters are passed to obtain a second optimized test case.
6. The method for generating a test case according to claim 1, wherein: The requirement information includes: keywords, parameters, attributes, dependencies, implementation priorities, conditional logic and boundary conditions. The requirement document is parsed to extract the requirement information, including: Formatting the demand document to obtain a conversion document; Performing data cleaning on the converted document to obtain a cleaned document; Parsing the content of the cleaned document to extract the corresponding keywords, function points, parameters, and attributes; Determine the dependency relationship and implementation priority between different functional points; The corresponding conditional logic and the boundary conditions are extracted from the function points.
7. The method for generating a test case according to claim 1, wherein: The extracting corresponding generation strategies, generation templates and test information from the knowledge base according to the requirement information includes: Determine the test type according to the requirement information; Determine a test design method according to the requirement information; Determine the generation strategy and the generation template according to the test type and the test design method; Generate corresponding test information according to the demand information, and add the test information to the knowledge base; The generation strategy, the generation template and the test information are extracted from the knowledge base.
8. A test case generation device, characterized in that: include: Acquisition module, used to obtain test requirement documents; A parsing module, used to parse the demand document and extract demand information; An extraction module, used to extract corresponding generation strategies, generation templates and test information from the knowledge base according to the demand information; A generation module, used to generate a test case according to the requirement information, the generation strategy, the generation template and the test information; The optimization module is used to optimize the test case to obtain an optimized test case.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the test case generation method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the test case generation method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method for automatically generating testing cases
CN104123227A
Intelligent fuzzy test method, device and system
CN112181833A
Test case execution result analysis method and device, equipment and storage medium
CN113392000A
Test case generation method and device, electronic equipment and computer readable medium
CN113448869A
Test case generation method and device and test case display method and device
CN114328276A
