CN116737556A - Test case generation method and device, electronic equipment and readable storage medium - Google Patents
Test case generation method and device, electronic equipment and readable storage medium Download PDFInfo
- Publication number
- CN116737556A CN116737556A CN202310643934.6A CN202310643934A CN116737556A CN 116737556 A CN116737556 A CN 116737556A CN 202310643934 A CN202310643934 A CN 202310643934A CN 116737556 A CN116737556 A CN 116737556A
- Authority
- CN
- China
- Prior art keywords
- test
- result
- test case
- case
- description
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application provides a test case generation method, a test case generation device, electronic equipment and a readable storage medium, and relates to the technical field of computers. The method comprises the following steps: extracting target content from the obtained target brain graph file, wherein the target content comprises at least one step description, a first result corresponding to success, a second result corresponding to failure and a limiting condition set corresponding to each part of step description; generating corresponding steps to be selected according to each step description, wherein the step description of at least one corresponding limiting condition set corresponds to a plurality of steps to be selected generated based on the step description and the limiting condition set; and obtaining a plurality of test step sets by respectively selecting one to-be-selected step from the to-be-selected steps corresponding to each step description, and selecting a test result corresponding to each test step set from the two results. Therefore, a test step set and a test result in the test case can be accurately generated without writing very detailed test steps.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a test case generating method, a device, an electronic apparatus, and a readable storage medium.
Background
As internet technology advances and evolves, the quality and efficiency requirements of individual internet companies become higher and higher. How to improve the test efficiency and ensure the quality in the frequent and rapid iteration process, so that the work of the test case design becomes simpler and the dependence on the working experience of personnel is reduced, and the test cannot become the bottleneck in the whole project flow and is a problem to be solved by the technicians in the field all the time. Along with the wide application of the mind map, the test thinking can be rapidly presented, and the test review is also facilitated, so that the time of test design is greatly shortened, and the test case can be rapidly obtained.
However, at present, the method requires technicians to mark how many test cases are in the mind map and completely write out each step and corresponding test result needed by each test case. For example, it is necessary to write: the mind map includes test case 1 and test case 2, and after test case 1, each step and corresponding test result needed by test case 1 are clearly and completely written out, and similarly, each step and corresponding test result needed by test case 2 are clearly and completely written out after test case 2. The mode has the advantages that a technician is required to write very perfect information, so that the efficiency of generating test cases is affected; moreover, because the test results are manually written by a technician, the situation that the test results of different test cases are substantially the same but different modes are used for describing the test results can occur, namely, the test results are not standard; omission can also occur during manual writing, resulting in quality being compromised.
Disclosure of Invention
The embodiment of the application provides a test case generation method, a device, electronic equipment and a readable storage medium, which can enable technicians to generate accurate test steps in test cases without writing specific test steps in the test cases, thereby improving the generation efficiency of the test cases, avoiding the condition that test results are not standard and avoiding the condition of missing the cases in the manual writing process.
Embodiments of the application may be implemented as follows:
in a first aspect, an embodiment of the present application provides a test case generating method, where the method includes:
obtaining a target brain graph file comprising target content, and extracting the target content from the target brain graph, wherein the target content comprises at least one step description, a first result corresponding to success, a second result corresponding to failure, and a limiting condition set corresponding to each partial step description;
generating corresponding steps to be selected for each step description, wherein when the step descriptions correspond to the limiting condition sets, the corresponding steps to be selected are generated according to the step descriptions and the corresponding limiting condition sets, and at least one step description of the corresponding limiting condition sets corresponds to a plurality of steps to be selected;
And obtaining a plurality of test step sets by respectively selecting one to-be-selected step from the to-be-selected steps corresponding to each step description, and selecting test results corresponding to each test step set from the first result and the second result, wherein each test case comprises one test step set and one test result.
In a second aspect, an embodiment of the present application provides a test case generating apparatus, including:
the analysis module is used for obtaining a target brain graph file comprising target content and extracting the target content from the target brain graph, wherein the target content comprises at least one limiting condition set corresponding to each step description, a first successful result, a second failed result and part of step descriptions;
the step processing module is used for generating corresponding to-be-selected steps for each step description, wherein when the step descriptions correspond to the limiting condition sets, the corresponding to-be-selected steps are generated according to the step descriptions and the corresponding limiting condition sets, and at least one step description corresponding to the limiting condition sets corresponds to a plurality of to-be-selected steps;
the case generation module is used for obtaining a plurality of test step sets by respectively selecting one to-be-selected step from the to-be-selected steps corresponding to each step description, and selecting test results corresponding to each test step set from the first result and the second result, wherein each test case comprises one test step set and one test result.
In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, where the memory stores machine executable instructions that can be executed by the processor, and the processor may execute the machine executable instructions to implement the test case generating method described in the foregoing embodiment.
In a fourth aspect, an embodiment of the present application provides a readable storage medium having stored thereon a computer program which, when executed by a processor, implements the test case generating method described in the foregoing embodiments.
In the test case generating method, the device, the electronic equipment and the readable storage medium provided by the embodiment of the application, under the condition that the target brain graph file comprising the target content is obtained, the target content is extracted from the target brain graph file through analysis, and the target content comprises at least one step description, a first result which corresponds to success, a second result which corresponds to failure and a limiting condition set which corresponds to each part of step description. And generating a step to be selected corresponding to the step description for each step description, wherein when the step description corresponds to the limiting condition set, the corresponding step to be selected is generated according to the step description and the corresponding limiting condition set, and at least one step description corresponding to the limiting condition set corresponds to a plurality of steps to be selected. Finally, a plurality of test step sets are obtained by selecting one to-be-selected step from the to-be-selected steps corresponding to the step descriptions, and test results corresponding to the test step sets are selected from the first results and the second results, wherein each test case comprises one test step set and one test result. Therefore, a technician does not need to write specific test steps in each test case, and the test steps in the test case can be automatically and accurately generated based on related keywords in the brain graph file, so that the generation efficiency of the test case is improved, and meanwhile, the condition that test results are not standard and the condition that the test cases are omitted in the manual writing process are avoided.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic block diagram of an electronic device according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of a method for generating test cases according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a target brain map file according to an embodiment of the present application;
FIG. 4 is a second flow chart of a method for generating test cases according to an embodiment of the present application;
FIG. 5 is a schematic view of a portion of another object brain graphic file according to an embodiment of the present application;
FIG. 6 is a third flow chart of a method for generating test cases according to an embodiment of the present application;
FIG. 7 is a flowchart illustrating a method for generating test cases according to an embodiment of the present application;
FIG. 8 is a block diagram of a test case generating device according to an embodiment of the present application.
Icon: 100-an electronic device; 110-memory; a 120-processor; 130-a communication unit; 200-test case generating device; 210-a parsing module; 220-a step processing module; 230—use case generation module.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present application.
It is noted that relational terms such as "first" and "second", and the like, are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
Some embodiments of the present application are described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other without conflict.
Referring to fig. 1, fig. 1 is a block diagram of an electronic device 100 according to an embodiment of the application. The electronic device 100 may be, but is not limited to, a computer, a server, etc. The electronic device 100 may include a memory 110, a processor 120, and a communication unit 130. The memory 110, the processor 120, and the communication unit 130 are electrically connected directly or indirectly to each other to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines.
Wherein the memory 110 is used for storing programs or data. The Memory 110 may be, but is not limited to, random access Memory (Random Access Memory, RAM), read Only Memory (ROM), programmable Read Only Memory (Programmable Read-Only Memory, PROM), erasable Read Only Memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable Read Only Memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
The processor 120 is used to read/write data or programs stored in the memory 110 and perform corresponding functions. For example, the memory 110 stores therein a test case generating device 200, and the test case generating device 200 includes at least one software functional module that may be stored in the memory 110 in the form of software or firmware (firmware). The processor 120 executes various functional applications and data processing by running software programs and modules stored in the memory 110, such as the test case generating device 200 in the embodiment of the present application, that is, implements the test case generating method in the embodiment of the present application.
The communication unit 130 is configured to establish a communication connection between the electronic device 100 and other communication terminals through a network, and is configured to transmit and receive data through the network.
It should be understood that the structure shown in fig. 1 is merely a schematic diagram of the structure of the electronic device 100, and that the electronic device 100 may further include more or fewer components than those shown in fig. 1, or have a different configuration than that shown in fig. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
Referring to fig. 2, fig. 2 is a schematic flow chart of a test case generating method according to an embodiment of the present application. The method is applicable to the electronic device 100 described above. The specific flow of the test case generation method is described in detail below. In this embodiment, the method may include steps S110 to S130.
Step S110, a target brain graph file comprising target contents is obtained, and the target contents are extracted from the target brain graph.
In this embodiment, the target brain graphic file is a mind guide graphic file, for example, an Xmind file. The target brain graph file is a file for generating a test case, and can be specifically determined by combining with actual requirements. The target brain file comprises target content, and the target content is used for generating test cases subsequently. The target content may include at least one step description, a first result corresponding to success, a second result corresponding to failure, and a set of constraints corresponding to each of the partial step descriptions.
The number of step descriptions included in the target content may be only one or may be plural, which is specifically determined by the actual situation. The first result and the second result are possible results, the first result is a result for describing success, and the second result is a result for describing failure. At least a portion (e.g., 1 or more) of the step descriptions in the target content corresponds to a set of constraints, e.g., step description 1 corresponds to 1 set of constraints and step description 2 also corresponds to 1 set of constraints. The limiting condition set includes limiting conditions for describing the corresponding step, for example, a certain step is described as an input name, one limiting condition in the limiting condition set for describing the corresponding step is that the necessary data types are Chinese and letters, and the limiting conditions indicate that the names required to be input include Chinese and letters. The number of constraints in a set of constraints is specifically determined by the actual situation.
The target brain file may be edited by a technician and uploaded to the electronic device, or may be obtained in other manners, which are not specifically limited herein. Under the condition that the target brain graphic file is obtained, the target brain graphic file can be analyzed, so that the target content is obtained.
Step S120, for each step description, generating a corresponding candidate step.
In the case of extracting the step descriptions and the constraint condition sets in the target brain map file, a candidate step corresponding to the step description may be generated for each step description. Alternatively, for a step description that does not correspond to a set of constraint conditions, a candidate step corresponding to the step description may be generated directly according to the step description, and the candidate step corresponding to the step description may be only one. For a step description corresponding to a limited condition set, a candidate step corresponding to the step description may be generated according to the step description and the limited condition set corresponding to the step description, where the candidate step corresponding to the step description may be 1 or more. Since multiple test cases are generally required to be set for a requirement, at least one step description corresponding to a set of constraints corresponds to multiple steps to be selected.
Step S130, a plurality of test step sets are obtained by selecting one to-be-selected step from the to-be-selected steps corresponding to each step description, and test results corresponding to each test step set are selected from the first result and the second result.
Under the condition that the corresponding candidate steps of the step descriptions are obtained, a plurality of test step sets can be obtained by respectively selecting one candidate step from the corresponding candidate steps of the step descriptions. One test step set can be obtained through one-time selection, and multiple selections are performed until a new test step set can not be obtained any more, so that multiple test step sets are obtained, and the situation of missing use cases can be avoided. Use case deduplication may be performed after the selection is completed to avoid generating a duplicate set of test steps. It will be appreciated that the ordering of the test steps (i.e. the candidate steps) in the set of test steps is the same as the ordering described by their corresponding steps.
For example, step description 1 corresponds to the step to be selected 1, and step description 2 corresponds to the steps to be selected 21, 22. Then, in the first selection, the step 1 to be selected and the step 21 to be selected may be selected to obtain a test step set 1, where the test step set 1 includes the step 1 to be selected and the step 21 to be selected in sequence, and the sorting indicates that the step 1 to be selected is executed first and then the step 21 to be selected is executed. Similarly, during the second selection, the step 1 to be selected and the step 21 to be selected may be selected to obtain a test step set 2, where the test step set 2 includes the step 1 to be selected and the step 22 to be selected in sequence, and the sorting means that the step 1 to be selected is executed first and then the step 22 to be selected is executed.
Each test case comprises a test step set and a test result. Under the condition that one test step set is obtained or all test step sets are generated, test results corresponding to the test step sets can be selected from the first results and the second results. That is, one result is selected from the first result and the second result as a test result corresponding to one test step set. In this way, a plurality of test cases can be obtained.
In this embodiment, a complete test step set and test results corresponding to each test case are not required to be written in the mind map by a technician, and only the keywords of the step description, the first result, the second result and the limiting condition set corresponding to each of the partial step descriptions are required to be written, so that a plurality of executable automatic test cases can be accurately and automatically generated according to the content, and the generation efficiency of the test cases can be improved. Moreover, because the test result of each test case is determined from the written first result and second result instead of manually writing the test result of each test case by a technician, the test result in the test case can be standardized, and the situation that the test result is not standardized is avoided. Meanwhile, as the plurality of test step sets are obtained by adopting a permutation and combination mode aiming at the corresponding to-be-selected steps described by each step, the case omission condition which is easy to occur when the test case is manually written can be avoided.
Alternatively, the target brain graphic file may be a file that a technician writes according to a brain graphic template to facilitate converting test requirements into executable automated test cases. That is, the target brain map file may be generated based on the brain map template and the received writing operation for generating the target content.
As a possible implementation manner, as shown in fig. 3, the brain graph template may include the following contents: the first level is the project name; the second level is the module name; the third level is a function name; the fourth level is a use case title; the fifth stage is a precondition; the sixth stage is an operation step and a preset result; the seventh stage is the result of step description and success/failure; the eighth level is Action (i.e. a set of constraint conditions) and is mainly divided into data of operation type, character length, data type, padding, value, etc.
The item names are names of items corresponding to the generated test cases. The module name is the name of the module corresponding to the generated test case. The function name (or label) is a certain function of the module indicated by the second level, and is mainly divided into: new addition, modification, deletion, etc., and can be expanded according to actual requirements. The precondition is a precondition for executing the test case written by the technician. The sixth level includes two fields: and operating steps and presetting a result. The step descriptions are some description information about the test steps written by the technicians, and the success/failure results are specific results that may occur for the test cases. The types of operations in an Action can be divided into: input, selection box, etc., data types include: the number, special symbol, letter and Chinese type can be selected according to the actual situation.
The target brain graphic file generated based on the brain graphic template is illustrated below in conjunction with fig. 3. In the target brain graphic file shown in fig. 3, the item name of the first level is XX test item. The second level of module name "/test master module/module 1". The function name of the third stage is xx. The fourth level of use case is titled create vulnerability scanning task 1. The precondition of the fifth stage is logged in. The sixth level is two fields: and operating steps and presetting a result. The seventh stage of steps is described as 4: click vulnerability scanning 1; inputting a task name 1; selecting a port; click determination 1. The successful outcome of the seventh stage is: success: the loophole scanning task is successfully created, and the task list can be checked; the result of the failure of the seventh stage is: failure: the vulnerability scanning task creation fails.
Wherein, "input task name 1" corresponds to a constraint set 1, and the constraint set 1 includes the following constraints: operation type: inputting; filling: is; the data types that must be: chinese, alphabetic; there may be data types: a number; character length: 5,10. "type of operation: the input "means that the task name 1 is input. Alternatively, the brain pattern template may display "must fill: yes/no "for the technician to choose. The constraint set 1 includes a constraint that is a requirement for an input task name. "select port" corresponds to a set of constraints 2, the set of constraints 2 comprising the following constraints: operation type: a selection frame; filling: if not, then judging whether the current is equal to or greater than the preset threshold; value: 22,23; selection type: and (5) single selection. "type of operation: the selection box "indicates selection by the selection box.
Keywords such as the step descriptions described above may be obtained by parsing each level of the target brain file. It should be noted that, the frame of the brain chart template and the target brain chart file shown in fig. 3 are only illustrative, and the above structures can be added and deleted according to actual requirements. For example, the first stage is not included, and only the second stage to the eighth stage are included; for another example, the first to third stages are not included, and only the fourth to eighth stages are included; for another example, only the sixth to eighth stages and the like are included.
In the case of obtaining the target brain map file, keywords in the target brain map file may be extracted as the target content by parsing. Optionally, as a possible implementation manner, as shown in fig. 3, the target brain map file includes an operation step and an expected result, where the operation step and the expected result are located at a same level in the brain map file, the step is described as a next level of the operation step, and the first result and the second result are a next level of the expected result, where all step descriptions in the target brain map file may be obtained through one reading operation, and the first result and the second result in the target brain map file may be obtained through one reading operation, so that the target content may be quickly extracted.
In the case of extracting the step descriptions and the constraint condition sets in the target brain map file, for each step description that does not correspond to the constraint condition set, the step description may be directly used as a candidate step corresponding to the step description, and no processing is performed. For each step description of the corresponding limited condition set, based on the test case design method, generating a candidate step corresponding to the step description according to the step description and the limited condition set corresponding to the step description.
The test case design method can be one or more of equivalence class division, boundary value analysis, orthogonal test method, input domain test method, output domain analysis method, abnormal analysis method and the like in the test case design technology. Among them, equivalence class classification is a method of classifying all possible input data (valid and invalid) of a program into several equivalence classes. The boundary value analysis method is a black box test method for testing input or output boundary values. Typically, boundary value analysis is complementary to equivalence class partitioning, in which case the test cases come from the boundaries of the equivalence classes. The orthogonal test method is another design method for researching multiple factors and multiple levels, and is characterized in that partial representative points are selected from a comprehensive test according to orthogonality to carry out the test, and the representative points have the characteristics of uniform dispersion and alignment and comparability, and the orthogonal test design is a main method for analyzing the factor design. The input domain test method is a comprehensive method, and combines the methods of the equivalence class division method, the boundary value analysis method and the like.
For the step description corresponding to the constraint condition set, a test case design method can be utilized to perform single or combined sorting on the constraint conditions in the constraint condition set, and 1 or more candidate steps corresponding to the step description are generated by combining the corresponding step description. When only one constraint condition is included in the constraint condition set, the corresponding candidate step is generated directly based on the constraint condition and the corresponding step description. Combining and sorting means that a plurality of constraint conditions in one constraint condition set are combined. Optionally, the step description corresponding to the restriction condition set may include: a step of selecting to be generated based on data satisfying all the restrictions in the restriction set, a step of selecting to be generated based on data not satisfying any of the restrictions in the restriction set, a step of selecting to be generated based on data satisfying some of the restrictions in the restriction set, and the like. The operation information can be determined according to the data determined based on the limiting condition set, and the step to be selected comprises the operation information and step description. That is, the step description and operation information are included in the test steps corresponding to the limited condition set. The number of the steps to be selected, which corresponds to the step description of the constraint set, can be determined according to the practical test requirement, namely the use case design method.
After determining the candidate steps corresponding to the step descriptions, a plurality of test step sets can be obtained by respectively selecting one candidate step from the candidate steps corresponding to the step descriptions. For each test step set, when each test step of the corresponding limited condition set in the test step set meets all the limiting conditions in the corresponding limited condition set, determining that the test result corresponding to the test step set is the first result, otherwise, determining that the test result is the second result. That is, when the test case is a content in the set of constraint conditions, a successful result may be invoked; otherwise, the failed result is invoked. Therefore, the test results in each test case can be accurately determined, and the situation that the written test results are inaccurate due to insufficient experience and the like when the test cases are manually written is avoided.
In this embodiment, the test step is generated in the following manner: and acquiring step descriptions, namely acquiring the input specific value by using the field with the operation type, and splicing the data to obtain the testing step. The set of test steps shown below can be obtained by means of: 1. clicking and creating; 2. inputting a title, which is a title; 3. input classification, which is a classification; 4. inputting test data; 5. the input proposer yy;6. selecting a proposed date, zz;7. the selection of priority is very urgent; 8. selecting a reporter, namely not selecting; 9. click determination. And acquiring specific values of success and failure of the keyword, calling a success result when the generated use case is the use case meeting the content in the limiting condition set, otherwise, calling a failure result. Assuming zz is 2023-01-01, step 6 in the test step set is: selection of the proposed date: 2023-01-01.
As a possible implementation manner, the target content may further include a case title, the test case may further include a case name, and the case name of the test case may be generated based on the case title, so that a worker may quickly learn about the test case based on the case name. Referring to fig. 4, fig. 4 is a second flowchart of a test case generating method according to an embodiment of the present application. In this embodiment, the method may further include step S141 and step S142. Optionally, after each test step set and corresponding test result are obtained, steps S141 to S142 may be performed; after all the test step sets and the corresponding test results are obtained, the steps S141 to S142 may be executed, and the specific execution time may be determined in combination with the actual requirement.
Step S141, for each test case, obtaining operation information obtained by processing the test case based on the constraint condition set, where the operation information is included in the test step corresponding to the constraint condition set.
Step S142, splice the example title, step description, operation information and the test result corresponding to the test example to obtain the example name of the test example.
In this embodiment, the target brain graphic file may further include a use case header, and when extracting the target content, the use case header may be extracted from the target brain graphic file as the target content. The step description may be obtained from a set of test steps included in the currently targeted test case, or may be obtained from stored target content obtained by parsing. And obtaining operation information which is processed and obtained based on the limiting condition set and is included in the testing steps corresponding to the limiting condition set from the testing step set which is included in the testing case which is aimed at currently. For example, if the test step 1 in a certain test step set corresponds to a constraint condition set, the data determined based on the constraint condition set in the test step 1 is used as operation information, and is extracted to generate a use case name.
Under the condition that the case title, the step description, the operation information and the test result corresponding to the test case are obtained, the case title, the step description, the operation information and the test result corresponding to the test case can be spliced, so that the case name of the currently aimed test case is obtained. The case name may be saved in the test case as content in the test case. Wherein, the concatenation order can be in proper order: use case title, step description, operation information and test results corresponding to the test case.
An example of how a case name of a test case is generated is described below with reference to fig. 5. The hierarchical architecture shown in fig. 5 is the same as that of fig. 3, but the first level is not shown.
The keywords of the fourth-level use case title are obtained as follows: creating ideas, namely representing use case titles in the brain file is specifically creating ideas. The value of the seventh stage is obtained as follows: the classification is entered. Operation information obtained based on all content processing of the eighth level is acquired. For example, the set of constraints in the eighth stage includes: operation type: inputting; filling: otherwise, the method comprises the steps of; the data types that must be: chinese language; character length: 64; then in a certain test step set a, the operation information obtained based on the constraint set may be: input, test data, wherein the test data is a specific value of the operation type input. Because the input in the operation information, the test data meets all the limiting conditions in the limiting condition set, the test result corresponding to the test step set can be determined as follows: and (3) creating success, namely the test result corresponding to the test step set A is a first result corresponding to success. The test result "creation success" can be extracted from the test cases corresponding to the test step set a.
When the keyword "create idea" of the fourth level, the value "input classification" of the seventh level, the operation information "input test data" of the eighth level, and the test result "create success" are obtained, the "create idea, input classification, input test data, create success" may be obtained by stitching, as the case name of the test case corresponding to the test step set a.
The "test data" in the above operation information may be that the electronic device is based on "operation type: input "," type of data necessary: chinese "," character length less than 64", and" test data "are specific values entered. Other operational information may also be generated, such as, for example, the character length of the input value being greater than 64.
Referring to fig. 6, fig. 6 is a third flowchart of a test case generating method according to an embodiment of the present application. In this embodiment, the method may further include step S150.
And step S150, the preconditions are stored in each test case.
In this embodiment, the target brain graphic file may further include a precondition. When the target content is extracted, the pre-condition can be used as one item of information in the target content to be extracted from the target brain graph file, and then the pre-condition can be stored in each test case so as to finish the content required by the pre-condition before the test condition is executed, so that the test case can be executed normally.
Referring to fig. 7, fig. 7 is a flowchart illustrating a test case generating method according to an embodiment of the present application. In this embodiment, the method may further include step S160.
Step S160, the project name, the module name and the function name are stored in each test case.
In this embodiment, the target brain graphic file may further include a project name, a module name, and a function name, and when the target content is extracted, the project name, the module name, and the function name may be extracted from the target brain graphic file as information of the target content, and stored in each test case. Therefore, the required test case can be accurately determined by combining the project name, the module name and the function name.
Optionally, according to actual needs, the target brain graphic file may only include one or two of the project name, the module name and the function name, and in this case, one or two of the project name, the module name and the function name included in the target brain graphic file may be added to each test case.
Optionally, the priorities of the test cases may also be set, and the set priorities may be saved in the corresponding test cases. As a possible implementation manner, the priority of the use case satisfying the corresponding set of constraint conditions may be set to P1, and vice versa to P2. Wherein, P1 has a higher priority than P2. When executing the test cases, the test case with the priority of P1 can be executed first, and then the test case with the priority of P2 can be executed.
Under the condition that each test case is obtained, the obtained test cases can be stored in an excel file.
At present, very perfect information needs to be written in a brain graph file for generating test cases, and the test cases in an excel format can be generated by directly reading the content of the brain graph, so that the efficiency of test case generation is not improved. According to the embodiment of the application, the brain graph template is set, and when a tester writes the brain graph according to the template, only the keywords in the required document are required to be extracted to automatically generate an accurate use case, and each test step is not required to be written in the brain graph file, so that the maximum value is generated by using the minimum workload, and meanwhile, the accuracy of the generated result can be standardized, omission and deviation in the manual writing process are avoided, and the quality is ensured and the efficiency is improved to a certain extent. And various technologies for test case design are introduced, so that the accuracy of case generation is ensured, and meanwhile, more requirements can be met by continuously expanding operation types.
In order to perform the corresponding steps in the foregoing embodiments and the various possible manners, an implementation manner of the test case generating apparatus 200 is given below, and alternatively, the test case generating apparatus 200 may employ the device structure of the electronic device 100 shown in fig. 1. Further, referring to fig. 8, fig. 8 is a block diagram of a test case generating apparatus 200 according to an embodiment of the present application. It should be noted that, the basic principle and the technical effects of the test case generating device 200 provided in this embodiment are the same as those of the above embodiment, and for brevity, reference should be made to the corresponding contents of the above embodiment. In this embodiment, the test case generating device 200 may include: the system comprises an analysis module 210, a step processing module 220 and a use case generation module 230.
The parsing module 210 is configured to obtain a target brain map file including target content, and extract the target content from the target brain map. The target content comprises at least one step description, a first result corresponding to success, a second result corresponding to failure and a limiting condition set corresponding to each part of the step description.
The step processing module 220 is configured to generate, for each of the step descriptions, a corresponding candidate step. When the step description corresponds to the limiting condition set, corresponding steps to be selected are generated according to the step description and the corresponding limiting condition set, and at least one step description corresponding to the limiting condition set corresponds to a plurality of steps to be selected.
The step processing module 220 is configured to obtain a set of test steps by selecting one candidate step from the candidate steps corresponding to each step description, and select a test result corresponding to each test step set from the first result and the second result. Each test case comprises a test step set and a test result.
Alternatively, the above modules may be stored in the memory 110 shown in fig. 1 or solidified in an Operating System (OS) of the electronic device 100 in the form of software or Firmware (Firmware), and may be executed by the processor 120 in fig. 1. Meanwhile, data, codes of programs, and the like, which are required to execute the above-described modules, may be stored in the memory 110.
The embodiment of the application also provides a readable storage medium, on which a computer program is stored, which when executed by a processor, implements the test case generating method.
In summary, embodiments of the present application provide a method, an apparatus, an electronic device, and a readable storage medium for generating a test case, where, when a target brain map file including target content is obtained, the target content is extracted from the target brain map file by parsing, where the target content includes at least one step description, a first result that corresponds to success, a second result that corresponds to failure, and a set of constraint conditions that each corresponds to a partial step description. And generating a step to be selected corresponding to the step description for each step description, wherein when the step description corresponds to the limiting condition set, the corresponding step to be selected is generated according to the step description and the corresponding limiting condition set, and at least one step description corresponding to the limiting condition set corresponds to a plurality of steps to be selected. Finally, a plurality of test step sets are obtained by selecting one to-be-selected step from the to-be-selected steps corresponding to the step descriptions, and test results corresponding to the test step sets are selected from the first results and the second results, wherein each test case comprises one test step set and one test result. Therefore, a technician does not need to write specific test steps in each test case, and the test steps in the test case can be automatically and accurately generated based on related keywords in the brain graph file, so that the generation efficiency of the test case is improved, and meanwhile, the condition that test results are not standard and the condition that the test cases are omitted in the manual writing process are avoided.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The apparatus embodiments described above are merely illustrative, for example, of the flowcharts and block diagrams in the figures that illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The above description is only of alternative embodiments of the present application and is not intended to limit the present application, and various modifications and variations will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims (10)
1. A method for generating test cases, the method comprising:
obtaining a target brain graph file comprising target content, and extracting the target content from the target brain graph, wherein the target content comprises at least one step description, a first result corresponding to success, a second result corresponding to failure, and a limiting condition set corresponding to each partial step description;
generating corresponding steps to be selected for each step description, wherein when the step descriptions correspond to the limiting condition sets, the corresponding steps to be selected are generated according to the step descriptions and the corresponding limiting condition sets, and at least one step description of the corresponding limiting condition sets corresponds to a plurality of steps to be selected;
and obtaining a plurality of test step sets by respectively selecting one to-be-selected step from the to-be-selected steps corresponding to each step description, and selecting test results corresponding to each test step set from the first result and the second result, wherein each test case comprises one test step set and one test result.
2. The method of claim 1, wherein the generating a corresponding candidate step for each of the step descriptions comprises:
When the step description corresponds to the constraint condition set, based on the test case design method, the step description and the constraint condition set corresponding to the step description are combined to generate a candidate step corresponding to the step description.
3. The method of claim 1, wherein the target content further comprises a case title, wherein the test case further comprises a case name, and wherein the method further comprises:
for each test case, obtaining operation information which is obtained by processing the test case based on the limiting condition set and is included in the test step corresponding to the limiting condition set, wherein the test step corresponding to the limiting condition set includes the step description and the operation information;
and splicing the case title, the step description, the operation information and the test result corresponding to the test case to obtain the case name of the test case.
4. The method of claim 1, wherein the target content further comprises a precondition, the method further comprising:
and storing the preconditions in each test case.
5. The method of claim 1, wherein the target content further comprises an item name, a module name, and a function name, the method further comprising:
And storing the project name, the module name and the function name in each test case.
6. The method of any one of claims 1-5, wherein the target brain map file includes an operation step and an expected result, the operation step and the expected result being located at a same level in the target brain map file, the step being described as a next level of the operation step, the first result and the second result being a next level of the expected result, the extracting the target content from the target brain map comprising:
obtaining all step descriptions in the target brain graph file through one-time reading operation;
the first result and the second result are obtained by one read operation.
7. The method of any one of claims 1-5, wherein the target brain map file is generated based on a brain map template and received writing operations.
8. A test case generating device, the device comprising:
the analysis module is used for obtaining a target brain graph file comprising target content and extracting the target content from the target brain graph, wherein the target content comprises at least one limiting condition set corresponding to each step description, a first successful result, a second failed result and part of step descriptions;
The step processing module is used for generating corresponding to-be-selected steps for each step description, wherein when the step descriptions correspond to the limiting condition sets, the corresponding to-be-selected steps are generated according to the step descriptions and the corresponding limiting condition sets, and at least one step description corresponding to the limiting condition sets corresponds to a plurality of to-be-selected steps;
the case generation module is used for obtaining a plurality of test step sets by respectively selecting one to-be-selected step from the to-be-selected steps corresponding to each step description, and selecting test results corresponding to each test step set from the first result and the second result, wherein each test case comprises one test step set and one test result.
9. An electronic device comprising a processor and a memory, the memory storing machine executable instructions executable by the processor to implement the test case generation method of any of claims 1-7.
10. A readable storage medium, on which a computer program is stored, characterized in that the computer program, when executed by a processor, implements the test case generating method according to any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310643934.6A CN116737556A (en) | 2023-06-01 | 2023-06-01 | Test case generation method and device, electronic equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310643934.6A CN116737556A (en) | 2023-06-01 | 2023-06-01 | Test case generation method and device, electronic equipment and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116737556A true CN116737556A (en) | 2023-09-12 |
Family
ID=87917979
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310643934.6A Pending CN116737556A (en) | 2023-06-01 | 2023-06-01 | Test case generation method and device, electronic equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116737556A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119621589A (en) * | 2025-02-10 | 2025-03-14 | 浙江大华技术股份有限公司 | An automated testing method, device and electronic equipment based on multi-intelligent algorithm |
-
2023
- 2023-06-01 CN CN202310643934.6A patent/CN116737556A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119621589A (en) * | 2025-02-10 | 2025-03-14 | 浙江大华技术股份有限公司 | An automated testing method, device and electronic equipment based on multi-intelligent algorithm |
CN119621589B (en) * | 2025-02-10 | 2025-05-06 | 浙江大华技术股份有限公司 | Automatic testing method and device based on multiple intelligent algorithms and electronic equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8010844B2 (en) | File mutation method and system using file section information and mutation rules | |
CN110287069B (en) | ESB interface automatic test method, server and computer readable storage medium | |
CN102804147B (en) | Perform the code check executive system of the code check of ABAP source code | |
US20100114939A1 (en) | Software test management system and method with facilitated reuse of test components | |
KR101588027B1 (en) | Method and apparatus for generating test case to support localization of software | |
CN110837356B (en) | Data processing method and device | |
CN110908890A (en) | Automatic test method and device for interface | |
CN111522741B (en) | Interface test code generation method and device, electronic equipment and readable storage medium | |
US20090100299A1 (en) | Methods and Apparatus for Patternizing Device Responses | |
Kuchta et al. | On the correctness of electronic documents: studying, finding, and localizing inconsistency bugs in PDF readers and files | |
CN113342692B (en) | Automatic test case generation method and device, electronic equipment and storage medium | |
CN113360388B (en) | Method for integrally managing test process of unmanned aerial vehicle ground station software | |
CN117724686B (en) | Visual generation method and device for XML-based design verification code | |
CN111651196A (en) | Document publishing method, device and server | |
CN109614325B (en) | Method and device for determining control attribute, electronic equipment and storage medium | |
CN116483372A (en) | Information processing method, device and storage medium | |
CN113641523A (en) | Log processing method and device | |
CN116737556A (en) | Test case generation method and device, electronic equipment and readable storage medium | |
CN119396719B (en) | Software efficient test method and system based on artificial intelligence | |
EP4083783B1 (en) | Program development assistance system and program development assistance method | |
JP4215255B2 (en) | Degradation confirmation inspection method, degradation confirmation inspection system, and program therefor | |
CN112567375A (en) | Format verification method, information identification method, device and storage medium | |
CN114416565B (en) | Data processing method, device, server and storage medium | |
CN112445461B (en) | Business rule generation method and device, electronic equipment and readable storage medium | |
CN115310011A (en) | Page display method and system and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |