CN112256558B - 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
CN112256558B
CN112256558B CN202010985123.0A CN202010985123A CN112256558B CN 112256558 B CN112256558 B CN 112256558B CN 202010985123 A CN202010985123 A CN 202010985123A CN 112256558 B CN112256558 B CN 112256558B
Authority
CN
China
Prior art keywords
test
case
generating
test case
rule configuration
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.)
Active
Application number
CN202010985123.0A
Other languages
Chinese (zh)
Other versions
CN112256558A (en
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.)
Suning Cloud Computing Co Ltd
Original Assignee
Suning Cloud Computing 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 Suning Cloud Computing Co Ltd filed Critical Suning Cloud Computing Co Ltd
Priority to CN202010985123.0A priority Critical patent/CN112256558B/en
Publication of CN112256558A publication Critical patent/CN112256558A/en
Priority to CA3131079A priority patent/CA3131079A1/en
Application granted granted Critical
Publication of CN112256558B publication Critical patent/CN112256558B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

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 invention discloses a method and a device for generating a test case, computer equipment and a storage medium, wherein the method comprises the following steps: the method comprises the steps of receiving a generation request of a test case to be generated, matching a corresponding case template from a preset case template library according to the generation request, generating a test scene according to the case template and a rule configuration table, generating the rule configuration table according to the test requirement of the test case to be generated and a pre-configured parameter relation table, testing an object to be tested by using the test scene, obtaining a test result, generating a final test case according to the test scene and the test result, avoiding the problem of test scene omission caused by human factors, and greatly reducing the workload of test case writing.

Description

Test case generation method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of information testing technologies, and in particular, to a method and an apparatus for generating a test case, a computer device, and a storage medium.
Background
At present, when a tester writes a test case, the same operation steps are sometimes encountered, the test results are different due to different input conditions, and in order to deal with such test scenarios, the tester often lists all possible scenarios in a table format and then performs test case design.
However, the following may occur by using this design method: when the scenes are divided manually, part of the scenes are omitted; the scene division is correct, but when the test case is really compiled, part of scenes are omitted, and the inspection efficiency is low when the test case is inspected; when the combination is more, the workload of writing test cases is larger, and the like.
Therefore, it is necessary to provide a new method for generating test cases.
Disclosure of Invention
In order to solve the problems in the prior art, embodiments of the present invention provide a method and an apparatus for generating a test case, a computer device, and a storage medium, so as to overcome the problems in the prior art that a test scenario is omitted due to human factors when a test case is designed, and the workload for writing the test case is large.
In order to solve one or more technical problems, the invention adopts the technical scheme that:
in a first aspect, a method for generating a test case is provided, where the method includes the following steps:
receiving a generation request of a test case to be generated, and matching a corresponding case template from a preset case template library according to the generation request;
generating a test scene according to the case template and a rule configuration table, wherein the rule configuration table is generated according to the test requirement of the test case to be generated and a pre-configured parameter relation table;
testing the object to be tested by utilizing the test scene to obtain a test result;
and generating a final test case according to the test scene and the test result.
In some embodiments, the generation request includes user information, the method further comprising:
after receiving a generation request of a test case to be generated, extracting user information in the generation request, and authenticating a current user according to the user information.
In some embodiments, the method further comprises:
and if the authentication is successful, generating a rule configuration table according to the test requirement of the test case to be generated and a pre-configured parameter relation table.
In some embodiments, the method further comprises a rule configuration table generation process, including:
determining a module to be tested according to the test requirement of the test case to be generated, determining required parameters according to the module to be tested and a preset parameter relation table, and generating a rule configuration table according to the required parameters.
In some embodiments, said generating a rule configuration table according to said parameter information comprises:
creating an initial rule configuration table according to the required parameter information, respectively inserting the combination of the parameters into the initial rule configuration table, traversing the data in the initial rule configuration table, generating a corresponding execution result according to a preset execution condition, writing the execution result into the initial rule configuration table, and generating a final rule configuration table.
In some embodiments, the generating a test scenario according to the use case template and the rule configuration table includes:
analyzing the case template, generating a test case header according to an analysis result, and generating a test scene according to the test case header and the rule configuration table.
In some embodiments, the generation request includes a test case name and a path, and the method further includes:
after receiving a generation request of a test case to be generated, extracting a test case name and a path in the generation request, judging whether the test case name and the path exist or not, and deleting the existing test case if the test case name and the path exist.
In a second aspect, an apparatus for generating a test case is provided, where the apparatus includes:
the request receiving module is used for receiving a generation request of a test case to be generated;
the template matching module is used for matching a corresponding use case template from a preset use case template library according to the generation request;
the scene generating module is used for generating a test scene according to the case template and a rule configuration table, and the rule configuration table is generated according to the test requirement of the test case to be generated and a pre-configured parameter relation table;
the result acquisition module is used for testing the object to be tested by utilizing the test scene to acquire a test result;
and the case generating module is used for generating a final test case according to the test scene and the test result.
In a third aspect, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the following steps when executing the computer program:
receiving a generation request of a test case to be generated, and matching a corresponding case template from a preset case template library according to the generation request;
generating a test scene according to the case template and a rule configuration table, wherein the rule configuration table is generated according to the test requirements of the test case to be generated and a pre-configured parameter relation table;
testing the object to be tested by utilizing the test scene to obtain a test result;
and generating a final test case according to the test scene and the test result.
In a fourth aspect, there is provided a computer readable storage medium having a computer program stored thereon, which when executed by a processor, performs the steps of:
receiving a generation request of a test case to be generated, and matching a corresponding case template from a preset case template library according to the generation request;
generating a test scene according to the case template and a rule configuration table, wherein the rule configuration table is generated according to the test requirements of the test case to be generated and a pre-configured parameter relation table;
testing the object to be tested by utilizing the test scene to obtain a test result;
and generating a final test case according to the test scene and the test result.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
1. according to the test case generation method and device, the computer equipment and the storage medium provided by the embodiment of the invention, the corresponding case template is matched from the preset case template library according to the generation request by receiving the generation request of the test case to be generated; generating a test scene according to the case template and a rule configuration table, wherein the rule configuration table is generated according to the test requirements of the test case to be generated and a pre-configured parameter relation table; testing the object to be tested by utilizing the test scene to obtain a test result; generating a final test case according to the test scene and the test result, avoiding the problem of test scene omission caused by human factors, and greatly reducing the workload of writing the test case;
2. according to the test case generation method and device, the computer equipment and the storage medium provided by the embodiment of the invention, the module to be tested is determined according to the test requirement of the test case to be generated, the required parameters are determined according to the module to be tested and the preset parameter relation table, and the rule configuration table is generated according to the required parameters, so that the automatic creation of the parameters is realized, and the working efficiency is improved.
All products of the present invention need not have all of the above-described effects.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is an architecture diagram illustrating a system for test case generation in accordance with an illustrative embodiment;
FIG. 2 is a flow diagram illustrating a method for test case generation in accordance with an illustrative embodiment;
FIG. 3 is a flow diagram illustrating a method for test case generation in accordance with an illustrative embodiment;
FIG. 4 is a flow diagram illustrating user authentication in accordance with an exemplary embodiment;
FIG. 5 is a flow diagram illustrating the generation of a rule configuration table in accordance with an exemplary embodiment;
FIG. 6 is a schematic diagram of a structure of a test case generation apparatus according to an exemplary embodiment;
FIG. 7 is a schematic diagram of an internal structure of a computer device shown in accordance with an exemplary embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As described in the background art, in order to solve the above problems, an embodiment of the present invention provides a method for generating a test case, and in response to the method, an embodiment of the present invention further provides a system for generating a test case, where a software architecture adopted by the system is divided into three layers, as shown in fig. 1, a Swing is adopted in a view layer to process each page interacting with a user, such as user login and each configuration system page; the business layer is a business processing module containing the core function of the system, and comprises modules such as user authentication, rule generation, case automatic generation, rule matching and the like; the storage layer adopts a traditional mysql database to store corresponding information, including user information, rule storage, case template information and the like. The system automatically designs the test cases by using the judgment table, can reduce the problem of test scene omission caused by other human factors, and can reset parameters to automatically create the use cases according to the change of a subsequent test system.
Fig. 2 and 3 are flowcharts of a method for generating a test case according to an exemplary embodiment, and referring to fig. 2 and 3, the method includes the following steps:
s1: receiving a generation request of a test case to be generated, and matching a corresponding case template from a preset case template library according to the generation request.
Specifically, in the embodiment of the invention, a pre-configured case template is adopted in the process of generating the test case, and the case template can be reused through the system without redesigning each time of design, so that the uniformity of the test case is ensured. And during specific implementation, storing the pre-configured use case template into a use case template library, and matching the use case template meeting the requirements from the use case template library according to the received generation request of the test case to be generated when the use case template is required.
As a preferred implementation manner, in the embodiment of the present invention, a use case template configuration system is provided, which is mainly used for configuring a subsequently generated test case template, where a configured parameter includes an element included in a use case. Such as: case number, case name, case description, case grade, preset conditions, test data, step description, expected output, case label and the like, and various parameters configured by a user are uniformly stored in a database. The administrator user can configure the case templates in a unified way, and the templates can generate the test case templates for a specific system or a specific department in a unified way, so that the problem that the case templates are not unified due to human factors is solved. The user can load the configured use case template in the system without manually configuring the use case template, thereby achieving the purpose of reusing the use case template. After the user performs configuration in the system, all configuration information is stored in the database, for example, the table structure description in the database may be as follows:
example of a template field for a Table user
Name of field Type of field Description of the invention
cmodeId Int Numbering
modeName varchar Belonging module
Item varchar Elements of use case
position Int The position of the case element: 1 is the 1 st position
owner Varchar The person to whom
S2: and generating a test scene according to the case template and a rule configuration table, wherein the rule configuration table is generated according to the test requirements of the test case to be generated and a pre-configured parameter relation table.
Specifically, in the embodiment of the present invention, in order to avoid the problem of test scenario omission due to artificial factors when a use case is designed, when a test scenario is generated, the test scenario is generated according to a matched use case template and a rule configuration table, where the rule configuration table is generated according to a test requirement of a test use case to be generated and a preconfigured parameter relationship table.
S3: and testing the object to be tested by utilizing the test scene to obtain a test result.
S4: and generating a final test case according to the test scene and the test result.
As a preferred implementation manner, in the embodiment of the present invention, a test case generation system is provided, where the system completes automatic generation of a test case, and a user only needs to configure a case name and an output path in the system. With further reference to fig. 3, the system accomplishes the automatic generation of test cases by:
1) Checking whether the case exists in the path or not according to the case name and the path input by the user, if so, prompting to delete the case, and if not, establishing a test case file;
2) Reading a case template from the database to generate a header of the test case;
3) Generating a corresponding test scene according to the test parameter configuration system, generating a corresponding output result according to the output rule, and automatically generating a corresponding case number;
4) The two types of information are uniformly stored into a use case object (if the two types of information can be realized in a code), and all the objects are uniformly stored into an array;
5) And traversing the object array, acquiring a corresponding case number, an input condition and an output result field, and inputting the case number, the input condition and the output result field into the test case table until the test case is generated.
As a preferred implementation manner, in an embodiment of the present invention, the generation request includes user information, and the method further includes:
after receiving a generation request of a test case to be generated, extracting user information in the generation request, and authenticating a current user according to the user information.
Specifically, in the embodiment of the present invention, in order to ensure the security of data, before generating a test case, an authentication operation needs to be performed on a user who sends a generation request, that is, the validity and validity (whether the state is activated) of a data service used by the user are checked.
As a preferred implementation manner, in the embodiment of the present invention, a user authentication system is further provided, as shown in fig. 4, when a user logs in the system, an account and a password need to be provided for logging in, when the login is clicked, the system obtains the account, the password, and a user name and a password stored in a background server to perform verification, if the login is successful, the system enters the system, and different configuration pages are loaded according to whether the user is a new user, otherwise, a corresponding prompt is given in the login page. The user information table (userInfo) stores fields in the database as follows:
table two user information table storing field descriptions in a database
Name of field Field type Description of the invention
id Int User number
account varchar User account
password varchar User password: encryption in database storage
As a preferred implementation manner, in an embodiment of the present invention, the method further includes:
and if the authentication is successful, generating a rule configuration table according to the test requirements of the test case to be generated and a pre-configured parameter relation table.
Specifically, when the authentication is successful, entering a parameter configuration page, and generating a rule configuration table according to the test requirements of the test case to be generated and a pre-configured parameter relationship table. As further shown in fig. 4, in the embodiment of the present invention, it may also be set to verify whether the current user is a new user or an old user through user information, and if the current user is the new user, the current user directly enters a parameter configuration page, and if the current user is the old user, the parameter configuration page of the module created by the user before is loaded for the user to edit, so that the user does not need to start the design again, and the efficiency is improved.
As a preferred implementation manner, in the embodiment of the present invention, the method further includes a process of generating a rule configuration table, including:
determining a module to be tested according to the test requirement of the test case to be generated, determining required parameters according to the module to be tested and a preset parameter relation table, and generating a rule configuration table according to the required parameters.
Specifically, in order to avoid the problem of parameter omission due to human factors, in the generation process of the rule configuration table, the module to be tested may be determined according to the test requirements of the test case to be generated, then the preset parameter relationship table may be queried, the parameters required by the module to be tested may be determined, and finally the rule configuration table may be generated according to the required parameters. Referring to fig. 5, in the embodiment of the present invention, a test parameter configuration system is further provided, where a user successfully logs in a system and then performs test parameter configuration, if a current user has a certain module test parameter before operation, the current user modifies the current test parameter through the page because the current scene of the system to be tested changes and needs to modify the test parameter, and if the current user has no operation before, the current user directly performs configuration through the system.
The parameters that the user needs to configure include, but are not limited to, a test module, input parameters, values of the input parameters, and a module english abbreviation, where the values of the input parameters may be characters or numbers, and are divided by scenes.
The parameter configuration system provides system support for subsequent system setting through determining the value of the module to be tested and the input parameter and storing the corresponding information in a test parameter configuration table in a database. As an example, a test parameter configuration table (modelnfo) storage field description is shown in the following table:
table three test parameter configuration table storage field description
Name of field Field type Description of the preferred embodiment
pId Int Parameter numbering
modelName varchar Module name: the module to which the parameter belongs
paraName varchar Parameter name
paraValue varchar Parameter value
ModeEn varchar Module English abbreviation
owner varchar The affiliated account number
The following is an example:
when the module to be tested is determined to be the query module in user management according to the test requirement of the test case to be generated, namely the query module needs to be tested, the name of the input parameter can be automatically obtained by reading the page element, the automatic obtaining method comprises the steps of checking the label of the page control, obtaining the attribute name of the page control, and automatically obtaining the input parameter which respectively comprises the user information, the user name, the starting time and the ending time of the creation time and the role, wherein the value of the role is automatically obtained through the page, such as an administrator or a common user. The value of the user information includes, but is not limited to, a null value, a valid job number, a non-existing job number, a valid mobile phone number, and a non-existing mobile phone number, the user name includes, but is not limited to, a null value, a valid user name, and a non-existing name, the creation time includes, but is not limited to, a null value, a valid time, and an invalid time, and the role includes, but is not limited to, all, administrator, and general user, etc.
As a preferred implementation manner, in an embodiment of the present invention, the generating a rule configuration table according to the parameter information includes:
creating an initial rule configuration table according to the required parameter information, respectively inserting the combination of the parameters into the initial rule configuration table, traversing the data in the initial rule configuration table, generating a corresponding execution result according to a preset execution condition, writing the execution result into the initial rule configuration table, and generating a final rule configuration table.
Specifically, as shown in fig. 5, after a module to be tested is determined, according to a preset embodiment of the present invention, when a rule configuration table is generated, parameters required by the module to be tested are firstly queried according to a preset parameter relationship table, the related parameters are stored in a pre-created array, then an initial rule configuration table is created according to the parameters in the array, combinations of the parameters are respectively inserted into the initial rule configuration table, data in the initial rule configuration table is traversed, a corresponding execution result is generated according to a preset execution condition, if the execution condition is met, execution is successful, otherwise, execution is failed, and finally, the execution result obtained in the above steps is written into a corresponding position of the initial rule configuration table (if successful information is written into a corresponding row success field, failed information is written into a corresponding row failure field), so as to generate a final rule configuration table.
As a preferred implementation manner, in the embodiment of the present invention, the generating a test scenario according to the use case template and the rule configuration table includes:
analyzing the case template, generating a test case header according to an analysis result, and generating a test scene according to the test case header and the rule configuration table.
Specifically, as further shown in fig. 3, in the embodiment of the present invention, when a test scenario is generated according to a case template and a rule configuration table, the obtained case template is analyzed first, then a test case header is generated according to an analysis result, and finally, the test scenario is generated according to the test case header and the rule configuration table.
As a preferred implementation manner, in an embodiment of the present invention, the generation request includes a test case name and a path, and the method further includes:
after receiving a generation request of a test case to be generated, extracting a test case name and a path in the generation request, judging whether the test case name and the path exist or not, and deleting the existing test case if the test case name and the path exist.
Specifically, as further shown in fig. 3, in the embodiment of the present invention, the generation request includes a test case name and a path, and the test case name and the path may also be input by the user. After the test case name and the test case path are obtained, whether the test case name and the test case path exist or not needs to be judged, if yes, a user is prompted to delete the existing test case, deletion is prompted first, and if not, the next step is continued, namely the corresponding case template is matched from a preset case template library according to the generation request.
As a preferred implementation manner, in an embodiment of the present invention, an output rule configuration system is further provided, where the system is mainly used to configure a relationship between an input parameter and an output result of a user, for example, when the input parameter satisfies a certain condition, an output result is a, and when the input parameter does not satisfy the condition, an output result is B, so as to prepare a condition for subsequently generating a use case. In the output rule configuration system, the parameters that the user needs to input include, but are not limited to, the relationship between the test parameters and the values thereof, the relationship between the parameters, the output results after the conditions are satisfied, the output results that do not satisfy the conditions, and the like. After the user completes the configuration, the corresponding table is generated in the database, and generally, the user only needs to configure the table that satisfies the execution success of the use case and the table that satisfies the execution failure.
The parameter relation table is used for recording parameters and values input by a user and recording the relation with other parameters, and is shown as the following table:
table four parameter relationship table field
Figure BDA0002687362200000111
As a preferred embodiment, the output rule configuration table may be automatically generated by the system code according to the parameter relationship table, and the process is as follows:
1. inquiring the different parameters according to the belonged person and the belonged module, and recording the parameters in an array; and (3) creating an output rule configuration table according to the parameters of the array: the information of the table comprises a serial number, each parameter of a user, a successful value and an unsuccessful value which are respectively saved by using fields of passResult and failResult, and the unified format of an output rule configuration table is module serial number _ config;
2. inquiring the values of the parameters according to the names of the parameters, and inserting the values into the output rule configuration table;
3. the values of the output result, including success and failure, are read and information is input into the corresponding fields of the configuration table (passResult and failResult fields).
The following table is an example of the rule number of the output rule configuration table, and specifically includes the following:
table five rule numbering
User information Name of user Creation time Character Outputting the result
Null value Null value Null value All are provided with Success of the query
Null value Null value Null value Administrator Success of the query
Null value Null value Null value General users Success of query
Effective job number Any value Effective value All of Success of query
Effective mobile phone number Any value Effective value All are provided with Success of query
Any value Valid name Effective value All of Success of query
Fig. 6 is a schematic structural diagram of a test case generation apparatus according to an exemplary embodiment, where the apparatus includes:
the request receiving module is used for receiving a generation request of a test case to be generated;
the template matching module is used for matching a corresponding use case template from a preset use case template library according to the generation request;
the scene generating module is used for generating a test scene according to the case template and a rule configuration table, and the rule configuration table is generated according to the test requirement of the test case to be generated and a pre-configured parameter relation table;
the result acquisition module is used for testing the object to be tested by utilizing the test scene to acquire a test result;
and the case generating module is used for generating a final test case according to the test scene and the test result.
As a preferred implementation manner, in an embodiment of the present invention, the generation request includes user information, and the apparatus further includes:
and the user authentication module is used for extracting the user information in the generation request after receiving the generation request of the test case to be generated and authenticating the current user according to the user information.
As a preferred implementation manner, in an embodiment of the present invention, the apparatus further includes:
and the rule configuration module is used for generating a rule configuration table according to the test requirement of the test case to be generated and a pre-configured parameter relation table if the authentication is successful.
As a preferred implementation manner, in an embodiment of the present invention, the rule configuration module is further configured to:
determining a module to be tested according to the test requirement of the test case to be generated, determining required parameters according to the module to be tested and a preset parameter relation table, and generating a rule configuration table according to the required parameters.
As a preferred implementation manner, in an embodiment of the present invention, the rule configuration module is further configured to:
creating an initial rule configuration table according to the required parameter information, respectively inserting the combination of the parameters into the initial rule configuration table, traversing the data in the initial rule configuration table, generating a corresponding execution result according to a preset execution condition, writing the execution result into the initial rule configuration table, and generating a final rule configuration table.
As a preferred implementation manner, in the embodiment of the present invention, the scene generation module is specifically configured to:
and analyzing the case template, generating a test case header according to an analysis result, and generating a test scene according to the test case header and the rule configuration table.
As a preferred implementation manner, in an embodiment of the present invention, the apparatus further includes:
and the duplication checking processing module is used for extracting the name and the path of the test case in the generation request after receiving the generation request of the test case to be generated, judging whether the name and the path of the test case exist or not, and deleting the existing test case if the name and the path of the test case exist.
Fig. 7 is a schematic diagram illustrating an internal configuration of a computer device according to an exemplary embodiment, which includes a processor, a memory, and a network interface connected through a system bus, as shown in fig. 7. 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 operating system and the computer program to run on the non-volatile storage medium. 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 method of optimization of an execution plan.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the inventive arrangements and is not intended to limit the computing devices to which the inventive arrangements may be applied, as a particular computing device may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
As a preferred implementation manner, in an embodiment of the present invention, the computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the following steps are implemented:
receiving a generation request of a test case to be generated, and matching a corresponding case template from a preset case template library according to the generation request;
generating a test scene according to the case template and a rule configuration table, wherein the rule configuration table is generated according to the test requirements of the test case to be generated and a pre-configured parameter relation table;
testing the object to be tested by utilizing the test scene to obtain a test result;
and generating a final test case according to the test scene and the test result.
As a preferred implementation manner, in the embodiment of the present invention, when the processor executes the computer program, the following steps are further implemented:
after receiving a generation request of a test case to be generated, extracting user information in the generation request, and authenticating a current user according to the user information.
As a preferred implementation manner, in the embodiment of the present invention, when the processor executes the computer program, the following steps are further implemented:
and if the authentication is successful, generating a rule configuration table according to the test requirements of the test case to be generated and a pre-configured parameter relation table.
As a preferred implementation manner, in the embodiment of the present invention, when the processor executes the computer program, the following steps are further implemented:
determining a module to be tested according to the test requirement of the test case to be generated, determining required parameters according to the module to be tested and a preset parameter relation table, and generating a rule configuration table according to the required parameters.
As a preferred implementation manner, in the embodiment of the present invention, when the processor executes the computer program, the following steps are further implemented:
creating an initial rule configuration table according to the required parameter information, respectively inserting the combination of the parameters into the initial rule configuration table, traversing the data in the initial rule configuration table, generating a corresponding execution result according to a preset execution condition, writing the execution result into the initial rule configuration table, and generating a final rule configuration table.
As a preferred implementation manner, in the embodiment of the present invention, when the processor executes the computer program, the following steps are further implemented:
and analyzing the case template, generating a test case header according to an analysis result, and generating a test scene according to the test case header and the rule configuration table.
As a preferred implementation manner, in the embodiment of the present invention, when the processor executes the computer program, the following steps are further implemented:
after receiving a generation request of a test case to be generated, extracting a test case name and a path in the generation request, judging whether the test case name and the path exist or not, and deleting the existing test case if the test case name and the path exist.
In an embodiment of the present invention, a computer-readable storage medium is further provided, on which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the following steps:
receiving a generation request of a test case to be generated, and matching a corresponding case template from a preset case template library according to the generation request;
generating a test scene according to the case template and a rule configuration table, wherein the rule configuration table is generated according to the test requirement of the test case to be generated and a pre-configured parameter relation table;
testing the object to be tested by utilizing the test scene to obtain a test result;
and generating a final test case according to the test scene and the test result.
As a preferred implementation manner, in the embodiment of the present invention, when executed by a processor, the computer program further implements the following steps:
after receiving a generation request of a test case to be generated, extracting user information in the generation request, and authenticating a current user according to the user information.
As a preferred implementation manner, in the embodiment of the present invention, when executed by the processor, the computer program further implements the following steps:
and if the authentication is successful, generating a rule configuration table according to the test requirements of the test case to be generated and a pre-configured parameter relation table.
As a preferred implementation manner, in the embodiment of the present invention, when executed by the processor, the computer program further implements the following steps:
determining a module to be tested according to the test requirement of the test case to be generated, determining required parameters according to the module to be tested and a preset parameter relation table, and generating a rule configuration table according to the required parameters.
As a preferred implementation manner, in the embodiment of the present invention, when executed by the processor, the computer program further implements the following steps:
creating an initial rule configuration table according to the required parameter information, respectively inserting the combination of the parameters into the initial rule configuration table, traversing the data in the initial rule configuration table, generating a corresponding execution result according to a preset execution condition, writing the execution result into the initial rule configuration table, and generating a final rule configuration table.
As a preferred implementation manner, in the embodiment of the present invention, when executed by the processor, the computer program further implements the following steps:
analyzing the case template, generating a test case header according to an analysis result, and generating a test scene according to the test case header and the rule configuration table.
As a preferred implementation manner, in the embodiment of the present invention, when executed by the processor, the computer program further implements the following steps:
after receiving a generation request of a test case to be generated, extracting a name and a path of the test case in the generation request, judging whether the name and the path of the test case exist, and if so, deleting the existing test case.
In summary, the technical solution provided by the embodiment of the present invention has the following beneficial effects:
1. according to the test case generation method and device, the computer equipment and the storage medium provided by the embodiment of the invention, the corresponding case template is matched from the preset case template library according to the generation request by receiving the generation request of the test case to be generated; generating a test scene according to the case template and a rule configuration table, wherein the rule configuration table is generated according to the test requirements of the test case to be generated and a pre-configured parameter relation table; testing the object to be tested by utilizing the test scene to obtain a test result; generating a final test case according to the test scene and the test result, avoiding the problem of test scene omission caused by human factors, and simultaneously greatly reducing the workload of compiling the test case;
2. according to the test case generation method and device, the computer equipment and the storage medium provided by the embodiment of the invention, the module to be tested is determined according to the test requirement of the test case to be generated, the required parameters are determined according to the module to be tested and the preset parameter relation table, and the rule configuration table is generated according to the required parameters, so that the automatic creation of the parameters is realized, and the working efficiency is improved.
It should be noted that: the test case generation device provided in the foregoing embodiment is only illustrated by dividing the functional modules when triggering the test case generation service, and in practical applications, the function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the test case generation device and the test case generation method provided by the above embodiments belong to the same concept, that is, the device is based on the test case generation method, and the specific implementation process thereof is detailed in the method embodiments and will not be described herein again.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (7)

1. A method for generating a test case is characterized by comprising the following steps:
receiving a generation request of a test case to be generated, and matching a corresponding case template from a preset case template library according to the generation request;
generating a test scene according to the case template and a rule configuration table, wherein the rule configuration table is generated according to the test requirements of the test case to be generated and a pre-configured parameter relation table;
testing the object to be tested by utilizing the test scene to obtain a test result;
generating a final test case according to the test scene and the test result;
the generation process of the rule configuration table specifically includes:
determining a module to be tested according to the test requirement of the test case to be generated, determining required parameters according to the module to be tested and a preset parameter relation table, and generating a rule configuration table according to the required parameters;
wherein the generating a rule configuration table according to the parameter comprises:
creating an initial rule configuration table according to the required parameters, respectively inserting the combination of the parameters into the initial rule configuration table, traversing the data in the initial rule configuration table, and generating a corresponding execution result according to a preset execution condition;
if the execution condition is met, the execution is successful;
if the execution condition is not met, writing the execution result into a corresponding position of the initial rule configuration table to generate a final rule configuration table;
generating a test scenario according to the use case template and the rule configuration table comprises:
and analyzing the case template, generating a test case header according to an analysis result, and generating a test scene according to the test case header and the rule configuration table.
2. The method for generating test cases according to claim 1, wherein the generation request includes user information, and the method further comprises:
after receiving a generation request of a test case to be generated, extracting user information in the generation request, and authenticating a current user according to the user information.
3. The method for generating the test case according to claim 2, wherein the method further comprises:
and if the authentication is successful, generating a rule configuration table according to the test requirements of the test case to be generated and a pre-configured parameter relation table.
4. The method for generating the test case according to any one of claims 1 to 3, wherein the generation request includes a test case name and a path, and the method further includes:
after receiving a generation request of a test case to be generated, extracting a name and a path of the test case in the generation request, judging whether the name and the path of the test case exist, and if so, deleting the existing test case.
5. An apparatus for implementing the test case generation method of claim 1, the apparatus comprising:
the request receiving module is used for receiving a generation request of a test case to be generated;
the template matching module is used for matching a corresponding use case template from a preset use case template library according to the generation request;
the scene generating module is used for generating a test scene according to the case template and a rule configuration table, and the rule configuration table is generated according to the test requirement of the test case to be generated and a pre-configured parameter relation table;
the result acquisition module is used for testing the object to be tested by utilizing the test scene to acquire a test result;
and the case generating module is used for generating a final test case according to the test scene and the test result.
6. A computer arrangement comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 4 when executing the computer program.
7. 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 4.
CN202010985123.0A 2020-09-17 2020-09-17 Test case generation method and device, computer equipment and storage medium Active CN112256558B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202010985123.0A CN112256558B (en) 2020-09-17 2020-09-17 Test case generation method and device, computer equipment and storage medium
CA3131079A CA3131079A1 (en) 2020-09-17 2021-09-17 Test case generation method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010985123.0A CN112256558B (en) 2020-09-17 2020-09-17 Test case generation method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112256558A CN112256558A (en) 2021-01-22
CN112256558B true CN112256558B (en) 2023-03-17

Family

ID=74231591

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010985123.0A Active CN112256558B (en) 2020-09-17 2020-09-17 Test case generation method and device, computer equipment and storage medium

Country Status (2)

Country Link
CN (1) CN112256558B (en)
CA (1) CA3131079A1 (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111581074A (en) * 2020-03-26 2020-08-25 平安普惠企业管理有限公司 Call scene coverage testing method and device, computer equipment and storage medium
CN113051171B (en) * 2021-04-08 2024-04-02 深圳赛安特技术服务有限公司 Interface testing method, device, equipment and storage medium
CN113190434B (en) * 2021-04-12 2024-03-08 成都安易迅科技有限公司 Test case generation method and device, storage medium and computer equipment
CN113176995B (en) * 2021-04-28 2024-03-19 平安银行股份有限公司 Interface testing method, device, equipment and medium based on testing scene
CN113138933A (en) * 2021-05-13 2021-07-20 网易(杭州)网络有限公司 Data table testing method, electronic device and storage medium
CN114116452A (en) * 2021-10-29 2022-03-01 北京达佳互联信息技术有限公司 Test case generation method and device, electronic equipment and storage medium
CN115047836A (en) * 2022-06-27 2022-09-13 中国核动力研究设计院 Test case generation and loading method and system based on DCS system periodic test
CN115454828A (en) * 2022-08-25 2022-12-09 深圳市沃享科技有限公司 Online case testing method, equipment and storage medium
CN115509900B (en) * 2022-09-15 2024-02-02 上海宜软检测技术有限公司 Method and system for generating functional test cases
CN115237814B (en) * 2022-09-20 2022-12-13 北京结慧科技有限公司 Method and system for automatically generating interface test case, storage medium and equipment
CN116185883A (en) * 2023-04-28 2023-05-30 阿里云计算有限公司 Test case generation method, test system, device, equipment and medium
CN116304399B (en) * 2023-05-19 2023-08-11 建信金融科技有限责任公司 Visual processing method, device and system for test cases
CN118519920A (en) * 2024-07-24 2024-08-20 中邮消费金融有限公司 Automatic test method, device, equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6542612B2 (en) * 2015-08-21 2019-07-10 株式会社日立製作所 Test scenario generation support apparatus and test scenario generation support method
CN111506498B (en) * 2020-03-16 2022-06-21 平安科技(深圳)有限公司 Automatic generation method and device of test case, computer equipment and storage medium

Also Published As

Publication number Publication date
CN112256558A (en) 2021-01-22
CA3131079A1 (en) 2022-03-17

Similar Documents

Publication Publication Date Title
CN112256558B (en) Test case generation method and device, computer equipment and storage medium
WO2020024408A1 (en) Test device, test method and storage medium
CN114048701B (en) Netlist ECO method, device, equipment and readable storage medium
CN111414391A (en) Method and system for accessing multiple data sources
CN108923997B (en) Cloud service node automatic testing method and device based on python
CN111124872A (en) Branch detection method and device based on difference code analysis and storage medium
CN111782207B (en) Task stream code generation method, device, equipment and storage medium
CN111737227A (en) Data modification method and system
CN114443039A (en) Input parameter verification method and device, electronic equipment and storage medium
CN112287400A (en) Transaction sequencing method and device in super account book and computer equipment
CN116502259A (en) Database management method and device based on tenant ID and computer readable medium
CN116166525A (en) Method and device for generating test script
CN112947907B (en) Method for creating code branches
CN112561690A (en) Method, system, equipment and storage medium for testing credit card staging service interface
CN112699027A (en) Interface testing method, device, equipment and readable storage medium
CN116599881A (en) Cloud platform tenant modeling test method, device, equipment and storage medium
CN116561003A (en) Test data generation method, device, computer equipment and storage medium
CN112583890B (en) Message pushing method and device based on enterprise office system and computer equipment
CN114003250A (en) Software deployment method and device
CN109165208B (en) Method and system for loading data into database
CN110716863A (en) Method, system, terminal and storage medium for testing mandatory access control rule
CN112445461A (en) Business rule generation method and device, electronic equipment and readable storage medium
CN110995526A (en) Database resource isolation test method, system, terminal and storage medium
CN113296789B (en) Code generation method, device, equipment and storage medium
CN110990475B (en) Batch task inserting method and device, 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
GR01 Patent grant
GR01 Patent grant