CN114281679A - Test case generation method and device, computer equipment and storage medium - Google Patents

Test case generation method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN114281679A
CN114281679A CN202111445598.1A CN202111445598A CN114281679A CN 114281679 A CN114281679 A CN 114281679A CN 202111445598 A CN202111445598 A CN 202111445598A CN 114281679 A CN114281679 A CN 114281679A
Authority
CN
China
Prior art keywords
dictionary
scene
test
factor
field
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111445598.1A
Other languages
Chinese (zh)
Inventor
杨吉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CMB Yunchuang Information Technology Co Ltd
Original Assignee
CMB Yunchuang Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CMB Yunchuang Information Technology Co Ltd filed Critical CMB Yunchuang Information Technology Co Ltd
Priority to CN202111445598.1A priority Critical patent/CN114281679A/en
Publication of CN114281679A publication Critical patent/CN114281679A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application relates to a test case generation method, a test case generation device, computer equipment and a storage medium. The method comprises the following steps: and generating a dictionary according to the test requirement table, the scene table and the path of the function menu of the system, thereby determining the content corresponding to each field of the test case according to the dictionary and generating the test case according to the content corresponding to each field. When the method is used for compiling the cases, the dictionary is generated by the paths of the test requirement table, the scene table and the function menu of the system, the format is convenient for program recognition, the scene table can be automatically converted into the cases meeting the existing test management platform, and a large amount of time for compiling the cases is saved.

Description

Test case generation method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of power system technologies, and in particular, to a test case generation method and apparatus, a computer device, and a storage medium.
Background
The scenario method, as a common software testing method, generally includes an elementary stream and a standby stream, wherein a main flow implemented by a software function according to an event stream, called as the elementary stream of the software, is labeled with an alternative stream in the process of a fault or a defect. When a scene method is used for testing software functions, a test case needs to be generated according to actual test requirements, so that an operator can test the software according to the test case. For example, the test cases may be presented in a tabular form or may be presented in a document form.
At present, when software is tested by using a scene method, a scene is not clear enough, and testers can read and understand the scene, but the software is difficult to read and understand by a machine, and a test case needs to be compiled manually and then imported into a related test management platform. Moreover, if there are many scenes, the time for maintaining the test cases is long, resulting in low efficiency.
Disclosure of Invention
In view of the above, it is necessary to provide a test case generation method, a device, a computer device, and a storage medium, which can improve the efficiency of writing test cases, in order to solve the above technical problems.
A test case generation method, the method comprising:
generating a dictionary according to the test requirement table, the scene table and the path of the function menu of the system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene;
determining the content corresponding to each field of the test case according to the dictionary;
and generating the test case according to the content corresponding to each field.
In one embodiment, the generating a dictionary according to the test requirement table, the scenario table, and the path of the function menu of the system includes:
generating a first dictionary according to the test requirement table; the first dictionary comprises a corresponding relation among requirement identification, requirement description and a four-level directory;
generating a second dictionary according to the scene table; the second dictionary comprises corresponding relations among the requirement identifications, the scenes, the factor information and the expected results;
generating a third dictionary according to the path of the function menu of the system; the third dictionary includes correspondence between level four directories and hierarchical paths.
In one embodiment, the test case includes a precondition field, the factor information includes a plurality of factors and values of the factors, and determining content corresponding to each field of the test case according to the dictionary includes:
traversing the second dictionary to obtain each column, and obtaining the corresponding relation between each factor and the value of the factor under each scene;
and writing the corresponding relation between each scene and each factor and the value of the factor under each scene into the precondition field.
In one embodiment, the test case further includes an expected result field, and the determining content corresponding to each field of the test case according to the dictionary further includes:
traversing the second dictionary to obtain each column to obtain an expected result corresponding to each scene;
and writing an expected result corresponding to each scene into the expected result field.
In one embodiment, the determining the content corresponding to each field of the test case according to the dictionary includes:
searching a four-level directory corresponding to a second demand identifier in the first dictionary according to the first demand identifier in the second dictionary; the second requirement identification is the same as the first requirement identification;
searching the third dictionary according to the four-level directory to obtain a hierarchical path corresponding to the four-level directory;
and writing the four-level directory and the hierarchical path corresponding to the four-level directory into the path field.
In one embodiment, the test case further includes test step fields, and the determining content corresponding to each field of the test case according to the dictionary further includes:
writing the hierarchical path corresponding to the four-level directory into the first test step of the test step field;
and writing the content of the preset field into the second test step of the test step field.
In one embodiment, the factor information includes a plurality of factors and values of the factors, and the method further includes:
analyzing the test requirement table, and determining each factor and the value of each factor, wherein the factor is a factor influencing at least one of an expected result, a basic flow and an alternative flow;
arranging and combining the factors and the values of the factors to obtain the factors and the values of the factors corresponding to the scenes;
and generating the scene table according to the factor corresponding to each scene, the value of the factor and the expected result of each scene.
A test case generation apparatus, the apparatus comprising:
the first generation module is used for generating a dictionary according to the test requirement table, the scene table and the path of the function menu of the system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene;
the determining module is used for determining the content corresponding to each field of the test case according to the dictionary;
and the second generation module is used for generating the test case according to the content corresponding to each field.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
generating a dictionary according to the test requirement table, the scene table and the path of the function menu of the system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene;
determining the content corresponding to each field of the test case according to the dictionary;
and generating the test case according to the content corresponding to each field.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
generating a dictionary according to the test requirement table, the scene table and the path of the function menu of the system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene;
determining the content corresponding to each field of the test case according to the dictionary;
and generating the test case according to the content corresponding to each field.
According to the test case generation method, the test case generation device, the computer equipment and the storage medium, the dictionary is generated according to the test requirement table, the scene table and the path of the function menu of the system, so that the content corresponding to each field of the test case is determined according to the dictionary, and the test case is generated according to the content corresponding to each field. When the method is used for compiling the cases, the dictionary is generated by the paths of the test requirement table, the scene table and the function menu of the system, the format is convenient for program recognition, the scene table can be automatically converted into the cases meeting the existing test management platform, and a large amount of time for compiling the cases is saved.
Drawings
FIG. 1 is a diagram of an application environment of a test case generation method in one embodiment;
FIG. 2 is a flowchart illustrating a test case generation method according to an embodiment;
FIG. 3 is a flowchart illustrating a test case generation method according to another embodiment;
FIG. 4 is a flowchart illustrating a test case generation method according to another embodiment;
FIG. 5 is a flowchart illustrating a test case generation method according to another embodiment;
FIG. 6 is a flowchart illustrating a test case generation method according to another embodiment;
FIG. 7 is a flowchart illustrating a test case generation method according to another embodiment;
FIG. 8 is a flowchart illustrating a test case generation method according to another embodiment;
FIG. 9 is a block diagram showing the structure of a test case generating apparatus according to an embodiment;
FIG. 10 is a block diagram showing the structure of a test case generating apparatus according to another embodiment;
FIG. 11 is a block diagram showing the structure of a test case generating apparatus according to another embodiment;
FIG. 12 is a block diagram showing the structure of a test case generating apparatus according to another embodiment;
FIG. 13 is a block diagram showing the structure of a test case generating apparatus according to another embodiment;
FIG. 14 is a block diagram showing the structure of a test case generating apparatus according to another embodiment;
FIG. 15 is a block diagram showing the structure of a test case generating apparatus according to another embodiment;
FIG. 16 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The test case generation method provided by the application can be applied to the application environment shown in fig. 1, and the computer device can be a terminal. Generating a dictionary by using the terminal according to the test requirement table, the scene table and the path of the function menu of the system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene; determining the content corresponding to each field of the test case according to the dictionary; and generating a test case according to the content corresponding to each field. The terminal may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 1. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a test case generation method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
In an embodiment, as shown in fig. 2, a test case generation method is provided, which is described by taking the application of the method to the terminal in fig. 1 as an example, and includes the following steps:
s201, generating a dictionary according to a test requirement table, a scene table and a path of a function menu of a system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene.
Where a dictionary is a language that can be recognized by a computer, is a correspondence of a series of keys and values, each key being associated with a value that can be accessed using the key, the values associated with the keys can be numbers, strings, lists, or even dictionaries. When a key is specified, the value associated with it will be returned, with colons separating between keys and values and commas separating between key-value pairs. In the dictionary, how many key-value pairs can be stored, and the simplest dictionary only has one key-value pair. For example: a ═ color ': red'.
In this embodiment, the functions to be tested are analyzed to obtain a test requirement table as shown in table 1. Taking a bank system as an example, a demand mark a, a demand name as a payment type, a demand problem is the time of fund arrival after a customer recharges, a demand description point 1 recharges a plurality of accounts at the same time, a demand description point 2 recharges a certain account at the same time, a four-level directory is a, a test point 1 recharges a plurality of accounts, and a test point 2 recharges a certain account.
TABLE 1 test requirements Table
Figure BDA0003383917150000061
In this embodiment, the scenario table includes factor information and expected results corresponding to each scenario, and the factor information is obtained after analyzing the test requirement table, as shown in table 2. For example, the demand sign a is analyzed, and factors of possible influences include the number of people with recharge and the speed of the network, the number of people with recharge is within 50, the speed of the network is good, and the expected result is that the account can be reached within 10 seconds.
TABLE 2 scene Table
Scene Factor 1 Factor 2 Factor 3 Factor 4 Factor 5 Expected result
Scene 1 Value 11 Value 21 Value 31 Value 41 Value 51 Expected results 1
Scene 2 Value 12 Value 21 Value 31 Value 41 Value 51 Expected results 2
Scene 3 Value 11 Value 22 Value 31 Value 41 Value 51 Expected results 3
Scene 4 Value 12 Value 22 Value 31 Value 41 Value 51 Expected result 4
In this embodiment, the content in the paths of the test requirement table, the scenario table, and the function menu of the system is generated into a corresponding dictionary according to a dictionary format for machine recognition. For example, scene 1 may be generated into a dictionary, the factor may be set as a key, and the factor value is a value, which is [ factor 1: value 11], [ factor 2: value 21, [ factor 3: value 31], [ factor 4: value 41, [ factor 5: value 51 ]. All scenes in table 2 may be generated as a dictionary, and if the scenes are set as keys and the rest as values, [ scene 1: value 11, value 21, value 31, value 41, value 51, [ scene 2: value 12, value 21, value 31, value 41, value 51, [ scene 3: value 11, value 22, value 31, value 41, value 51, [ scene 4: value 12, value 22, value 31, value 41, value 51, or generate a dictionary of the paths of the function menu of table 1, table 2 and the system, { requirement identification a: [ requirement name 1, problem 1, requirement description 1, level four directory 1, test point 1], requirement identification b: [ requirement name 2, problem 2, requirement description 2, level four directory 2, site 2] }.
And S202, determining the content corresponding to each field of the test case according to the dictionary.
In this embodiment, the paths of the test requirement table, the scenario table, and the function menu of the system respectively correspond to different dictionaries, the test requirement table corresponds to the dictionary 1, the scenario table corresponds to the dictionary 2, the path of the function menu of the system corresponds to the dictionary 3, the dictionary 1 includes all contents in the test requirement table, the dictionary 2 includes all contents in the scenario table, and the dictionary 3 includes the path of the function menu of the system. For example, the dictionary 1 includes content 1, content 2, and content 3, the dictionary 2 includes content 4, content 5, and content 6, and the dictionary 3 includes content 7 and content 8. The fields include field 1, field 2, field 3, field 4, and field 5. The three dictionaries can be correlated through content 1, content 4 and content 7, and the content corresponding to field 1, field 2, field 3, field 4 and field 5 of the test case is determined according to content 2, content 3, content 5, content 6 and content 8; it is also possible that the dictionary 1 includes content 1, content 2, and content 3, the dictionary 2 includes content 4, content 5, and content 6, and the dictionary 3 includes content 7 and content 8. The fields comprise a field 1, a field 2 and a field 3, and the three dictionaries can be related to each other through content 1, content 4 and content 7. And determining the content of the field 1 of the test case according to the content 2 and the content 3, determining the content of the field 2 of the test case according to the content 5, the content 6 and the content 8, and determining the content corresponding to the field 3 of the test case according to the content 4.
And S203, generating a test case according to the content corresponding to each field.
In this embodiment, the test case may be generated by writing the content corresponding to each field into the test case corresponding field according to the above method, for example, in the above step, the content 2 and the content 3 are written into the field 1, the content 5, the content 6 and the content 8 are written into the field 2, and the content 4 is written into the field 3.
In the test case generation method, the dictionary is generated according to the test requirement table, the scene table and the path of the function menu of the system, so that the content corresponding to each field of the test case is determined according to the dictionary, and the test case is generated according to the content corresponding to each field. When the method is used for compiling the cases, the dictionary is generated by the paths of the test requirement table, the scene table and the function menu of the system, the format is convenient for program recognition, the scene table can be automatically converted into the cases meeting the existing test management platform, and a large amount of time for compiling the cases is saved.
The embodiment of fig. 2 described above introduces a method for generating a test case, and then mainly introduces an implementation manner for generating three dictionaries.
The first dictionary generation mode: generating a first dictionary according to the test requirement table; the first dictionary comprises corresponding relations among requirement identifications, requirement descriptions and four-level directories.
In this embodiment, a programming language may be used to automatically generate the first dictionary from the test requirement table, for example, data is extracted from the test requirement table 1 by using a python script, and a first dictionary with a format of { requirement identifier a: [ requirement name 1, problem 1, requirement description 1, level four directory 1, test point 1], requirement identification b: [ requirement name 2, problem 2, requirement description 2, level four directory 2, test point 2] }; or generating a first dictionary according to a dictionary generation tool, for example, packing the test requirement table 1 or a plurality of test requirement tables, inputting the packed file into the dictionary generation tool, decompressing and operating the file by the dictionary generation tool; or the user may manually generate the dictionary, for example, in a notebook or an excel, the first dictionary is generated by manual editing according to the format requirement of the dictionary.
The second dictionary generation mode is as follows: generating a second dictionary according to the scene table; the second dictionary includes correspondences between the requirement identifications, scenarios, factor information, and expected results.
In this embodiment, the second dictionary may be automatically generated from the scenario table by using a programming language, for example, according to the specific content of the scenario table, data is extracted by using a python script, and a second dictionary with a format of { requirement identifier a: [ [ factor a ], [ value 11], [ value 12] ], requirement identification b: [ [ factor b ], [ value 21] ], [ value 22], [ value 23] }; or generating a second dictionary according to the dictionary generating tool, for example, packing the scene table or a plurality of scene tables, inputting the packed file into the dictionary generating tool, decompressing and operating the file by the dictionary generating tool; or the user may manually generate the second dictionary, for example, in a notebook or an excel, the second dictionary is generated by manual editing according to the format requirement of the dictionary.
The third dictionary generation mode: generating a third dictionary according to the path of the function menu of the system; the third dictionary includes correspondence between the level four directories and the hierarchical paths.
In this embodiment, the third dictionary may be automatically generated by using a programming language, for example, a python script, and a path in a format of { four-level directory: level 1\ level 2\ level 3, four levels of directories: level 1\ level 2\ level 4 }; the user may also manually generate the third dictionary, for example, in a notepad or an excel, the third dictionary may be generated by manually editing the path of the conventional function menu according to the format requirement of the dictionary.
In the embodiment of the application, the test requirement table, the scene table and the path of the function menu of the system are respectively generated into corresponding dictionaries, so that the test requirements, factors, scenes, expected results and the like are clearer, the format is convenient for machine recognition, and a foundation is laid for the subsequent automatic generation of test cases.
The above embodiment introduces three dictionary generating manners, and determining the content corresponding to each field of the test case according to the dictionary includes generating a precondition field content, generating an expected result field content, generating a path field content, and generating a test step field content. Next, an implementation of determining content corresponding to a precondition field of a test case is first described, and as shown in fig. 3, the implementation includes the following steps:
s401, traversing each column of the second dictionary to obtain the corresponding relation between each factor and the value of the factor in each scene.
In this embodiment, the second dictionary is a dictionary corresponding to the scene table, for example, the second dictionary is { requirement identifier a: [ [ scene table factor a ], [ scene 11], [ scene 12], [ scene 13], [ scene 14] ], demand identification b: [ [ scene table factors b ], [ scene 21] ], [ scene 22], [ scene 23], [ scene 24] }, wherein the scene table factors a include two factors under the requirement identification a, namely a factor a1 and a factor a2, the factor a1 corresponds to a value a11 and a value a12, and the factor a2 corresponds to a value a21 and a value a 22; the factor b of the scene table includes two factors under the requirement identifier b, which are factor b1 and factor b2, respectively, the factor b1 has a value b11 and a value b12, and the factor b2 has a value b21 and a value b 22. Scene 11, scene 12, scene 13, etc. correspond to corresponding values, as shown in the following table:
TABLE 3 second dictionary schematic table
Figure BDA0003383917150000091
Figure BDA0003383917150000101
In this embodiment, it can be seen from the table that the second column of the second dictionary is traversed, the second column is a factor column of the scene table, and the remaining columns after the second dictionary are traversed, and the remaining columns are scene columns. And traversing each column after traversing decomposition, and traversing the scene table factor column to know that specific factors include a factor a1, a factor a2, a factor b1 and a factor b2, and traversing the scene column to obtain a factor value corresponding to the factor in each scene.
S402, writing the corresponding relation between each scene and each factor and the factor value in each scene into a precondition field.
In this embodiment, the scenes and the corresponding relationship between the factors and the factor values in each scene are written into the precondition field according to the traversal result. For example, for the requirement number 1, four scenes in the requirement number 1 and corresponding factors and factor values under the four scenes may be written into the precondition of one case test table; a case test table may also be generated for each scene, that is, for four scenes in the requirement identifier a, the factor and the factor value in each scene are written into the preconditions of different case test tables, respectively, and there may be four case test tables.
In the embodiment of the application, the corresponding relation between each factor and the value of each factor in each scene is obtained by traversing each column of the second dictionary, and then the corresponding relation between each scene and each factor and the value of each factor in each scene is written into the precondition field, so that under the condition of more scenes and more influence factors, a great amount of time for writing cases is saved for testers.
The above embodiment of fig. 3 introduces an implementation manner of determining content corresponding to a precondition field of a test case, and then focuses on determining a second type of content corresponding to each field of the test case according to a dictionary, that is, a process of determining content corresponding to an expected result field of the test case, as shown in fig. 4, includes the following steps:
s501, traversing the second dictionary to obtain each column, and obtaining expected results corresponding to each scene.
In this embodiment, as shown in table 2, each scene in the second dictionary corresponds to an expected result, and each column of the second dictionary is traversed, so that the expected result corresponding to each scene can be obtained. For example, scene 11 corresponds to expected result 11 and scene 12 corresponds to expected result 12.
S501, writing expected results corresponding to all scenes into an expected result field.
In this embodiment, the expected result corresponding to each scene is written into the expected result field. For example, for scenario 11, its preconditions are [ factor a 1: value a11], [ factor a 2: value a21], the content in the corresponding expected result field being the expected result 11.
In the embodiment of the application, each column is obtained by traversing the second dictionary, the expected result corresponding to each scene is obtained, the expected result corresponding to each scene is written into the expected result field, the expected result is obtained by inference according to the precondition, and a tester only needs to detect whether the actual test result accords with the expected result in the test process, so that the tester can conveniently compare the expected result with the actual test result according to the expected result.
The above embodiment of fig. 4 introduces an implementation manner of determining contents corresponding to expected result fields of a test case, and then focuses on a third process of determining contents corresponding to each field of the test case according to a dictionary, that is, determining contents corresponding to path fields of the test case, as shown in fig. 5, the process includes the following steps:
s601, searching a four-level directory corresponding to a second demand identifier in a first dictionary according to the first demand identifier in the second dictionary; the second requirement identification is the same as the first requirement identification.
In this embodiment, the second dictionary corresponding to the scenario table and the first dictionary of the test requirement table both include requirement identifiers, which are requirement identifier a and requirement identifier b, respectively. Taking the requirement identifier a as an example, according to the requirement identifier a in the second dictionary, searching for a corresponding requirement identifier a from the first dictionary, where each requirement identifier corresponds to a corresponding four-level directory, and searching for the four-level directory a corresponding to the requirement identifier a from the first dictionary according to the requirement identifier a.
S602, the third dictionary is searched by the root four-level directory, and the hierarchical path corresponding to the four-level directory is obtained.
In this embodiment, the third dictionary is a corresponding dictionary generated by the path of the function menu of the system, and is in the format of { four-level directory a: level 1\ level 2\ level 3, level four directory b: and the level 1\ level 2\ level 4}, and a level path corresponding to the level four directory a is found from the third dictionary according to the level four directory a by utilizing the level four directory a corresponding to the requirement identifier a in the first dictionary and is level 1\ level 2\ level 3.
S603, writing the four-level directory and the hierarchical path corresponding to the four-level directory into the path field.
In this embodiment, the level paths corresponding to the level four directory a and the level four directory a searched in the above steps are written into the path field of the test case in level 1\ level 2\ level 3. For example, if the preconditions and the expected results of the same requirement flag are written into the same test case, only the four-level directory a: the path field of the same write test case of the level 1\ level 2\ level 3; if the precondition and the expected result of the same requirement identifier are written into different test cases according to different scenes, the four-level directory a: and writing the level 1\ level 2\ level 3 into path fields in different test cases according to the corresponding relation.
According to the method, the four-level directory corresponding to the second requirement identification in the first dictionary is searched according to the first requirement identification in the second dictionary, the corresponding level directory is further found from the third dictionary according to the four-level directory, and then the four-level directory and the corresponding level directory are written into the path field.
The embodiment of fig. 5 described above introduces an implementation manner of determining content corresponding to a path field of a test case, and then focuses on a fourth process of determining content corresponding to each field of the test case according to a dictionary, that is, determining content corresponding to a test step field of the test case, as shown in fig. 6, the process includes the following steps:
s701, writing the hierarchical path corresponding to the four-level directory into the first test step of the test step field.
In this embodiment, according to the embodiment of fig. 5, a path of a test case may be determined, and a hierarchical path corresponding to a four-level directory is written into a first test step of a test step field, so as to instruct an operator to enter an interface corresponding to the path according to the path provided in the corresponding first test step. For example, for the requirement identification a, the tester reads the requirement from "level four directory a: and entering a corresponding interface by a level 1\ level 2\ level 3 "path to test the software.
S702, writing the content of the preset field into the second test step of the test step field.
The preset field may be operated for "corresponding to the precondition, so that the triggered scene meets the precondition. "may also be a specific operation step according to the test requirement.
In this embodiment, the "corresponding precondition is operated, so that the triggered scene meets the precondition. And performing character string encoding, identifying the character string by the computer equipment, and operating the corresponding preset condition to ensure that the triggered scene meets the preset condition and is fixedly written into the second test step. When the software test is carried out by a tester, the tester tests the software according to the precondition. For example, according to table 2, the requirement identifier a corresponds to four different scenarios, and the tester needs to test the software according to the preconditions corresponding to the scenarios 11, 12, 13, and 14.
In the embodiment of the application, when the content corresponding to the field of the test step of the test case is determined, the corresponding path is written into the first test step, and the preset field is written into the second test step. Even if the precondition is changed for different cases or a plurality of preconditions exist in a plurality of scenes, the content of the preset field does not need to be changed, thereby saving a great deal of time for writing the test case.
The embodiment of fig. 6 described above introduces an implementation manner for determining content corresponding to a test step field of a test case, and before generating a dictionary, a scenario table needs to be generated. Therefore, the test case generation method further includes the following steps, as shown in fig. 7.
S801, analyzing the test requirement table, and determining each factor and the value of each factor, wherein the factor is a factor influencing at least one of an expected result, a basic flow and an alternative flow.
In this embodiment, when testing software, the functions to be tested are identified, the requirements of the functions to be tested are listed, a test requirement table is obtained, and the test requirement table is further analyzed to determine each factor and the value of each factor. For example, after analyzing the test requirements table, the factors and the values of the factors are determined as shown in table 4. Wherein the factors influencing the expected result are a factor 1 and a factor 2, the factors influencing the elementary stream are a factor 3 and a factor 4, the factors influencing the alternative stream are a factor 5, the factor 1 has two corresponding factor values, respectively a value 11 and a value 12, the factor 2 also has two corresponding factor values, respectively a value 21 and a value 22, the factor 3 has three corresponding factor values, respectively a value 31 and a value 32, the factor 4 also has three corresponding factor values, respectively a value 41 and a value 42, the factor 5 has two corresponding factor values, respectively a value 51 and a value 52.
TABLE 4 factor analysis Table
Figure BDA0003383917150000131
Figure BDA0003383917150000141
And S802, arranging and combining the factors and the values of the factors to obtain the factors and the values of the factors corresponding to the scenes.
In this embodiment, the factors and the values of the factors are arranged and combined, taking the above table 3 as an example, if the factors 1, 2 and 5 have two corresponding values respectively, and the factors 3 and 4 have three corresponding values respectively, then a total of 72 arrangement combinations can be obtained, and the result is shown in table 5. As the factor and the value of the factor increase, the scene also increases accordingly.
TABLE 5 factor permutation and combination table
Factor 1 Factor 2 Factor 3 Factor 4 Factor 5
Value 11 Value 21 Value 31 Value 41 Value 51
Value 12 Value 21 Value 31 Value 41 Value 51
Value 11 Value 22 Value 31 Value 41 Value 51
Value 12 Value 22 Value 31 Value 41 Value 51
S803, a scene table is generated based on the factor and the value of the factor corresponding to each scene and the expected result of each scene.
In this embodiment, each permutation and combination manner is a scenario, for example: the value 11, the value 21, the value 31, the value 41, and the value 51 correspond to one scene, the scene 1 is assumed, the value 12, the value 21, the value 31, the value 41, and the value 51 correspond to one scene, the scene 2 is assumed, and so on. Each scene has a corresponding expected result, and the factor and the value of the factor corresponding to each scene are combined with the expected result of each scene to generate a scene table, as shown in table 2 above.
In the embodiment of the application, the test requirement table is analyzed to determine the factors and the values of the factors, the factors and the values of the factors are arranged and combined, and the factors and the values of the factors corresponding to the scenes are subjected to result expectation, so that the regular scene table is generated. The method extracts characteristic factors which influence basic streams, alternative streams and expected results, and then carries out permutation and combination to analyze the test function from multiple aspects, so that the scene method analysis test point is more complete and comprehensive.
Further, as shown in fig. 8, the test case generation method further includes the following steps:
s901, analyzing the test requirement table, determining each factor and the value of each factor, wherein the factor is a factor influencing at least one of an expected result, a basic flow and an alternative flow
S902, the factors and the factor values are arranged and combined to obtain the factors and the factor values corresponding to the scenes
S903, generating a scene table according to the factor corresponding to each scene, the value of the factor and the expected result of each scene
S904, generating a first dictionary according to the test requirement table; the first dictionary comprises a corresponding relation among requirement identification, requirement description and a four-level directory;
s905, generating a second dictionary according to the scene table; the second dictionary comprises corresponding relations among the requirement identifications, the scenes, the factor information and the expected results;
s906, generating a third dictionary according to the path of the function menu of the system; the third dictionary comprises the corresponding relation between the four-level directory and the hierarchical path;
s907, traversing the second dictionary to obtain each column, and obtaining the corresponding relation between each factor and the value of the factor in each scene;
s908, writing the scenes and the corresponding relation between the factors and the factor values in the scenes into a precondition field;
s909, traversing the second dictionary to obtain each row and obtaining expected results corresponding to each scene;
s910, writing expected results corresponding to all scenes into expected result fields;
s911, according to the first requirement identification in the second dictionary, searching a four-level directory corresponding to the second requirement identification in the first dictionary; the second requirement identification is the same as the first requirement identification;
s912, searching a third dictionary by the root level four directory to obtain a level path corresponding to the level four directory;
s913, writing the four-level directory and the hierarchical path corresponding to the four-level directory into the path field
S914, writing the hierarchical path corresponding to the four-level directory into the first test step of the test step field;
s915, writing the content of the preset field into a second test step of the field of the test step;
and S916, generating a test case according to the content corresponding to each field.
In the embodiment of the application, the dictionary is generated according to the test requirement table, the scene table and the path of the function menu of the system, so that the content corresponding to each field of the test case is determined according to the dictionary, and the test case is generated according to the content corresponding to each field. When the method is used for compiling the cases, the dictionary is generated by the paths of the test requirement table, the scene table and the function menu of the system, the format is convenient for program recognition, the scene table can be automatically converted into the cases meeting the existing test management platform, and a large amount of time for compiling the cases is saved.
It should be understood that although the various steps in the flow charts of fig. 2-8 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-8 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
In one embodiment, as shown in fig. 9, there is provided a test case generation apparatus, including: a first generation module 11, a determination module 12 and a second generation module 13, wherein:
the first generation module 11 is configured to generate a dictionary according to a test requirement table, a scenario table, and a path of a function menu of the system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene;
the determining module 12 is configured to determine, according to the dictionary, contents corresponding to each field of the test case;
and a second generating module 13, configured to generate a test case according to the content corresponding to each field.
In one embodiment, as shown in fig. 10, the first generating module 11 includes:
the first generating unit 111 is used for generating a first dictionary according to the test requirement table; the first dictionary comprises a corresponding relation among requirement identification, requirement description and a four-level directory;
a second generating unit 112, configured to generate a second dictionary according to the scene table; the second dictionary comprises corresponding relations among the requirement identifications, the scenes, the factor information and the expected results;
a third generating unit 113 for generating a third dictionary according to a path of the function menu of the system; the third dictionary includes correspondence between the level four directories and the hierarchical paths.
In one embodiment, as shown in fig. 11, the determining module 12 includes:
the first traversal unit 121 is configured to traverse the second dictionary to obtain each column, and obtain a corresponding relationship between each factor and a value of the factor in each scene;
a first writing unit 122, configured to write the scenes and the correspondence between the factors and the values of the factors in the scenes into the precondition field.
In one embodiment, as shown in fig. 12, the determining module 12 further includes:
the second traversal unit 123 is configured to traverse the second dictionary to obtain each column, so as to obtain an expected result corresponding to each scene;
and a second writing unit 124, configured to write the expected result corresponding to each scene into the expected result field.
In one embodiment, as shown in fig. 13, the determining module 12 further includes:
the first searching unit 125 is configured to search, according to the first requirement identifier in the second dictionary, a four-level directory corresponding to the second requirement identifier in the first dictionary; the second requirement identification is the same as the first requirement identification;
the second searching unit 126 is configured to search the third dictionary according to the root level-four directory to obtain a level path corresponding to the level-four directory;
the third writing unit 127 is configured to write the four-level directory and the hierarchical path corresponding to the four-level directory into the path field.
In one embodiment, as shown in fig. 14, the determining module 12 further includes:
a fourth writing unit 128, configured to write the hierarchical path corresponding to the four-level directory into the first test step of the test step field;
a fifth writing unit 129, configured to write the content of the preset field into the second test step of the test step field.
In one embodiment, as shown in fig. 15, there is provided a test case generation apparatus, further including:
an analysis module 14, configured to analyze the test requirement table, and determine each factor and a value of each factor, where the factor is a factor that affects at least one of an expected result, a basic stream, and an alternative stream;
a combination module 15 for arranging and combining the factors and the factor values to obtain the factors and the factor values corresponding to the scenes;
and a third generating module 16, configured to generate a scene table according to the factor and the value of the factor corresponding to each scene, and the expected result of each scene.
For specific limitations of the test case generation apparatus, reference may be made to the above limitations of the test case generation method, which is not described herein again. The modules in the test case generation device may be implemented in whole or in part by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 16. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing test case data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a test case generation method.
Those skilled in the art will appreciate that the architecture shown in fig. 16 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
generating a dictionary according to the test requirement table, the scene table and the path of the function menu of the system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene;
determining the content corresponding to each field of the test case according to the dictionary;
and generating a test case according to the content corresponding to each field.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
generating a first dictionary according to the test requirement table; the first dictionary comprises a corresponding relation among requirement identification, requirement description and a four-level directory;
generating a second dictionary according to the scene table; the second dictionary comprises corresponding relations among the requirement identifications, the scenes, the factor information and the expected results;
generating a third dictionary according to the path of the function menu of the system; the third dictionary includes correspondence between the level four directories and the hierarchical paths.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
traversing the second dictionary to obtain each column, and obtaining the corresponding relation between each factor and the value of the factor under each scene;
and writing the scenes and the corresponding relation between the factors and the values of the factors in the scenes into the precondition field.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
traversing the second dictionary to obtain each column to obtain an expected result corresponding to each scene;
and writing the expected result corresponding to each scene into an expected result field.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
searching a four-level directory corresponding to a second demand identifier in the first dictionary according to the first demand identifier in the second dictionary; the second requirement identification is the same as the first requirement identification;
searching a third dictionary by the root level four directory to obtain a level path corresponding to the level four directory;
and writing the four-level directory and the corresponding hierarchical path of the four-level directory into the path field.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
writing a hierarchical path corresponding to the four-level directory into a first test step of the test step field;
and writing the content of the preset field into the second test step of the test step field.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
analyzing the test requirement table, and determining each factor and the value of each factor, wherein the factor is a factor which influences at least one of an expected result, a basic flow and an alternative flow;
the factors and the values of the factors are arranged and combined to obtain the factors and the values of the factors corresponding to the scenes;
and generating a scene table according to the factor corresponding to each scene, the value of the factor and the expected result of each scene.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
generating a dictionary according to the test requirement table, the scene table and the path of the function menu of the system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene;
determining the content corresponding to each field of the test case according to the dictionary;
and generating a test case according to the content corresponding to each field.
In one embodiment, the computer program when executed by the processor further performs the steps of:
generating a first dictionary according to the test requirement table; the first dictionary comprises a corresponding relation among requirement identification, requirement description and a four-level directory;
generating a second dictionary according to the scene table; the second dictionary comprises corresponding relations among the requirement identifications, the scenes, the factor information and the expected results;
generating a third dictionary according to the path of the function menu of the system; the third dictionary includes correspondence between the level four directories and the hierarchical paths.
In one embodiment, the computer program when executed by the processor further performs the steps of:
traversing the second dictionary to obtain each column, and obtaining the corresponding relation between each factor and the value of the factor under each scene;
and writing the scenes and the corresponding relation between the factors and the values of the factors in the scenes into the precondition field.
In one embodiment, the computer program when executed by the processor further performs the steps of:
traversing the second dictionary to obtain each column to obtain an expected result corresponding to each scene;
and writing the expected result corresponding to each scene into an expected result field.
In one embodiment, the computer program when executed by the processor further performs the steps of:
searching a four-level directory corresponding to a second demand identifier in the first dictionary according to the first demand identifier in the second dictionary; the second requirement identification is the same as the first requirement identification;
searching a third dictionary by the root level four directory to obtain a level path corresponding to the level four directory;
and writing the four-level directory and the corresponding hierarchical path of the four-level directory into the path field.
In one embodiment, the computer program when executed by the processor further performs the steps of:
writing a hierarchical path corresponding to the four-level directory into a first test step of the test step field;
and writing the content of the preset field into the second test step of the test step field.
In one embodiment, the computer program when executed by the processor further performs the steps of:
analyzing the test requirement table, and determining each factor and the value of each factor, wherein the factor is a factor which influences at least one of an expected result, a basic flow and an alternative flow;
the factors and the values of the factors are arranged and combined to obtain the factors and the values of the factors corresponding to the scenes;
generating a scene table according to the factor corresponding to each scene, the value of the factor and the expected result of each scene
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A test case generation method, the method comprising:
generating a dictionary according to the test requirement table, the scene table and the path of the function menu of the system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene;
determining the content corresponding to each field of the test case according to the dictionary;
and generating the test case according to the content corresponding to each field.
2. The method of claim 1, wherein generating the dictionary based on the test requirements table, the scenario table, and the path of the function menu of the system comprises:
generating a first dictionary according to the test requirement table; the first dictionary comprises a corresponding relation among requirement identification, requirement description and a four-level directory;
generating a second dictionary according to the scene table; the second dictionary comprises corresponding relations among the requirement identifications, the scenes, the factor information and the expected results;
generating a third dictionary according to the path of the function menu of the system; the third dictionary includes correspondence between level four directories and hierarchical paths.
3. The method according to claim 2, wherein the test case includes a precondition field, the factor information includes a plurality of factors and values of the factors, and the determining content corresponding to each field of the test case according to the dictionary includes:
traversing the second dictionary to obtain each column, and obtaining the corresponding relation between each factor and the value of the factor under each scene;
and writing the corresponding relation between each scene and each factor and the value of the factor under each scene into the precondition field.
4. The method according to claim 3, wherein the test case further includes an expected result field, and wherein determining the content corresponding to each field of the test case according to the dictionary further includes:
traversing each column of the second dictionary to obtain an expected result corresponding to each scene;
and writing an expected result corresponding to each scene into the expected result field.
5. The method according to any one of claims 2 to 4, wherein the test case includes a path field, and the determining the content corresponding to each field of the test case according to the dictionary includes:
searching a four-level directory corresponding to a second demand identifier in the first dictionary according to the first demand identifier in the second dictionary; the second requirement identification is the same as the first requirement identification;
searching the third dictionary according to the four-level directory to obtain a hierarchical path corresponding to the four-level directory;
and writing the four-level directory and the hierarchical path corresponding to the four-level directory into the path field.
6. The method according to claim 5, wherein the test case further includes test step fields, and the determining the content corresponding to each field of the test case according to the dictionary further includes:
writing the hierarchical path corresponding to the four-level directory into the first test step of the test step field;
and writing the content of the preset field into the second test step of the test step field.
7. The method of any one of claims 1 to 4, wherein the factor information includes a plurality of factors and values of the factors, the method further comprising:
analyzing the test requirement table, and determining each factor and the value of each factor, wherein the factor is a factor influencing at least one of an expected result, a basic flow and an alternative flow;
arranging and combining the factors and the values of the factors to obtain the factors and the values of the factors corresponding to the scenes;
and generating the scene table according to the factor corresponding to each scene, the value of the factor and the expected result of each scene.
8. A test case generation apparatus, the apparatus comprising:
the first generation module is used for generating a dictionary according to the test requirement table, the scene table and the path of the function menu of the system; the test requirement table comprises functions to be tested and requirement information corresponding to the functions, and the scene table comprises factor information and expected results corresponding to each scene;
the determining module is used for determining the content corresponding to each field of the test case according to the dictionary;
and the second generation module is used for generating the test case according to the content corresponding to each field.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202111445598.1A 2021-11-30 2021-11-30 Test case generation method and device, computer equipment and storage medium Pending CN114281679A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111445598.1A CN114281679A (en) 2021-11-30 2021-11-30 Test case generation method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111445598.1A CN114281679A (en) 2021-11-30 2021-11-30 Test case generation method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114281679A true CN114281679A (en) 2022-04-05

Family

ID=80870366

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111445598.1A Pending CN114281679A (en) 2021-11-30 2021-11-30 Test case generation method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114281679A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117271373A (en) * 2023-11-21 2023-12-22 太平金融科技服务(上海)有限公司深圳分公司 Automatic construction method and device for test cases, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117271373A (en) * 2023-11-21 2023-12-22 太平金融科技服务(上海)有限公司深圳分公司 Automatic construction method and device for test cases, electronic equipment and storage medium
CN117271373B (en) * 2023-11-21 2024-03-01 太平金融科技服务(上海)有限公司深圳分公司 Automatic construction method and device for test cases, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111176996A (en) Test case generation method and device, computer equipment and storage medium
CN111352907A (en) Method and device for analyzing pipeline file, computer equipment and storage medium
US10409820B2 (en) Semantic mapping of form fields
CN110955608B (en) Test data processing method, device, computer equipment and storage medium
CN108415826B (en) Application testing method, terminal device and computer readable storage medium
CN111581271A (en) Interface parameter determination method and device, computer equipment and storage medium
CN112199296B (en) Page testing method and device, computer equipment and storage medium
CN109446065A (en) User tag test method, device, computer equipment and storage medium
CN112416777B (en) Text display test method and device, computer equipment and storage medium
CN112286934A (en) Database table importing method, device, equipment and medium
CN114372006A (en) Method and system for automatically generating test case, computer equipment and storage medium
CN115438740A (en) Multi-source data convergence and fusion method and system
CN114281679A (en) Test case generation method and device, computer equipment and storage medium
CN109800147B (en) Test case generation method and terminal equipment
CN110532229B (en) Evidence file retrieval method, device, computer equipment and storage medium
CN103235757B (en) Several apparatus and method that input domain tested object is tested are made based on robotization
Qian et al. Error bound and exact penalty method for optimization problems with nonnegative orthogonal constraint
CN117332766A (en) Flow chart generation method, device, computer equipment and storage medium
CN113805861B (en) Code generation method based on machine learning, code editing system and storage medium
CN109635287A (en) Method, apparatus, computer equipment and the storage medium of policy dynamics analysis
CN112732423B (en) Process migration method, device, equipment and medium
CN113010550B (en) Batch object generation and batch processing method and device for structured data
CN110389754A (en) Method for processing business, system, server, terminal, electronic equipment and storage medium
CN111506299B (en) Front-end data verification method and device and computer equipment
CN117971675A (en) Evaluation method and device for code large model, computer equipment and 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