CN115391188A - Scene test case generation method, device, equipment and storage medium - Google Patents
Scene test case generation method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN115391188A CN115391188A CN202210994411.1A CN202210994411A CN115391188A CN 115391188 A CN115391188 A CN 115391188A CN 202210994411 A CN202210994411 A CN 202210994411A CN 115391188 A CN115391188 A CN 115391188A
- Authority
- CN
- China
- Prior art keywords
- case
- interface
- test
- identifier
- target
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The embodiment of the application provides a method, a device, equipment and a storage medium for generating a scene test case, which relate to the technical field of software testing, and the method comprises the following steps: based on the test service requirement, determining scene case identification associated with the test service requirement, and determining each interface case identification corresponding to the scene case identification and a first calling sequence relation of each interface case identification. And modifying the interface case identifications and the first calling sequence relation based on the test service requirement to obtain target interface case identifications and second calling sequence relation of the target interface case identifications. And generating a target interface test case aiming at any target interface case identifier. And generating a target scene test case based on the target interface test cases and the second calling sequence relation. According to the method and the device, the use case identifiers of the interfaces and the first calling sequence relation are adjusted according to the test service requirements, so that the test cost and the maintenance cost are reduced.
Description
Technical Field
The embodiment of the invention relates to the technical field of software testing, in particular to a method, a device, equipment and a storage medium for generating a scene test case.
Background
With the rapid development of computer technology, the structure of software products becomes more and more complex. In order to ensure the software quality, the functional test of the software product by adopting the test case is a necessary technical means. At present, two test cases are included, namely an interface test case and a scenario test case.
The interface test case is used for testing one interface in a single service module, for example, logging in a login interface in the service module, compiling the login interface test case aiming at the login interface, and testing the login interface by using the login interface test case.
The scenario test case is used for testing a plurality of interfaces in a service scenario (including a plurality of service modules), the scenario test case includes a plurality of interface test cases, for example, a query scenario is login- > query- > logout, and the query scenario includes 3 interfaces, which are a login interface, a query interface, and a logout interface, respectively. And compiling a query scene test case aiming at the query scene, and testing the query scene by using the query scene test case.
At present, because the scenario test cases need to be written separately for different service scenarios, when a service scenario changes, a new scenario test case needs to be written according to the changed service scenario or each interface test case in an existing scenario test case needs to be modified, which will increase the test cost and maintenance cost and reduce the software test efficiency at the same time.
Disclosure of Invention
The embodiment of the application provides a method, a device, equipment and a storage medium for generating a scenario test case, which are used for reducing the test cost and the maintenance cost and improving the software testing efficiency.
In one aspect, an embodiment of the present application provides a method for generating a scenario test case, where the method includes:
determining a scene case identifier matched with the test service requirement based on the test service requirement;
determining each interface case identifier corresponding to the scene case identifier matched with the test service requirement and a first calling sequence relation of each interface case identifier from the scene case record;
modifying the interface case identifications and the first calling sequence relation based on the test service requirement to obtain target interface case identifications and second calling sequence relations of the target interface case identifications;
aiming at any target interface use case identification, determining a target interface identification and a target request parameter use case corresponding to the target interface use case identification from an interface use case record; determining a target request identifier corresponding to the target interface identifier from an interface record, and generating a target interface test case based on the target request identifier and the target request parameter case;
and generating a target scene test case based on the target interface test cases and the second calling sequence relation.
Optionally, before determining the scene use case identifier matched with the test service requirement based on the test service requirement, the method further includes:
capturing original test data from a system to be tested, and analyzing the original test data to obtain a scene test case, wherein the scene test case comprises at least one interface test case;
aiming at any interface test case, the following steps are executed:
determining an interface identifier and a request identifier corresponding to the interface test case, and adding the interface identifier and the request identifier to the interface record;
determining an interface use case identifier and a request parameter use case corresponding to the interface test use case, and adding the interface identifier, the interface use case identifier and the request parameter use case to the interface use case record;
determining a scene case identifier corresponding to the scene test case, and adding the scene case identifier, each interface case identifier corresponding to the scene case identifier and a first calling sequence relation of each interface case identifier to the scene case record.
Optionally, the raw test data includes a plurality of raw test cases;
the analyzing the original test data to obtain a scenario test case includes:
aiming at any original test case in the original test data, determining at least one target test case from the original test data based on the matching relation between the request identifier in the original test case and the global configuration rule;
and respectively taking the at least one target test case as interface test cases, and assembling the at least one target test case into the scene test case according to the sequence.
Optionally, the global configuration rule includes a blacklist rule and a whitelist rule;
the determining at least one target test case from the original test data based on the matching relationship between the request identifier in the original test case and the global configuration rule includes:
if any request identification in the original test case is matched with the blacklist rule, deleting the original test case; taking other original test cases in the original test data as target test cases; and if any request identifier in the original test case is matched with the white list rule and is not matched with the black list rule, taking the original test case as a target test case.
Optionally, the request identifier corresponding to each interface identifier in the interface record includes: the system comprises a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier.
Optionally, after determining the interface identifier and the request identifier corresponding to the interface test case, the method further includes:
generating a directory file based on the request path identification in the interface test case;
generating a request file based on a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier in the interface test case, and adding the request file into the directory file;
and adding the interface identifier and the directory file name corresponding to the directory file to a directory file retrieval record.
Optionally, adding the interface identifier, the interface use case identifier, and the request parameter use case to the interface use case record includes:
and acquiring an interface test result corresponding to the interface test case from a system to be tested, taking the interface test result as assertion information, and adding the interface identifier, the interface case identifier, the request parameter case and the assertion information to the interface case record.
Optionally, after generating the target scenario test case based on the target interface test cases and the second call order relationship, the method further includes:
inputting the target test scene case into the system to be tested, and acquiring a target interface test result corresponding to each target interface test case in the target test scene case;
aiming at any target interface test case, the following steps are executed:
determining target assertion information corresponding to the target interface test case from the interface case records;
and if the target assertion information is consistent with the target interface test result corresponding to the target interface test case, the test is successful.
Optionally, if the target assertion information is consistent with the target interface test result corresponding to the target interface test case, the test is successful, including:
and if the value of the target assertion information is consistent with the value of the target interface test result, the structural form of the target assertion information is consistent with the structural form of the target interface test result, and the data type of the target assertion information is consistent with the data type of the target interface test result, the test is successful.
In one aspect, an embodiment of the present application provides a scenario test case generation apparatus, where the apparatus includes:
the determining module is used for determining scene case identification matched with the testing service requirement based on the testing service requirement;
the acquisition module is used for determining each interface case identifier corresponding to the scene case identifier matched with the test service requirement and a first calling sequence relation of each interface case identifier from the scene case record;
the modification module is used for modifying the interface case identifications and the first calling sequence relation based on the test service requirement to obtain target interface case identifications and second calling sequence relations of the target interface case identifications;
the system comprises a use case generation module, a target request parameter use case generation module and a target interface request parameter use case generation module, wherein the use case generation module is used for determining a target interface identifier and a target request parameter use case corresponding to the target interface use case identifier from an interface use case record aiming at any target interface use case identifier; determining a target request identifier corresponding to the target interface identifier from an interface record, and generating a target interface test case based on the target request identifier and the target request parameter case;
the case generating module is further configured to generate a target scene test case based on the target interface test cases and the second call order relationship.
Optionally, the system further comprises a record generating module, wherein the record generating module is specifically configured to:
capturing original test data from a system to be tested before determining a scene case identifier matched with the test service requirement based on the test service requirement, and analyzing the original test data to obtain a scene test case, wherein the scene test case comprises at least one interface test case;
aiming at any interface test case, the following steps are executed:
determining an interface identifier and a request identifier corresponding to the interface test case, and adding the interface identifier and the request identifier to the interface record;
determining an interface use case identifier and a request parameter use case corresponding to the interface test use case, and adding the interface identifier, the interface use case identifier and the request parameter use case to the interface use case record;
determining a scene case identifier corresponding to the scene test case, and adding the scene case identifier, each interface case identifier corresponding to the scene case identifier and a first calling sequence relation of each interface case identifier to the scene case record.
Optionally, the raw test data includes a plurality of raw test cases;
the record generation module is specifically configured to:
aiming at any original test case in the original test data, determining at least one target test case from the original test data based on the matching relation between the request identifier in the original test case and the global configuration rule;
and respectively taking the at least one target test case as interface test cases, and assembling the at least one target test case into the scene test case according to the sequence.
Optionally, the global configuration rule includes a blacklist rule and a whitelist;
the record generation module is specifically configured to:
if any request identification in the original test case is matched with the blacklist rule, deleting the original test case; taking other original test cases in the original test data as target test cases; and if any request identifier in the original test case is matched with the white list rule and is not matched with the black list rule, taking the original test case as a target test case.
Optionally, the request identifier corresponding to each interface identifier in the interface record includes: the system comprises a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier.
Optionally, the system further comprises a file generation module, where the file generation module is specifically configured to:
after determining the interface identifier and the request identifier corresponding to the interface test case, the method further includes:
generating a directory file based on the request path identification in the interface test case;
generating a request file based on a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier in the interface test case, and adding the request file into the directory file;
and adding the interface identifier and the directory file name corresponding to the directory file to a directory file retrieval record.
Optionally, the record generating module is specifically configured to:
and acquiring an interface test result corresponding to the interface test case from a system to be tested, taking the interface test result as assertion information, and adding the interface identifier, the interface case identifier, the request parameter case and the assertion information to the interface case record.
Optionally, the system further comprises a test module, wherein the test module is specifically configured to:
after generating a target scene test case based on each target interface test case and the second calling sequence relation, inputting the target test scene case into the system to be tested to obtain a target interface test result corresponding to each target interface test case in the target test scene case;
aiming at any target interface test case, the following steps are executed:
determining target assertion information corresponding to the target interface test case from the interface case records;
and if the target assertion information is consistent with the target interface test result corresponding to the target interface test case, the test is successful.
Optionally, the test module is specifically configured to:
and if the value of the target assertion information is consistent with the value of the target interface test result, the structural form of the target assertion information is consistent with the structural form of the target interface test result, and the data type of the target assertion information is consistent with the data type of the target interface test result, the test is successful.
In one aspect, an embodiment of the present application provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the scenario test case generation method when executing the program.
In one aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program executable by a computer device, and when the program runs on the computer device, the computer device is caused to execute the steps of the above scenario test case generation method.
In the embodiment of the application, based on the test service requirement, the scene case identification associated with the test service requirement is determined, and the interface case identifications corresponding to the scene case identification matched with the test service requirement and the first calling sequence relation of the interface case identifications are determined from the scene case record. And modifying the interface case identifications and the first calling sequence relation based on the test service requirement to obtain target interface case identifications and second calling sequence relation of the target interface case identifications. Then aiming at any target interface use case identification, determining a target interface identification and a target request parameter use case corresponding to the target interface use case identification from the interface use case record; and determining a target request identifier corresponding to the target interface identifier from the interface record, and generating a target interface test case based on the target request identifier and the target request parameter case. And finally, generating a target scene test case based on the target interface test cases and the second calling sequence relation. According to the method and the device, the interface case identifications corresponding to the scene case identifications and the first calling sequence relation of the interface case identifications can be directly adjusted according to the test service requirements, the target scene test case is obtained, the scene test case does not need to be rewritten according to the test service requirements, the test cost and the maintenance cost are reduced, and the software test efficiency is improved.
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 inventive exercise.
Fig. 1 is a schematic diagram of a system architecture according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a method for generating a scenario test case according to an embodiment of the present application;
fig. 3 is a schematic flowchart of a method for generating a scene use case record according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a scenario test case generation apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more clearly apparent, the present invention 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 invention and do not limit the invention.
Referring to fig. 1, a scene test case generation system architecture diagram applicable to the embodiment of the present application is shown, where the scene test case generation system architecture diagram at least includes a terminal device 101 and a scene test case generation system 102.
The terminal device 101 is installed with a target application for generating a scenario test case, where the application may be a client installed in advance, a web application, or an applet embedded in another application. The terminal device 101 may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, and the like.
The scenario test case generation system 102 provides a service for the target application as a background server of the target application. The scenario test case generation system 102 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like.
The terminal device 101 and the scenario test case generating system 102 may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein.
The terminal device 101 responds to the operation of generating the scenario test case by the user, and sends a scenario test case generation instruction to the scenario test case generation system 102. The scene test case generation system 102 receives a scene test case generation instruction, and determines a scene case identifier associated with a test service requirement based on the test service requirement; and then determining the interface use case identifications corresponding to the scene use case identifications and the first calling sequence relation of the interface use case identifications from the scene use case records. And modifying the interface case identifications and the first calling sequence relation based on the test service requirement to obtain target interface case identifications and second calling sequence relation of the target interface case identifications. Then, aiming at any target interface use case identification, determining a target interface identification and a target request parameter use case corresponding to the target interface use case identification from the interface use case record; and determining a target request identifier corresponding to the target interface identifier from the interface record, and generating a target interface test case based on the target request identifier and the target request parameter case. And finally, generating a target scene test case based on the target interface test cases and the second calling sequence relation.
Based on the system architecture diagram shown in fig. 1, an embodiment of the present application provides a process of a scenario test case generation method, as shown in fig. 2, where the process of the method is executed by the scenario test case generation system 102 shown in fig. 1, and includes the following steps:
step S201, based on the test service requirement, determining a scene case identifier matched with the test service requirement.
Specifically, each test service requirement corresponds to a respective service scenario. The test service requirement may be to test a corresponding module in an inquiry scenario, to test a corresponding module in a menu placement scenario, to test a corresponding module in a login scenario, and the like, which is not limited herein.
Different scene test cases exist for corresponding modules in the same scene. For example, there are different test cases for the corresponding modules in the login scenario.
According to a service scene corresponding to the test service requirement, determining a plurality of scene test cases related to the service scene, selecting a scene test case which is most matched with the test service requirement from the plurality of scene test cases, and determining a scene case identifier corresponding to the most matched scene test case.
Step S202, determining each interface case identification corresponding to the scene case identification matched with the test service requirement and a first calling sequence relation of each interface case identification from the scene case record.
Specifically, the scenario test case is composed of a plurality of interface test cases in sequence. For any scene test case, the scene case record includes a scene case identifier corresponding to the scene test case, interface case identifiers corresponding to a plurality of interface test cases corresponding to the scene test case, and a first call sequence relation of the interface case identifiers.
For example, as shown in table 1, two records are included in the scenario use case record. In the first record, the scene case identification is CJ01, the interface case identifications are JK02 and JK08 respectively, and the first calling sequence relation is JK02-JK08; in the second record, the scene case is marked as CJ02, the plurality of interface case marks are JK01, JK03 and JK09 respectively, and the first calling sequence relation is JK01-JK03-JK09.
Table 1.
Scene use case identification | First Call order relationship |
CJ01 | JK02-JK08 |
CJ02 | JK01-JK03-JK09 |
Step S203, modifying each interface case identifier and the first calling sequence relation based on the test service requirement, and obtaining each target interface case identifier and the second calling sequence relation of each target interface case identifier.
Specifically, based on the requirement of the test service, part of the interface case identifiers may be deleted, and part of the interface case identifiers may also be added.
For example, if the scene case identifier matched with the test service requirement is CJ02 in table 1, modifying the plurality of interface case identifiers JK01, JK03, and JK09 corresponding to the scene case identifier CJ02 and the first calling sequence relationship JK01-JK03-JK09 according to the test service requirement to obtain target interface case identifiers JK01, JK04, and JK09 corresponding to the scene case identifier CJ02, wherein the first calling sequence relationship is JK01-JK04-JK09.
Step S204, aiming at any target interface use case identification, determining a target interface identification and a target request parameter use case corresponding to the target interface use case identification from the interface use case record; and determining a target request identifier corresponding to the target interface identifier from the interface record, and generating a target interface test case based on the target request identifier and the target request parameter case.
Specifically, the interface use case record includes three attribute information: the interface comprises an interface use case identifier, an interface identifier and a request parameter use case. The request parameter cases corresponding to different interface case identifiers are different, and the different interface case identifiers may correspond to the same interface identifier.
For example, as shown in table 2, the interface use case records include 3 login interface use cases, and it can be seen that, since the above 3 records are all login interface use cases, the corresponding interface identifiers are the same and are all a. The request parameter use cases corresponding to each login interface use case are different, and when the interface use case is identified as JK10, the request parameter use cases are name: zhangsan and code:123; when the interface use case identifier is JK11, the request parameter use case is name zhangsan and code 111; when the interface use case is marked as JK12, the request parameter use cases are name: lisi and code:233.
Table 2.
Interface use case identification | Interface identification | Request parameter use case |
JK10 | A | name:zhangsan,code:123 |
JK11 | A | name:zhangsan,code:111 |
JK12 | A | name:lisi,code:233 |
The interface record comprises interface identifiers and request identifiers, and the request identifier corresponding to each interface identifier in the interface record comprises: the system comprises a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier. Wherein, the request identifications corresponding to different interface identifications are not completely the same.
Specifically, the request mode identifier includes any one of the following: post, get, put, delete, and so on.
The request protocol identification comprises any one of the following: https, websocket, tcp, etc.
The request type identification comprises any one of the following: html, css, js, xhr, images, and the like.
For example, the interface identifier corresponding to the login interface is a, and the interface identifier corresponding to the query interface is B. The interface record includes 2 records as shown in table 3. In the first record, the interface identifier is a, the request mode identifier is post, the request protocol identifier is https, the request type identifier is html, the request address identifier is passport. In the second record, the interface is identified as B, the request mode is identified as get, the request protocol is identified as https, the request type is identified as html, the request address is identified as weather.
Table 3.
Specifically, for any target interface use case identifier, a target interface use case identifier is determined from a plurality of interface use case identifiers in an interface use case record, an interface identifier corresponding to the target interface use case identifier is determined from the interface use case record to serve as the target interface identifier, and a request parameter use case corresponding to the target interface use case identifier serves as a target request parameter use case. Then, determining a target interface identifier from the plurality of interface identifiers in the interface record, and determining a request identifier corresponding to the target interface identifier from the interface record as a target request identifier, wherein the request identifier includes: the system comprises a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier. And finally, generating a target interface test case based on the target request identifier and the target request parameter case.
Step S205, generating a target scene test case based on each target interface test case and the second calling sequence relation.
Specifically, the target interface test cases are assembled according to the second calling sequence relation, and a target scene test case is generated.
In the embodiment of the application, based on the test service requirement, the scene case identification associated with the test service requirement is determined, and the interface case identifications corresponding to the scene case identification matched with the test service requirement and the first calling sequence relation of the interface case identifications are determined from the scene case record. And modifying the interface case identifications and the first calling sequence relation based on the test service requirement to obtain target interface case identifications and second calling sequence relations of the target interface case identifications. Then aiming at any target interface use case identification, determining a target interface identification and a target request parameter use case corresponding to the target interface use case identification from the interface use case record; and determining a target request identifier corresponding to the target interface identifier from the interface record, and generating a target interface test case based on the target request identifier and the target request parameter case. And finally, generating a target scene test case based on the target interface test cases and the second calling sequence relation. According to the method and the device, the interface case identifications corresponding to the scene case identifications and the first calling sequence relation of the interface case identifications can be directly adjusted according to the test service requirements, the target scene test case is obtained, the scene test case does not need to be rewritten according to the test service requirements, the test cost and the maintenance cost are reduced, and the software test efficiency is improved.
Optionally, before determining the scenario use case identifier matching the test service requirement based on the test service requirement in step S201, the following steps shown in fig. 3 are performed:
step S301, capturing original test data from a system to be tested, and analyzing the original test data to obtain a scene test case.
The scene test case comprises at least one interface test case.
Step S302, aiming at any interface test case, determining an interface identifier and a request identifier corresponding to the interface test case, and adding the interface identifier and the request identifier to an interface record.
Specifically, a request identifier is determined according to the interface test case, and an interface identifier is determined according to a request mode identifier and a request path identifier in the request identifier.
After obtaining an interface identifier corresponding to the interface test case, judging whether the interface identifier exists in an interface record, if not, adding the interface identifier and a corresponding request identifier into the interface record; if yes, no processing is carried out.
For example, an interface test case corresponding to the query scenario is get https:// web.page.baidu.com/web/pcquery = Hubei Wuhan weather & srcid =4982, the request mode identifier corresponding to the interface test case is get, the request protocol identifier is https, the request type identifier is html, the request address identifier is web.page.baidu.com, the request path identifier is/web/pc, and the request parameter identifier is query and srcid.
According to the request mode identifier get and the request path identifier/web/pc, determining that the interface identifier corresponding to the interface test case is B, and adding the interface identifier B and the corresponding request identifier to the interface record, as shown in Table 4.
Table 4.
Optionally, after determining an interface identifier and a request identifier corresponding to the interface test case, generating a directory file based on the request path identifier in the interface test case; and generating a request file based on a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier in the interface test case, and adding the request file to the directory file. And finally, adding the interface identifier and the directory file name corresponding to the directory file retrieval record.
The request file in the directory file and the record in the interface record are in a mutual index relationship, that is, when the request file in the directory file is modified, the corresponding record in the interface record also changes. When the record in the interface record is modified, the request file in the corresponding target file is also changed, and the uniqueness of the data is ensured.
In the embodiment of the application, the request file is added to the directory file and displayed in a file form, so that the request file can be displayed visually. The name of the directory file corresponding to the interface identifier can be directly determined according to the directory file retrieval record, so that the search is facilitated.
Step S303, determining an interface case identifier and a request parameter case corresponding to the interface test case, and adding the interface identifier, the interface case identifier and the request parameter case to the interface case record.
Specifically, the interface case identifier corresponding to each interface test case has uniqueness.
Optionally, an interface test result corresponding to the interface test case is obtained from the system to be tested, and the interface test result is used as assertion information. And then adding the interface identifier, the interface use case identifier, the request parameter use case and the assertion information to the interface use case record.
For example, one interface test case corresponding to the query scenario is get https:// weather, page, basic, com/weather, pcquery = northof a lake wuhan weather & srcid =4982, and the request parameter case corresponding to the interface test case is query = northof a lake wuhan weather & srcid =4982. And setting the interface case identifier generated by the interface test case as JK13, and setting the interface identifier corresponding to the interface test case as B.
The interface test result corresponding to the interface test case is obtained from the system to be tested, the interface test result is set to be "clear", and the interface case identifier JK13, the interface identifier B, the request parameter case and the interface test result "clear" are added to the interface case record, as shown in table 5.
Table 5.
Optionally, the request parameter case may be modified, for example, part of the request parameter case is deleted, and part of the request parameter case is modified, so as to increase the diversity of the interface test case and improve the stability of the system to be tested.
Step S304, determining scene case identifications corresponding to the scene test cases, and adding the scene case identifications, the interface case identifications corresponding to the scene case identifications and the first calling sequence relation of the interface case identifications to the scene case record.
In the embodiment of the application, the scene test case is split into the plurality of interface test cases, and based on the interface test cases, the scene test cases and the relationship between the interface test cases and the scene test cases, interface records, interface case records and scene case records are constructed, so that the target scene test case can be conveniently generated based on the interface records, the interface case records and the scene case records.
Optionally, in step S301, analyzing the original test data to obtain a scenario test case, where the method includes the following steps:
the original test data comprises a plurality of original test cases, and at least one target test case is determined from the original test data based on the matching relation between the request identification in the original test case and the global configuration rule aiming at any original test case in the original test data. And then, respectively taking the at least one target test case as an interface test case, and assembling the at least one target test case into a scene test case according to the sequence.
For example, 5 original test cases are included in the original test data, namely YS01-YS02-YS03-YS04-YS05, the YS01, YS03 and YS05 are set as target test cases, the YS01, YS03 and YS05 are used as interface test cases, and the YS01, YS03 and YS05 are assembled in sequence to obtain a scene test case of YS01-YS03-YS05.
Specifically, the global configuration rules include blacklist rules and whitelist rules.
For any original test case in the original test data, if any request identifier in the original test case is matched with the blacklist rule, deleting the original test case; and taking the rest original test cases in the original test data as target test cases. And if any request identifier in the original test case is matched with the white list rule and is not matched with the black list rule, taking the original test case as a target test case.
The blacklist rule may include one configuration rule or may include a plurality of configuration rules. For example, blacklist rules: the request mode is identified as delete and the request type is identified as html. The white list rules are similar and are not described herein.
Optionally, the global configuration rule further comprises a custom rule. The custom rule is a historical deletion record determined according to the manual deletion of the original test case.
And judging whether the original test case is a target test case or not according to the historical deletion record aiming at any original test case in the original test data. And if the historical deletion record corresponding to the original test case is greater than or equal to a preset deletion threshold value, deleting the original test case and not taking the original test case as a target test case. And if the historical deletion record corresponding to the original test case is smaller than a preset deletion threshold, reserving the original test case as a target test case.
In the embodiment of the application, based on the global configuration rule, a plurality of original test cases are filtered to obtain the target test case, the test cases corresponding to the interfaces needing to be subjected to subsequent tests are reserved, and the redundancy of the test cases is reduced.
Optionally, in step S205, after generating the target scenario test case based on each target interface test case and the second calling order relationship, the following steps are performed:
and inputting the target test scene case into a system to be tested, and acquiring a target interface test result corresponding to each target interface test case in the target test scene case.
Aiming at any target interface test case, the following steps are executed: determining target assertion information corresponding to a target interface test case from the interface case records; if the target assertion information is consistent with the target interface test result corresponding to the target interface test case, the test is successful; otherwise, the test fails. If the test is successful, the system to be tested has no error, and if the test is failed, the system to be tested has an error, and the system to be tested needs to be modified subsequently.
Specifically, if the value of the target assertion information is consistent with the value of the target interface test result, the structural form of the target assertion information is consistent with the structural form of the target interface test result, and the data type of the target assertion information is consistent with the data type of the target interface test result, the test is successful.
For example, the structural form includes a key-value pair form, etc., and the data type includes a character string type, an integer type, etc.
In the embodiment of the application, whether the test is successful is judged based on the consistency of the target interface test result corresponding to the target test scenario case and the target assertion information, manual verification is not needed, and the software test efficiency is improved.
Based on the same technical concept, an embodiment of the present application provides a scenario test case generation apparatus, as shown in fig. 4, the scenario test case generation apparatus 400 includes:
a determining module 401, configured to determine, based on a test service requirement, a scene case identifier matching the test service requirement;
an obtaining module 402, configured to determine, from a scene case record, each interface case identifier corresponding to a scene case identifier that matches the test service requirement and a first call order relationship of each interface case identifier;
a modification module 403, configured to modify the interface case identifiers and the first call order relationship based on the test service requirement, to obtain target interface case identifiers and second call order relationships of the target interface case identifiers;
a use case generation module 404, configured to determine, from an interface use case record, a target interface identifier and a target request parameter use case corresponding to any target interface use case identifier; determining a target request identifier corresponding to the target interface identifier from an interface record, and generating a target interface test case based on the target request identifier and the target request parameter case;
the use case generating module 404 is further configured to generate a target scene test case based on the target interface test cases and the second call order relationship.
Optionally, the system further includes a record generating module 405, where the record generating module 405 is specifically configured to:
capturing original test data from a system to be tested before determining a scene case identifier matched with the test service requirement based on the test service requirement, and analyzing the original test data to obtain a scene test case, wherein the scene test case comprises at least one interface test case;
aiming at any interface test case, the following steps are executed:
determining an interface identifier and a request identifier corresponding to the interface test case, and adding the interface identifier and the request identifier to the interface record;
determining an interface use case identifier and a request parameter use case corresponding to the interface test use case, and adding the interface identifier, the interface use case identifier and the request parameter use case to the interface use case record;
determining a scene case identifier corresponding to the scene test case, and adding the scene case identifier, each interface case identifier corresponding to the scene case identifier and a first calling sequence relation of each interface case identifier to the scene case record.
Optionally, the raw test data includes a plurality of raw test cases;
the record generating module 405 is specifically configured to:
aiming at any original test case in the original test data, determining at least one target test case from the original test data based on the matching relation between the request identifier in the original test case and the global configuration rule;
and respectively taking the at least one target test case as interface test cases, and assembling the at least one target test case into the scene test case according to the sequence.
Optionally, the global configuration rule includes a blacklist rule and a whitelist rule;
the record generating module 405 is specifically configured to:
if any request identification in the original test case is matched with the blacklist rule, deleting the original test case; taking other original test cases in the original test data as target test cases; and if any request identifier in the original test case is matched with the white list rule and is not matched with the black list rule, taking the original test case as a target test case.
Optionally, the request identifier corresponding to each interface identifier in the interface record includes: the system comprises a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier.
Optionally, the system further includes a file generating module 406, where the file generating module 406 is specifically configured to:
after determining the interface identifier and the request identifier corresponding to the interface test case, the method further includes:
generating a directory file based on the request path identification in the interface test case;
generating a request file based on a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier in the interface test case, and adding the request file to the directory file;
and adding the interface identifier and the directory file name corresponding to the directory file to a directory file retrieval record.
Optionally, the record generating module 405 is specifically configured to:
and acquiring an interface test result corresponding to the interface test case from a system to be tested, taking the interface test result as assertion information, and adding the interface identifier, the interface case identifier, the request parameter case and the assertion information to the interface case record.
Optionally, the system further includes a testing module 407, where the testing module 407 is specifically configured to:
after generating a target scene test case based on each target interface test case and the second calling sequence relation, inputting the target test scene case into the system to be tested to obtain a target interface test result corresponding to each target interface test case in the target test scene case;
aiming at any target interface test case, the following steps are executed:
determining target assertion information corresponding to the target interface test case from the interface case records;
and if the target assertion information is consistent with the target interface test result corresponding to the target interface test case, the test is successful.
Optionally, the test module 407 is specifically configured to:
and if the value of the target assertion information is consistent with the value of the target interface test result, the structural form of the target assertion information is consistent with the structural form of the target interface test result, and the data type of the target assertion information is consistent with the data type of the target interface test result, the test is successful.
Based on the same technical concept, the embodiment of the present application provides a computer device, which may be a terminal or a server, as shown in fig. 5, including at least one processor 501 and a memory 502 connected to the at least one processor, where a specific connection medium between the processor 501 and the memory 502 is not limited in the embodiment of the present application, and the processor 501 and the memory 502 are connected through a bus in fig. 5 as an example. The bus may be divided into an address bus, a data bus, a control bus, etc.
In the embodiment of the present application, the memory 502 stores instructions that can be executed by the at least one processor 501, and the at least one processor 501 can execute the steps included in the scenario test case generation method by executing the instructions stored in the memory 502.
The processor 501 is a control center of the computer device, and may connect various parts of the computer device by using various interfaces and lines, and perform the scenario test case generation by executing or executing the instructions stored in the memory 502 and calling the data stored in the memory 502. Optionally, the processor 501 may include one or more processing units, and the processor 501 may integrate an application processor and a modem processor, wherein the application processor mainly handles an operating system, a user interface, an application program, and the like, and the modem processor mainly handles wireless communication. It will be appreciated that the modem processor described above may not be integrated into the processor 501. In some embodiments, processor 501 and memory 502 may be implemented on the same chip, or in some embodiments, they may be implemented separately on separate chips.
The processor 501 may be a general-purpose processor, such as a Central Processing Unit (CPU), a digital signal processor, an Application Specific Integrated Circuit (ASIC), a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or the like, and may implement or perform the methods, steps, and logic blocks disclosed in the embodiments of the present Application. The general purpose processor may be a microprocessor or any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or may be implemented by a combination of hardware and software modules in a processor.
Based on the same inventive concept, embodiments of the present application provide a computer-readable storage medium, which stores a computer program executable by a computer device, and when the program runs on the computer device, the computer device is caused to execute the steps of the above-mentioned scenario test case generation method.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.
Claims (12)
1. A method for generating a scenario test case is characterized by comprising the following steps:
determining a scene case identifier matched with the test service requirement based on the test service requirement;
determining each interface case identifier corresponding to the scene case identifier matched with the test service requirement and a first calling sequence relation of each interface case identifier from the scene case record;
modifying the interface case identifications and the first calling sequence relation based on the test service requirement to obtain target interface case identifications and second calling sequence relations of the target interface case identifications;
aiming at any target interface use case identification, determining a target interface identification and a target request parameter use case corresponding to the target interface use case identification from an interface use case record; determining a target request identifier corresponding to the target interface identifier from an interface record, and generating a target interface test case based on the target request identifier and the target request parameter case;
and generating a target scene test case based on the target interface test cases and the second calling sequence relation.
2. The method of claim 1, wherein before determining the scenario use case identifier matching the test service requirement based on the test service requirement, further comprising:
capturing original test data from a system to be tested, and analyzing the original test data to obtain a scene test case, wherein the scene test case comprises at least one interface test case;
aiming at any interface test case, the following steps are executed:
determining an interface identifier and a request identifier corresponding to the interface test case, and adding the interface identifier and the request identifier to the interface record;
determining an interface use case identifier and a request parameter use case corresponding to the interface test use case, and adding the interface identifier, the interface use case identifier and the request parameter use case to the interface use case record;
determining a scene case identifier corresponding to the scene test case, and adding the scene case identifier, each interface case identifier corresponding to the scene case identifier and a first calling sequence relation of each interface case identifier to the scene case record.
3. The method of claim 2, wherein the raw test data comprises a plurality of raw test cases;
the analyzing the original test data to obtain a scenario test case includes:
aiming at any original test case in the original test data, determining at least one target test case from the original test data based on the matching relation between the request identifier in the original test case and the global configuration rule;
and respectively taking the at least one target test case as interface test cases, and assembling the at least one target test case into the scene test case according to the sequence.
4. The method of claim 3, wherein the global configuration rules include blacklist rules and whitelist rules;
the determining at least one target test case from the original test data based on the matching relationship between the request identifier in the original test case and the global configuration rule includes:
if any request identification in the original test case is matched with a blacklist rule, deleting the original test case; taking other original test cases in the original test data as target test cases;
and if any request identifier in the original test case is matched with the white list rule and is not matched with the black list rule, taking the original test case as a target test case.
5. The method of any of claims 1-4, wherein the request identifier corresponding to each interface identifier in the interface record comprises: the system comprises a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier.
6. The method of claim 5, wherein after determining the interface identifier and the request identifier corresponding to the interface test case, the method further comprises:
generating a directory file based on the request path identification in the interface test case;
generating a request file based on a request mode identifier, a request protocol identifier, a request type identifier, a request address identifier, a request path identifier and a request parameter identifier in the interface test case, and adding the request file to the directory file;
and adding the interface identifier and the directory file name corresponding to the directory file to a directory file retrieval record.
7. The method of claim 2, wherein said adding the interface identification, the interface use case identification, and the request parameter use case to the interface use case record comprises:
and acquiring an interface test result corresponding to the interface test case from a system to be tested, taking the interface test result as assertion information, and adding the interface identifier, the interface case identifier, the request parameter case and the assertion information to the interface case record.
8. The method of claim 7, wherein after generating the target scenario test case based on the target interface test cases and the second calling order relationship, the method further comprises:
inputting the target test scene case into the system to be tested, and acquiring a target interface test result corresponding to each target interface test case in the target test scene case;
aiming at any target interface test case, the following steps are executed:
determining target assertion information corresponding to the target interface test case from the interface case records;
and if the target assertion information is consistent with the target interface test result corresponding to the target interface test case, the test is successful.
9. The method as claimed in claim 8, wherein if the target assertion information is consistent with the target interface test result corresponding to the target interface test case, the testing is successful, including:
if the value of the target assertion information is consistent with the value of the target interface test result, the structural form of the target assertion information is consistent with the structural form of the target interface test result, and the data type of the target assertion information is consistent with the data type of the target interface test result, the test is successful.
10. A scenario test case generation apparatus includes:
the determining module is used for determining scene case identification matched with the testing service requirement based on the testing service requirement;
the acquisition module is used for determining each interface case identifier corresponding to the scene case identifier matched with the test service requirement and a first calling sequence relation of each interface case identifier from the scene case record;
the modification module is used for modifying the interface case identifications and the first calling sequence relation based on the test service requirement to obtain target interface case identifications and second calling sequence relations of the target interface case identifications;
the system comprises a use case generation module, a target request parameter use case generation module and a target interface request parameter use case generation module, wherein the use case generation module is used for determining a target interface identifier and a target request parameter use case which correspond to the target interface use case identifier from an interface use case record aiming at any target interface use case identifier; determining a target request identifier corresponding to the target interface identifier from an interface record, and generating a target interface test case based on the target request identifier and the target request parameter case;
the case generating module is further configured to generate a target scene test case based on the target interface test cases and the second call order relationship.
11. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the steps of the method of any one of claims 1 to 9 are performed when the program is executed by the processor.
12. A computer-readable storage medium, in which a computer program is stored which is executable by a computer device, and which, when run on the computer device, causes the computer device to carry out the steps of the method according to any one of claims 1 to 9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210994411.1A CN115391188A (en) | 2022-08-18 | 2022-08-18 | Scene test case generation method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210994411.1A CN115391188A (en) | 2022-08-18 | 2022-08-18 | Scene test case generation method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115391188A true CN115391188A (en) | 2022-11-25 |
Family
ID=84120772
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210994411.1A Pending CN115391188A (en) | 2022-08-18 | 2022-08-18 | Scene test case generation method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115391188A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115934576A (en) * | 2023-03-10 | 2023-04-07 | 华锐分布式(北京)技术有限公司 | Test case generation method, device, equipment and medium in transaction scene |
WO2024178987A1 (en) * | 2023-02-28 | 2024-09-06 | 华为云计算技术有限公司 | Software testing method and device |
-
2022
- 2022-08-18 CN CN202210994411.1A patent/CN115391188A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024178987A1 (en) * | 2023-02-28 | 2024-09-06 | 华为云计算技术有限公司 | Software testing method and device |
CN115934576A (en) * | 2023-03-10 | 2023-04-07 | 华锐分布式(北京)技术有限公司 | Test case generation method, device, equipment and medium in transaction scene |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20190327094A1 (en) | Information authentication method and system | |
CN110209652B (en) | Data table migration method, device, computer equipment and storage medium | |
US9552469B2 (en) | Identity authentication by using human biological characteristic | |
JP2021515427A (en) | Blockchain-based data validation methods and equipment, as well as electronic devices | |
CN115391188A (en) | Scene test case generation method, device, equipment and storage medium | |
CN109800258B (en) | Data file deployment method, device, computer equipment and storage medium | |
CN108897728B (en) | Short message splicing processing method and device, computer equipment and storage medium | |
CN105678127A (en) | Verification method and device for identity information | |
CN111435367B (en) | Knowledge graph construction method, system, equipment and storage medium | |
CN113010476B (en) | Metadata searching method, device, equipment and computer readable storage medium | |
CN109446801A (en) | Detect method, apparatus, server and the storage medium of simulator access | |
CN104408118A (en) | Database establishing method and device | |
CN112699034A (en) | Virtual login user construction method, device, equipment and storage medium | |
CN113420245B (en) | Page display method and system | |
CN117171108B (en) | Virtual model mapping method and system | |
CN112395339B (en) | Intersystem data admission verification method, device, computer equipment and storage medium | |
CN114022926A (en) | Face recognition method, device, equipment and storage medium | |
CN117493309A (en) | Standard model generation method, device, equipment and storage medium | |
CN117271571A (en) | Database uniqueness constraint processing method, device, equipment and storage medium | |
CN112231232A (en) | Method, device and equipment for determining test data model and generating test data | |
CN114490673A (en) | Data information processing method and device, electronic equipment and storage medium | |
CN113934637A (en) | Test method, device, equipment and storage medium | |
CN111143644B (en) | Identification method and device of Internet of things equipment | |
CN114826726B (en) | Network asset vulnerability detection method, device, computer equipment and storage medium | |
CN111914065B (en) | Short message content verification method, device, computer system and computer readable 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 |