[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN113407446A - Test case generation method and electronic equipment - Google Patents

Test case generation method and electronic equipment Download PDF

Info

Publication number
CN113407446A
CN113407446A CN202110626466.2A CN202110626466A CN113407446A CN 113407446 A CN113407446 A CN 113407446A CN 202110626466 A CN202110626466 A CN 202110626466A CN 113407446 A CN113407446 A CN 113407446A
Authority
CN
China
Prior art keywords
interface
test
test case
input data
parameter
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.)
Granted
Application number
CN202110626466.2A
Other languages
Chinese (zh)
Other versions
CN113407446B (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.)
Shanghai Glory Smart Technology Development Co ltd
Original Assignee
Honor Device 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 Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202110626466.2A priority Critical patent/CN113407446B/en
Publication of CN113407446A publication Critical patent/CN113407446A/en
Application granted granted Critical
Publication of CN113407446B publication Critical patent/CN113407446B/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
    • 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/3688Test 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 discloses a test case generation method and electronic equipment, relates to the technical field of interface testing, and solves the problems of high labor cost and low testing efficiency of manual design of test cases. The specific scheme is as follows: acquiring a first test case; the first test case is a test case for testing the first interface by using first interface parameters, the first interface parameters are interface parameters used by the software to be tested in a first application scene, and the first test case comprises: a first interface parameter and corresponding input data; acquiring a test value of a first interface parameter and a corresponding expected output result according to an interface description file of a first interface; and generating a test case set of the first interface parameter according to the input data corresponding to the first interface parameter, the test value of the first interface parameter and the corresponding expected output result, wherein the test case set is used for realizing the test of the first interface.

Description

Test case generation method and electronic equipment
Technical Field
The present disclosure relates to the field of interface testing technologies, and in particular, to a method for generating a test case and an electronic device.
Background
The interface test is a test that submits input data to an interface included in the tested software by using a test case, obtains a return result of the interface and analyzes whether the result meets expectations. Interface testing is an important branch of software testing. The key point of the interface test is the design of the test case. The design of the test case comprises the following steps: interface parameters for the interface, input data for the interface parameters, and a design of an expected output result. The key principle of test case design is to use the least test cases to find as many errors as possible in the tested software.
At present, the generation of test cases is mainly completed manually by testers, so that the design labor cost of the test cases is high, and the test efficiency is low. In addition, in the micro-service test process, the interface parameters of the interface to be tested are very many (usually more than 50 +), and if the test case is still manually completed by the tester, the labor cost is further increased, and the test efficiency is reduced.
Disclosure of Invention
The embodiment of the application provides a test case generation method and electronic equipment, and solves the problems of high labor cost and low test efficiency of manual design of test cases.
In order to achieve the above purpose, the embodiment of the present application adopts the following technical solutions:
in a first aspect, an embodiment of the present application provides a method for generating a test case. The method can comprise the following steps: acquiring a first test case; the first test case is a test case for testing a first interface by using first interface parameters, the first interface parameters are interface parameters used by the software to be tested in a first application scene, and the first test case comprises: the first interface parameter and the corresponding input data; obtaining the test value of the first interface parameter and a corresponding expected output result according to the interface description file of the first interface; and generating a test case set of the first interface parameter according to the input data corresponding to the first interface parameter, the test value of the first interface parameter and the corresponding expected output result, wherein the test case set is used for realizing the test of the first interface.
Based on the method of the first aspect, a test case set of interface parameters used by the software under test in the application scene is automatically generated by using a known test case of the software under test in the application scene, and is used for testing the corresponding interface. Compared with the method that the test case is manually completed by a tester, the scheme of the application can automatically generate the test case set of the interface parameters used in the application scene based on the known test case in the application scene, so that the manual cost of manually designing the test case can be reduced. In addition, the scheme of the application only generates the corresponding test case set aiming at the interface parameters used in the application scene, and is used for testing the interfaces corresponding to the interface parameters, so that the data volume of the test cases is reduced, the execution time of the test cases is shortened, the time of the interface test is further shortened, and the test efficiency is improved.
With reference to the first aspect, in a possible implementation manner, the generating a test case set of the first interface parameter according to the input data corresponding to the first interface parameter, the test value of the first interface parameter, and the expected output result may include: for each of the first interface parameters: generating a test case set of the interface parameter according to the test value of the interface parameter and input data corresponding to other interface parameters in the first interface parameter; the test case set of the interface parameters comprises test cases which correspond to the test values of the interface parameters one by one; the input data of the interface parameters of one test case is a test value, and the input data of other interface parameters is the input data corresponding to other interface parameters.
Based on the possible implementation manner, the test case set of the interface parameter can be generated through the test value of the interface parameter in the first interface parameter and the input data corresponding to other interface parameters in the first interface parameter, so that the test case set of the first interface parameter can be generated.
With reference to the first aspect, in another possible implementation manner, the interface description file of the first interface includes: the obtaining a test value of the first interface parameter and a corresponding expected output result according to the interface description file of the first interface may include: analyzing the interface description file and determining the type of the first interface parameter; acquiring a test value of the first interface parameter according to the type of the first interface parameter and all input data of the first interface parameter; and acquiring an expected output result corresponding to the test value of the first interface parameter according to the expected output result of the first interface under different input data of the first interface parameter.
Based on the possible implementation manner, the test value of the first interface parameter and the expected output result corresponding to the test value of the first interface parameter can be obtained, so that the test case set of the first interface parameter can be generated by using the test value of the first interface parameter and the expected output result corresponding to the test value of the first interface parameter.
With reference to the first aspect, in another possible implementation manner, after the obtaining the first test case, the method may further include: and analyzing the first test case to determine the first interface parameters and the corresponding input data.
Based on the possible implementation manner, the first interface parameters and the corresponding input data can be determined by analyzing the first test case, so that the test case set of the first interface parameters can be generated by using the first interface parameters and the corresponding input data conveniently.
With reference to the first aspect, in another possible implementation manner, the test value includes a normal value and an abnormal value, the normal value corresponds to an expected output result being successful, and the abnormal value corresponds to an expected output result being failure.
Based on the possible implementation manner, the test values include a normal value and an abnormal value, an expected output result corresponding to the normal value, and an expected output result corresponding to the abnormal value, so that the test case set of the first interface parameter is generated by using the test values conveniently.
In a second aspect, an embodiment of the present application provides a device for generating a test case, where the device may be applied to an electronic device, and is configured to implement the method in the first aspect. The functions of the device can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the above functions, for example, an acquisition module, a generation module, and the like.
The obtaining module can be used for obtaining a first test case; the first test case is a test case for testing the first interface by using first interface parameters, the first interface parameters are interface parameters used by the software to be tested in a first application scene, and the first test case comprises: a first interface parameter and corresponding input data; and acquiring the test value of the first interface parameter and a corresponding expected output result according to the interface description file of the first interface. The generating module may be configured to generate a test case set of the first interface parameter according to the input data corresponding to the first interface parameter, the test value of the first interface parameter, and the expected output result, so as to implement a test on the first interface.
With reference to the second aspect, in another possible implementation manner, the generating module is specifically configured to, for each interface parameter in the first interface parameters: generating a test case set of the interface parameters according to the test values of the interface parameters and input data corresponding to other interface parameters in the first interface parameters; the test case set of the interface parameters comprises test cases which correspond to the test values of the interface parameters one by one; the input data of the interface parameters of one test case is a test value, and the input data of other interface parameters is the input data corresponding to other interface parameters.
With reference to the second aspect, in another possible implementation manner, the interface description file of the first interface includes: all interface parameters of a first interface, all input data of each interface parameter, and an expected output result of the first interface of each interface parameter under different input data; the acquisition unit is specifically used for analyzing the interface description file and determining the type of the first interface parameter; acquiring a test value of the first interface parameter according to the type of the first interface parameter and all input data of the first interface parameter; and acquiring an expected output result corresponding to the test value of the first interface parameter according to the expected output result of the first interface under different input data of the first interface parameter.
With reference to the second aspect, in another possible implementation manner, the obtaining unit is further configured to analyze the first test case, and determine the first interface parameter and the corresponding input data.
With reference to the second aspect, in another possible implementation manner, the obtaining unit is further configured to analyze the first test case, determine the first interface, and obtain an interface description file of the first interface.
With reference to the second aspect, in another possible implementation manner, the test value includes a normal value and an abnormal value, the expected output result corresponding to the normal value is success, and the expected output result corresponding to the abnormal value is failure.
In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory for storing instructions executable by the processor. The processor is configured to execute the above instructions, so that the electronic device implements the method for generating the test case according to the first aspect or any one of the possible implementation manners of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium having computer program instructions stored thereon. When executed by an electronic device, the computer program instructions cause the electronic device to implement the method for generating a test case according to the first aspect or any one of the possible implementation manners of the first aspect.
In a fifth aspect, an embodiment of the present application provides a computer program product, which includes computer readable code, and when the computer readable code runs in an electronic device, the electronic device is caused to implement the method for generating a test case according to the first aspect or any one of the possible implementation manners of the first aspect.
It should be understood that the beneficial effects of the second to fifth aspects can be seen from the description of the first aspect, and are not repeated herein.
Drawings
Fig. 1 is a schematic structural diagram of a software testing apparatus according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a method for generating a test case according to an embodiment of the present application;
fig. 3 is a schematic flowchart of another test case generation method according to an embodiment of the present application;
fig. 4 is a schematic flowchart of an interface testing method according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a device for generating a test case according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, 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 application.
The terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present application, "a plurality" means two or more unless otherwise specified.
As people demand higher and higher software quality, software testing is becoming more and more important. Interface testing is an important branch of software testing. The interface test is completed by using a test case and is used for testing whether the interface of the tested software meets specific requirements.
At present, test cases are designed mainly by testers, so that the design labor cost of the test cases is high, and the test efficiency is low. And requires a certain experience and a high level of expertise on the part of the tester. In addition, in the testing process of micro services (i.e., a single application program is divided into a group of small services, and the services are coordinated and matched with each other to provide final value for users), the interface parameters involved in the micro services are very many, and the manual design of test cases can further increase the workload of testers and further reduce the testing efficiency. As versions and interfaces evolve, the subsequent maintenance costs will continue to expand as well.
In the related technology, the interface document can be used for automatically generating the test case so as to reduce the labor cost and improve the test efficiency. Specifically, for the software to be tested, interface documents of all interfaces of the software to be tested can be acquired, and a test case of each interface of the software to be tested is generated according to the interface documents of each interface of the software to be tested and all interface parameters included in each interface. And finally, integrating the test cases of each interface to generate the test case of the tested software. In this technique, the generated test cases may be used to test all interfaces included in the software under test. Even if the interface needs to be tested by using part of interface parameters, the test is completed by using the test case of the tested software. This results in a large amount of data of the used test case when the interface needs to be tested by using part of the interface parameters, which results in a long time consumption for interface testing, i.e. the problem of low testing efficiency is not solved well.
The embodiment of the application provides a method for generating a test case, which can automatically generate a test case set of interface parameters used in an application scene based on a known test case in the application scene. And the manual design of testers is not needed, so that the labor cost is saved. And only the interface parameters used in the application scene generate corresponding test case sets for testing the interfaces corresponding to the interface parameters, so that the data volume of the test cases is reduced, the execution time of the test cases is shortened, the time of interface testing is shortened, and the testing efficiency is improved.
The following describes a method for generating a test case provided in the embodiment of the present application.
The method for generating the test case provided by the embodiment of the application can be applied to software test equipment, or called test equipment. In some examples, the software testing device may be an electronic device such as a Personal Computer (PC), a cell phone, or the like. The software testing device may also be a server or the like. The embodiment of the present application does not limit the specific form of the software testing device.
Fig. 1 is a schematic structural diagram of a software testing device according to an embodiment of the present application. As shown in fig. 1, the software testing apparatus 100 may include: at least one processor 101, a communication link 102, a memory 103, and a communication interface 104.
Among other things, processor 101 may perform various functions of software testing device 100 by running or executing software programs stored in memory 103, as well as invoking data stored in memory 103.
In one embodiment, the software testing device 100 may include one processor or may include a plurality of processors. Each of these processors may be a single-Core Processor (CPU) or a multi-Core Processor (CPU). A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
The Memory 103 may be a Read-Only Memory (ROM) or other types of static storage devices that can store static information and instructions, a Random Access Memory (RAM) or other types of dynamic storage devices that can store information and instructions, an Electrically Erasable Programmable Read-Only Memory (EEPROM), a Compact Disc Read-Only Memory (CD-ROM) or other optical Disc storage, optical Disc storage (including Compact Disc, laser Disc, optical Disc, digital versatile Disc, blu-ray Disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The memory 103 may be separate and coupled to the processor 101 via a communication link 102. The memory 103 may also be integrated with the processor 101.
The memory 103 is used for storing software programs for executing the scheme of the application, and is controlled by the processor 101 to execute.
The communication interface 104, which may be any transceiver or the like, is used for communicating with other devices or communication networks.
The communication line 102 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one line is shown in FIG. 1, but it is not intended that there be only one bus or one type of bus.
The device architecture shown in FIG. 1 does not constitute a limitation of the software testing device 100, and the software testing device 100 may include more or fewer components than shown, or some components may be combined, or a different arrangement of components.
Fig. 2 is a flowchart illustrating a method for generating a test case according to an embodiment of the present application. As shown in fig. 2, the method for generating a test case may include:
s201, software testing equipment obtains a scene case, wherein the scene case is a testing case for testing a corresponding interface by adopting interface parameters used in an application scene A.
Before software (or called an application) comes online, it is often necessary to test it to check whether it meets specified requirements or to figure out differences between expected and actual results. An important step in software testing is to test an Application Programming Interface (API), such as an interface for short, included in software. The interface testing is mainly completed by using the interface parameters included in the interface. Wherein a piece of software may comprise a plurality of interfaces, and an interface may comprise one or more interface parameters.
In addition, a plurality of application scenarios may be involved in the actual running process of the software, and the interface parameters of the software used in different application scenarios may be the same or different. The interface parameters used in an application scenario are typically part of the interface parameters of the software. For example, the interface parameters may be part of all interfaces included in the software, and for example, the interface parameters may be all or part of some interfaces included in the software. For example, a software run may involve application scenario 1 and application scenario 2. In the application scenario 1, one or more interface parameters (e.g., referred to as interface parameter 1) need to be used, and the corresponding application function can be implemented by using the one or more interface parameters 1 to call the corresponding interface. In the application scenario 2, one or more interface parameters (e.g., referred to as interface parameter 2) need to be used, and another application function can be implemented by using the one or more interface parameters 2 to call the corresponding interface.
For example, for information flow applications (such as news applications), the application scenarios that may be involved in the actual running process include information recommendation scenarios. In the information recommendation scenario, the interface parameters to be used include: user identifier (uid), age (age), phone Type (phone Type), and favorite color (color). With the interface parameters: and calling the corresponding interface by the aid of age, color and phone Type, so that different information such as personalized news and personalized videos can be recommended according to information such as user account, age, mobile phone Type and favorite color, and a personalized recommendation function is realized. Such as interface parameters: the uid, age, color, and phone Type all belong to an interface between the information flow application and a background server of the information flow application (for convenience of description, the interface is hereinafter referred to as interface 1), that is, interface parameters are utilized: and the uid, age, color and phone Type call the interface 1, so that the personalized recommendation function of the information flow application can be realized. Of course, in the actual running process of the information flow application, other scenarios may also be involved, and in these scenarios, the information flow application may implement the call to the corresponding interface by using other interface parameters to implement the corresponding function.
Therefore, in the embodiment of the present application, for software (for example, referred to as tested software) that needs to be subjected to an interface test, a corresponding test case set may be generated for different application scenarios of the software, so as to implement a test on an interface corresponding to an interface parameter used in an application scenario. For example, in the above example, for the information flow application, a corresponding test case set may be generated for an information recommendation scenario, so as to implement testing of an interface (e.g., interface 1) corresponding to interface parameters (e.g., uid, age, color, and phone Type) used in the information recommendation scenario.
The scenario case in S201 may be a first test case in the embodiment of the present application, and is a test case for testing a corresponding interface (e.g., a first interface) by using interface parameters used by the software under test in an application scenario, for example, application scenario a. The scenario use case may include all interface parameters used by the software under test in the application scenario a, and input data corresponding to each interface parameter. The scenario use case may also include expected output results for the interface corresponding to the interface parameters under corresponding input data. The expected output result includes success or failure. It should be noted that the application scenario a may be a first application scenario in this embodiment, and the interface parameter used in the application scenario a may be a first interface parameter in this embodiment.
For example, in the above example, for the information flow application, the interface parameters used by the information recommendation scenario may include: uid, age, color and phone Type. Accordingly, the scenario use case may include interface parameters, such as: uid, age, color, and phone Type, and input data corresponding to each interface parameter, such as uid ═ x001, age ═ 25, color ═ blue, and phone Type ═ v 50. The scenario use case may further include an expected output result of the interface parameter corresponding to the interface (such as interface 1 described above) under the input data, if the expected output result is successful.
In the above scenario, the interface parameters, the input data and the corresponding expected output result are configured manually by the tester.
S202, the software testing equipment determines interface parameters used in the application scene A and corresponding input data according to the scene use case.
After the scenario use case is obtained, the software testing device may determine, according to the scenario use case, interface parameters and corresponding input data used by the software under test in the application scenario a. Because the scene case is a known test case, the scene case can be subjected to case script analysis, so that all interface parameters and input data of each interface parameter used by the software to be tested in the application scene A can be determined.
For example, for information flow application, in a scenario where an application scenario is information recommendation, interface parameters included in a scenario case are respectively: uid, age, color and phone Type, the input data corresponding to each interface parameter is: uid 001, age 25, color blue and phone Type v50, and the corresponding expected output results were successful. With reference to fig. 3, the software testing device may analyze the scenario case, and determine all interface parameters used in the information recommendation scenario and input data corresponding to each interface parameter. The method comprises the following steps: the interface parameters include: and the input data corresponding to the uid, age, color and phone Type and each interface parameter comprises: uid ═ x001, age ═ 25, color ═ blue, and phone Type ═ v 50.
S203, the software testing equipment obtains an interface description file of an interface corresponding to the interface parameters used in the application scene A.
The software testing equipment can also determine an interface corresponding to the interface parameter used in the application scene A by carrying out case script analysis on the scene case. The interface corresponding to the interface parameter used in the application scenario a may include one interface or may include a plurality of interfaces. After determining the interface corresponding to the interface parameter used in the application scenario a, the software testing device may obtain an interface description file of each interface in the determined interfaces.
The interface description file, i.e. the interface document, is a file for describing an interface included in the software. An interface description file for an interface may include: the interface parameters of the interface, all input data for each interface parameter, and the expected output result of the interface for each interface parameter under different input data.
For example, the interface description file may be stored in the memory of the software testing apparatus by a tester in advance. For example, the interface description file may be stored in a code bin of a memory of the software testing device. The software testing device can obtain the interface description files of all the determined interfaces from the code bin.
For example, as shown in fig. 3, in the above example, for the information flow application, in the information recommendation scenario, the scenario use case is subjected to use case script analysis, and it can be determined that the interface corresponding to the interface parameter used in the information recommendation scenario includes the above interface 1 (e.g., an interface between the information flow application and a background server of the information flow application). The software testing device may retrieve the interface description file for interface 1 from a code bin of memory.
The interface description file of the interface 1 may include an interface definition description, that is, a definition description of each interface parameter (e.g., uid, age, color, and phone Type) included in the interface 1. For example, the interface definition of interface 1 is described as follows:
Figure BDA0003102242340000071
Figure BDA0003102242340000081
and the name is uid and is used for defining the interface parameter to be uid. String, which is used for defining the type of the interface parameter uid as a character string type. maxLength:4 and minLength:4, respectively, for defining the maximum length of the interface parameter uid to be 4 and the minimum length to be 4.
And the name: age is used for defining the interface parameter as age. And the type is integer and is used for defining the type of the interface parameter age as a digital type. maximum of 150 and minimum of 0, which are used to define the maximum value of 150 and the minimum value of 0 for the interface parameter age. The name is color and is used for defining the interface parameter as color. String, which is used for defining the type of the interface number color and enum: red, blue, green, which is used to define the type of the interface parameter color as an enumeration type. The definition description of the interface parameter phone Type can refer to the definition description of the other interface parameters mentioned above, and is not described in detail here.
The interface description file of interface 1 may further include: all input data for the respective interface parameters of interface 1, and the expected output results for the different input data for each interface parameter.
For example, the interface parameter is taken as the interface parameter color. The interface description file of interface 1 may also include data as shown in table 1.
TABLE 1
Serial number Input data of color Expected output result
1 red Successful
2 green Successful
3 blue Successful
4 yellow Failure of
5 0 Failure of
6 1 Failure of
7 2 Failure of
8 3 Failure of
9 -1 Failure of
10 "abc" Failure of
11 Is empty Failure of
12
As shown in table 1, the input data of the interface parameter color may include: red, green, blue, yellow, 0, 1, 2, 3, -1, "abc", empty, etc. And when the input data of the interface parameter color is red, green and blue, the corresponding expected output results are all successful, and when the input data of the interface parameter color is yellow, 0, 1, 2, 3, -1, abc and empty, the corresponding expected output results are all failed.
As another example, the interface parameters are the interface parameters uid and age. The interface description file of interface 1 may also include data as shown in tables 2 and 3.
TABLE 2
Serial number Input data of uid Expected output result
1 X001 Successful
2 1000 Successful
3 a001 Successful
4 abcd Successful
5 Abcd Successful
6 ABCD Successful
7 Abc@ Successful
8 Ab@1 Successful
9 #Abc Successful
10 #### Successful
11 abc Failure of
12 abcde Failure of
13 Air conditioner Failure of
14
TABLE 3
Serial number age input data Expected output result
1 0 Successful
2 1 Successful
3 50 Successful
4 149 Successful
5 150 Successful
6 151 Failure of
7 -1 Failure of
8 "abc" Failure of
9 Air conditioner Successful
10
As shown in table 2, the input data of the interface parameter uid may include: x001, 1000, a001, Abcd, Abcd, ABCD, Abc @, Ab @1, # Abc, #####, Abc, abcde, null, etc. When the input data of the interface parameter uid are X001, 1000, a001, Abcd, Abc @, Ab @1, # Abc, and # #######, the corresponding expected output results are successful, and when the input data of the interface parameter uid are Abc, abcde, and empty, the corresponding expected output results are failed.
As shown in table 3, the input data of the interface parameter age may include: 0. 1, 50, 149, 150, 151, -1, "abc", empty, etc. When the input data of the interface parameter age are 0, 1, 50, 149 and 150 and are empty, the corresponding expected output results are successful, and when the input data of the interface parameter age are 151, -1 and "abc", the corresponding expected output results are failed.
S204, the software testing equipment generates a test case set of the interface parameters used under the application scene A according to the interface description file of the interface corresponding to the interface parameters used under the application scene A, the interface parameters used under the application scene A and the corresponding input data.
After the interface parameters and the corresponding input data used in the application scenario a and the interface description file of the interface corresponding to the interface parameters used in the application scenario a are acquired, the software testing device can automatically generate a test case set according to the interface description file of the interface corresponding to the interface parameters used in the application scenario a, the interface parameters used in the application scenario a and the corresponding input data, and the test case set can be used for realizing the test of the interface corresponding to the interface parameters used in the application scenario a.
As an example implementation, the software testing device analyzes the interface description file of the interface corresponding to the interface used in the application scenario a acquired in S203, and may acquire a normal value and an abnormal value of each interface parameter used in the application scenario a, and an expected output result corresponding to each value. The normal value and the abnormal value may be the test values in the embodiment of the present application. Then, the software testing device may generate a test case set of the interface parameters used in the application scenario a according to the normal values and the abnormal values of the interface parameters used in the application scenario a, the expected output results corresponding to the values, and the input data corresponding to the interface parameters used in the application scenario a obtained in S202.
The normal value and the abnormal value of the input data of the interface parameters of different types are different, so the normal value and the abnormal value can be determined according to the types of the interface parameters. The types of interface parameters may include an enumeration type, a number type, a string type, a boolean type, and the like. An enumeration-type interface parameter whose input data includes a plurality of data that may be enumerated. The boolean interface parameter has only two inputs, false and true. The input data of the digital type interface parameters are all numbers. The input data of the interface parameter of the character string type are character strings.
The software testing equipment can analyze the interface definition description in the corresponding interface description file so as to determine the type of the corresponding interface parameter.
For example, if the type of the interface parameter uid in the interface definition description is string, the software testing device analyzes the interface definition description and may determine that the type of the interface parameter uid is a character string type. Similarly, if the type of the interface parameter color in the interface definition description is string, and enum is red, blue, green, then the software testing device may analyze it to determine that the type of the interface parameter color is an enumerated type,
after the software testing device determines the type of the interface parameter used in the application scenario a, the software testing device may determine a normal value and an abnormal value of the interface parameter by combining all input data and types of the interface parameter in the interface description file of the corresponding interface.
For example, in the case where the type of the interface parameter is an enumeration type, the software testing apparatus may determine a full coverage value as a normal value of the input data of the interface parameter, and determine a value, a character string, a special character, a number, and the like outside a boundary of the input data of the interface parameter as an abnormal value of the input data of the interface parameter. The full coverage value may be all input data that may be enumerated by the interface parameter. Illustratively, when the interface parameter is color, the full coverage value, i.e., the interface parameter, is all the input data that can be enumerated by color, i.e., red, green, and blue.
For example, the interface parameter is color, and its type is enumerated type. With reference to table 1, the software testing device may determine that the normal values of the input data of the interface parameter color are red, green and blue, and the abnormal values of the input data of the interface parameter color are: the value outside the boundary of the input data of the interface parameter color (e.g., -1, 3, 4), the string (e.g., purple, ABC), the special character (e.g., & ^ purple, ABC, & ^ null), and the number (0, 1, 2).
For example, in the case that the type of the interface parameter is a numeric type, the software testing device may determine any one of values between boundary values of input data of the interface parameter as a normal value of the input data of the interface parameter, and a minimum boundary value-1 of the input data of the interface parameter, a maximum boundary value +1 of the input data of the interface parameter, a character string, and a special character as an abnormal value of the input data of the interface parameter.
For example, the interface parameter is age and the type is a numeric type. With reference to table 3, the software testing device may determine that the normal value of the input data of the interface parameter age is 1. The minimum boundary value of the interface parameter age is 0, the maximum boundary value is 150, and the software testing equipment can determine that the abnormal value of the input data of the interface parameter age comprises: the minimum boundary value of the input data of the interface parameter is-1 (i.e., -1), the maximum boundary value of the input data of the interface parameter is +1 (i.e., + 151), and the character string (i.e., "abc").
For example, in the case where the type of the interface parameter is a character string type, the software testing apparatus may determine a boundary length of the input data of the interface parameter as a normal value of the input data of the interface parameter, and determine a boundary length +1 of the input data of the interface parameter, a boundary length-1 of the input data of the interface parameter, a null, a special character, a number, and the like as an abnormal value of the input data of the interface parameter. In the case where the type of the interface parameter is a boolean type, the software test may determine True and False as normal values of the input data of the interface parameter, and numbers, special characters, character strings, and the like as abnormal values of the input data of the interface parameter.
In this way, normal and abnormal values of all interface parameters used in the application scenario a can be obtained. Then, the software testing device combines the data (such as the data shown in tables 1-3) in the interface description file of the corresponding interface to obtain the expected output result corresponding to each value. After the normal values and the abnormal values of all the interface parameters used in the application scenario a and the expected output results corresponding to the values are obtained, the test case set of the interface parameters used in the application scenario a can be automatically generated by combining the input data corresponding to the interface parameters used in the application scenario a, which is obtained in S202.
Because the interface parameters are independent, under the condition that the input data of one interface parameter is fixed, the output result of the corresponding interface cannot be influenced by the change of the input data of other interface parameters. Therefore, the software testing device may traverse the input data of one of the interface parameters (for example, referred to as interface parameter 1) according to the normal values and the abnormal values of all the interface parameters used in the application scenario a, fix the input data of the other interface parameters (for example, referred to as interface parameter 2), and combine the expected output result corresponding to the interface parameter 1 under each input data to generate the test case set corresponding to the interface parameter 1. That is, the test case set of the interface parameter 1 includes test cases corresponding to the test values of the interface parameter 1 one to one. The input data of the interface parameter 1 of one test case is a test value, and the input data of other interface parameters is the input data corresponding to other interface parameters. And similar processing is carried out on other interface parameters to obtain test case sets corresponding to all the interface parameters used in the application scenario A. Then, the software testing device may use the test case sets corresponding to all the interface parameters as the test case sets of the interface parameters used in the application scenario a.
With reference to the example of fig. 3, continuing to use the software to be tested as the information flow application and the application scenario as the information recommendation scenario, for example, determining, in S204, that is, the software testing device, the test case set corresponding to each interface parameter according to the interface description file of the interface 1 and all the interface parameters used in the information recommendation scenario obtained according to the scenario case and the input data corresponding to each interface parameter.
The interface parameters used in the information recommendation scene are uid, age, color and phone Type. Take interface parameter 1 as color, and interface parameter 2 as uid, age, and phone Type as examples. And the software testing equipment determines the type of the interface parameter color as an enumeration type according to the interface description file of the interface 1. The software testing equipment determines the normal value and the abnormal value of the input data of the interface parameter color and the expected output result corresponding to each value according to the interface description file of the interface 1 and the type of the interface parameter color. For example, the normal values of the input data of the interface parameter color include: full coverage values (e.g., red, green, and blue). When the input data of the interface parameter color is a normal value, the corresponding expected output result is successful. The abnormal values of the input data of the interface parameter color include: the value outside the boundary of the input data of the interface parameter color (e.g., -1, 3, 4), the string (e.g., puple, ABC), the special character (e.g., & ^ puple, ABC, & ^ null). When the input data of the interface parameter color is an abnormal value, the corresponding expected output result is failure.
In addition, in S202, the software testing device determines that the input data of the interface parameters used in the information recommendation scenario are respectively: uid 001, age 25, color blue, phone Type v 50.
The software testing device may fix uid 001, age 25, and phone TYPE 50, traverse normal values and abnormal values of the input data of the interface parameter color, and determine an expected output result corresponding to each input data of the interface parameter color, so as to generate a test case set corresponding to the interface parameter color.
For example, the input data of the interface parameter color is normal values, such as full coverage value, red, green and blue, and the corresponding expected output results are all successful. The input data of the interface parameter color is abnormal values, such as-1, 3, 4, puple, ABC, & ^%, puple, ABC, & ^ and null, and the corresponding expected output results are all failures. The software testing device may traverse each input data of the interface parameter color to generate a corresponding test case, so as to obtain a test case set corresponding to the interface parameter color. For example, generating a test case set of the interface parameter color may specifically include: cure-x 001, age-25, phone TYPE-v 50, color-red, corresponding to the expected outcome success; cure is x001, age 25, phone TYPE v50, color green, corresponding to expected output results as successful; cure ═ x001, age ═ 25, phone TYPE ═ v50, color ═ blue, corresponding to expected output results as successful; uid ═ x001, age ═ 25, phone TYPE ═ v50, color ═ -1, corresponding to the expected outcome of failure, …, uid ═ x001, age ═ 25, phone TYPE ═ v50, color ═ empty, corresponding to the expected outcome of failure.
Similarly, the software testing device may fix color blue, age 25, and phone TYPE v50, traverse normal and abnormal values of the input data of the interface parameter uid, and determine an expected output result corresponding to each input data of the interface parameter uid to generate a test case set corresponding to the interface parameter uid. The software testing equipment fixes color blue, uid x001 and phone TYPE v50, traverses normal values and abnormal values of input data of the interface parameter age, and determines an expected output result corresponding to each input data of the interface parameter age to generate a test case set corresponding to the interface parameter age. The software testing equipment fixes the uid 001, the age 25 and the color blue, traverses the input data of the interface parameter phone Type, and determines an expected output result corresponding to each input data of the interface parameter phone Type to generate a test case set corresponding to the interface parameter phone Type.
Then, as shown in fig. 3, the software testing device may use the test case set corresponding to the interface parameter color, the test case set corresponding to the interface parameter uid, the test case set corresponding to the interface parameter age, and the test case set corresponding to the interface parameter phone Type as the test case set of the interface parameter used in the information recommendation scenario.
Optionally, after the software testing device generates a test case set used for the interface parameters in the application scenario a, the test case set may be stored. For example, the software testing device may correspondingly store the interface identifier of the interface corresponding to the interface parameter related to the test case set and the test case set, so as to subsequently test the interface corresponding to the corresponding interface parameter. The identity of the interface may be a Uniform Resource Locator (URL) of the interface, which is used to address the interface.
It should be noted that, the above embodiment describes a generation process of a test case set of interface parameters used by a software under test in an application scenario. For other application scenarios related to the software, a test case set of the interface parameters used in the application scenario may also be automatically generated according to the method provided in the above embodiment, and details of the embodiment of the present application are not described herein again.
The method for generating the test case provided by the embodiment of the application can automatically generate the test case set of the interface parameters used in the application scene based on the known test case in the application scene. And the manual design of testers is not needed, so that the labor cost is saved. And only the interface parameters used in the application scene generate corresponding test case sets for testing the interfaces corresponding to the interface parameters, so that the data volume of the test cases is reduced, the execution time of the test cases is shortened, the time of interface testing is shortened, and the testing efficiency is improved.
After the test case set of the interface parameters used in the application scenario a is generated, the interface corresponding to the interface parameters may be tested by using the test case set, so as to check whether the corresponding interface of the software to be tested meets the specified requirements.
Fig. 4 is a schematic flowchart of an interface testing method according to an embodiment of the present application. As shown in fig. 4, the interface testing method may include:
s401, software testing equipment obtains a use case execution environment of a tested object.
And the tested object is an interface corresponding to the interface parameters used by the tested software in the application scene A.
The case execution environment may refer to a running environment of a test case of the object under test. The use case execution environment can comprise an existing network mirror image environment, a functional test environment and the like. Different use case execution environments have different requirements on data processing. For example, different use case execution environments have different requirements on the format of the use case. In the case that the format of the use case is different from the format required by the use case execution environment, the software testing device can convert the format of the use case into the format required by the use case execution environment.
S402, software testing equipment obtains a test case set, wherein the test case set comprises a test case 1.
The test case set is a test case set of interface parameters used by the software to be tested in the application scenario a. The set of test cases may include a plurality of test cases. The test case 1 is any one of the test cases in the test case set.
S403, the software testing equipment obtains the case information of the test case 1 and the identification of the interface stored corresponding to the test case set.
The software testing device may analyze the test case 1 to obtain case information of the test case 1, such as interface parameters used in the application scenario a, input data corresponding to the interface parameters, and a corresponding expected output result. The software testing equipment can also acquire the identifier of the interface stored corresponding to the testing case set, wherein the identifier of the interface is the identifier of the interface corresponding to the interface parameter used in the application scenario A.
For example, in combination with the example of fig. 3, in a scenario where the application scenario is information recommendation, the test case set may include: the test case set corresponding to the interface parameter color, the test case set corresponding to the interface parameter uid, the test case set corresponding to the interface parameter age, and the test case set corresponding to the interface parameter phone Type. The test case 1 may be any test case in the test case set corresponding to the interface parameter color. The test case 1 may also be any one of the test case sets corresponding to the interface parameter uid. The test case 1 may also be any one of the test case sets corresponding to the interface parameter age. The test case 1 may also be any test case in the test case set corresponding to the interface parameter phone Type. The identification of the interface stored in correspondence with the test case set is the URL of interface 1 in the above example. The interface 1 is an interface between the information flow application and a background server of the information flow application.
Taking the test case 1 as any test case in the test case set corresponding to the interface parameter color as an example, the case information of the test case 1 may include: the interface parameters (uid, color, and phone Type) of each interface, the input data (uid ═ x001, age ═ 25, color ═ red, and phone Type ═ v50) corresponding to the interface parameters, and the corresponding expected output result (success).
S404, the software testing equipment sends the case information of the testing case 1 and the identification of the interface stored corresponding to the testing case set to the electronic equipment.
The electronic device is a device installed with software (such as information flow application) corresponding to the object to be tested. For example, the electronic device may be a mobile phone, a computer, or the like.
And S405, receiving an actual output result of the tested object from the electronic equipment by the software testing equipment.
And S406, the software testing equipment compares the actual output result of the tested object with the corresponding expected output result, and marks the test case 1.
The software testing equipment can send the case information of the test case 1 and the identification of the interface stored corresponding to the test case set to the electronic equipment through the message frame, so that the electronic equipment can respectively set the input data corresponding to the interface parameters of the interface as the input data corresponding to the interface parameters in the case information of the test case 1 according to the identification of the interface, and then the tested object is tested to obtain the actual output result corresponding to the tested object.
After the electronic device obtains the actual output result corresponding to the tested object, the actual output result corresponding to the tested object is sent to the software testing device, so that the software testing device can compare the actual output result corresponding to the tested object with an expected output result included in the case information of the test case 1.
And under the condition that the actual output result is the same as the expected output result included in the case information of the test case 1 after the actual output result and the expected output result corresponding to the tested object are the same, namely the actual output result is the same as the expected output result included in the case information of the test case 1 after the tested object is tested by adopting the input data corresponding to the interface parameters included in the case information of the test case 1, the software testing equipment marks the test case 1 as passing. And under the condition that the actual output result is different from the expected output result contained in the case information of the test case 1 after the actual output result and the expected output result corresponding to the tested object are different, namely the actual output result is different from the expected output result contained in the case information of the test case 1 after the tested object is tested by adopting the input data corresponding to the interface parameters contained in the case information of the test case 1, the software testing equipment marks the test case 1 as failure.
Illustratively, in conjunction with the above example, the use case information of the test use case 1 includes: the interface parameters (uid, color, and phone Type), the input data (uid ═ x001, age ═ 25, color ═ red, and phone Type ═ v50) corresponding to the interface parameters, and the corresponding expected output result (success). After the electronic device sets the interface parameters (uid, color, and phone Type) included in the interface 1 as corresponding input data (uid ═ x001, age ═ 25, color ═ red, and phone Type ═ v50), respectively, the electronic device may acquire an actual output result, such as a success of the actual output result. The electronic device may send the actual output result to the software testing device. After the software testing device receives the actual output result, the actual output result can be determined to be the same as the expected output result included in the case information of the test case 1, and the software testing device marks that the test case 1 passes.
After the software testing equipment compares the actual output result and the expected output result corresponding to the tested object and marks the test case 1, the software testing equipment can continue to compare the actual output result and the expected output result corresponding to the tested object under other test cases in the test case set and mark the other test cases. The specific implementation of the actual output result corresponding to the other test case obtained by the software test device may refer to the implementation of obtaining the actual output result corresponding to the test case 1, that is, the foregoing S403-S405, and details of the embodiment of the present application are not described herein again.
And S407, the software testing equipment generates and outputs a case execution report of the tested object.
After the software testing device marks each test case in the test case set, the software testing device can generate a case execution report of the tested object. The software testing equipment can generate and output a case execution report according to the marking information (such as pass or fail) of all the test case sets in the test case set of the tested object. The use case execution report includes: and each test case in the test case set corresponding to the tested object and the mark information of each test case.
Optionally, after the use case execution report is generated, the use case execution report may be analyzed, so that whether the corresponding interface of the tested software meets the specified requirement may be determined by using the use case execution report.
By adopting the method, the corresponding interface is tested by utilizing the test case set generated by the interface parameters used in the application scene, the test of the corresponding interface is realized by adopting fewer test cases, the execution time of the test cases is shortened, the time for testing the interface is further shortened, and the test efficiency is improved.
Corresponding to the method in the foregoing embodiment, an embodiment of the present application further provides a device for generating a test case. The apparatus may be applied to an electronic device for implementing the method in the foregoing embodiments. The functions of the device can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the above-described functions. For example, fig. 5 shows a schematic structural diagram of a test case generation apparatus, and as shown in fig. 5, the apparatus includes: an acquisition module 501, a generation module 502, etc.
The obtaining module 501 may be configured to obtain a first test case; the first test case is a test case for testing the first interface by using first interface parameters, the first interface parameters are interface parameters used by the software to be tested in a first application scene, and the first test case comprises: a first interface parameter and corresponding input data; and acquiring the test value of the first interface parameter and a corresponding expected output result according to the interface description file of the first interface. The generating module 502 may be configured to generate a test case set of the first interface parameter according to the input data corresponding to the first interface parameter, the test value of the first interface parameter, and the expected output result, so as to implement the test on the first interface.
In another possible implementation, the generating module 502 is specifically configured to, for each interface parameter in the first interface parameters: generating a test case set of the interface parameters according to the test values of the interface parameters and input data corresponding to other interface parameters in the first interface parameters; the test case set of the interface parameters comprises test cases which correspond to the test values of the interface parameters one by one; the input data of the interface parameters of one test case is a test value, and the input data of other interface parameters is the input data corresponding to other interface parameters.
In another possible implementation manner, the interface description file of the first interface includes: all interface parameters of a first interface, all input data of each interface parameter, and an expected output result of the first interface of each interface parameter under different input data; an obtaining unit 501, configured to analyze the interface description file and determine a type of the first interface parameter; acquiring a test value of the first interface parameter according to the type of the first interface parameter and all input data of the first interface parameter; and acquiring an expected output result corresponding to the test value of the first interface parameter according to the expected output result of the first interface under different input data of the first interface parameter.
In another possible implementation manner, the obtaining unit 501 is further configured to analyze the first test case, and determine the first interface parameter and the corresponding input data.
In another possible implementation manner, the obtaining unit 501 is further configured to analyze the first test case, determine the first interface, and obtain an interface description file of the first interface.
In another possible implementation, the test values include normal values and abnormal values, the normal values corresponding to expected output results being success, and the abnormal values corresponding to expected output results being failure.
It should be understood that the division of units or modules (hereinafter referred to as units) in the above apparatus is only a division of logical functions, and may be wholly or partially integrated into one physical entity or physically separated in actual implementation. And the units in the device can be realized in the form of software called by the processing element; or may be implemented entirely in hardware; part of the units can also be realized in the form of software called by a processing element, and part of the units can be realized in the form of hardware.
For example, each unit may be a processing element separately set up, or may be implemented by being integrated into a chip of the apparatus, or may be stored in a memory in the form of a program, and a function of the unit may be called and executed by a processing element of the apparatus. In addition, all or part of the units can be integrated together or can be independently realized. The processing element described herein, which may also be referred to as a processor, may be an integrated circuit having signal processing capabilities. In the implementation process, the steps of the method or the units above may be implemented by integrated logic circuits of hardware in a processor element or in a form called by software through the processor element.
In one example, the units in the above apparatus may be one or more integrated circuits configured to implement the above method, such as: one or more ASICs, or one or more DSPs, or one or more FPGAs, or a combination of at least two of these integrated circuit forms.
As another example, when a unit in a device may be implemented in the form of a processing element scheduler, the processing element may be a general purpose processor, such as a CPU or other processor capable of invoking programs. As another example, these units may be integrated together and implemented in the form of a system-on-a-chip (SOC).
In one implementation, the means for implementing the respective corresponding steps of the above method by the above apparatus may be implemented in the form of a processing element scheduler. For example, the apparatus may include a processing element and a memory element, the processing element calling a program stored by the memory element to perform the method described in the above method embodiments. The memory elements may be memory elements on the same chip as the processing elements, i.e. on-chip memory elements.
In another implementation, the program for performing the above method may be in a memory element on a different chip than the processing element, i.e. an off-chip memory element. At this time, the processing element calls or loads a program from the off-chip storage element onto the on-chip storage element to call and execute the method described in the above method embodiment.
For example, the embodiments of the present application may also provide an apparatus, such as: an electronic device may include: a processor, a memory for storing instructions executable by the processor. The processor is configured to execute the above instructions, so that the electronic device implements the method for generating the test case according to the foregoing embodiment. The memory may be located within the electronic device or external to the electronic device. And the processor includes one or more.
In yet another implementation, the unit of the apparatus for implementing the steps of the method may be configured as one or more processing elements, and these processing elements may be disposed on the electronic device corresponding to the foregoing, where the processing elements may be integrated circuits, for example: one or more ASICs, or one or more DSPs, or one or more FPGAs, or a combination of these types of integrated circuits. These integrated circuits may be integrated together to form a chip.
For example, the embodiment of the present application also provides a chip, and the chip can be applied to the electronic device. The chip includes one or more interface circuits and one or more processors; the interface circuit and the processor are interconnected through a line; the processor receives and executes computer instructions from the memory of the electronic device through the interface circuitry to implement the methods described in the method embodiments above.
Embodiments of the present application further provide a computer program product, which includes computer instructions executed by an electronic device, such as the electronic device described above.
Through the above description of the embodiments, it is clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical functional division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another device, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may be one physical unit or a plurality of physical units, that is, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be embodied in the form of software products, such as: and (5) programming. The software product is stored in a program product, such as a computer readable storage medium, and includes several instructions for causing a device (which may be a single chip, a chip, or the like) or a processor (processor) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
For example, embodiments of the present application may also provide a computer-readable storage medium having stored thereon computer program instructions. The computer program instructions, when executed by the electronic device, cause the electronic device to implement the method for generating test cases as described in the aforementioned method embodiments.
The above description is only an embodiment of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present disclosure should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (14)

1. A method for generating a test case is characterized in that the method comprises the following steps:
acquiring a first test case; the first test case is a test case for testing a first interface by using first interface parameters, the first interface parameters are interface parameters used by the software to be tested in a first application scene, and the first test case comprises: the first interface parameters and corresponding input data;
obtaining a test value of the first interface parameter and a corresponding expected output result according to the interface description file of the first interface;
and generating a test case set of the first interface parameter according to the input data corresponding to the first interface parameter, the test value of the first interface parameter and the corresponding expected output result, wherein the test case set is used for realizing the test of the first interface.
2. The method of claim 1, wherein generating the test case set of the first interface parameter according to the input data corresponding to the first interface parameter, the test value of the first interface parameter, and the expected output result comprises:
for each of the first interface parameters:
generating a test case set of the interface parameters according to the test values of the interface parameters and input data corresponding to other interface parameters in the first interface parameters;
the test case set of the interface parameters comprises test cases which correspond to the test values of the interface parameters one by one; the input data of the interface parameters of one test case is a test value, and the input data of the other interface parameters is the input data corresponding to the other interface parameters.
3. The method of claim 1, wherein the interface description file for the first interface comprises: all interface parameters of the first interface, all input data of each interface parameter, and an expected output result of the first interface of each interface parameter under different input data;
the obtaining the test value of the first interface parameter and the corresponding expected output result according to the interface description file of the first interface includes:
analyzing the interface description file to determine the type of the first interface parameter;
acquiring a test value of the first interface parameter according to the type of the first interface parameter and all input data of the first interface parameter;
and acquiring an expected output result corresponding to the test value of the first interface parameter according to the expected output result of the first interface under different input data of the first interface parameter.
4. The method of any of claims 1-3, wherein after said obtaining the first test case, the method further comprises:
and analyzing the first test case to determine the first interface parameters and the corresponding input data.
5. The method according to any of claims 1-3, wherein prior to said obtaining the test values of the first interface parameters and the corresponding expected output results from the interface description file of the first interface, the method further comprises:
and analyzing the first test case, determining the first interface, and acquiring an interface description file of the first interface.
6. The method of claim 1, wherein the test values include normal values and abnormal values, the normal values corresponding to an expected output result being a success and the abnormal values corresponding to an expected output result being a failure.
7. An electronic device, comprising a processor, a memory for storing processor-executable instructions; the processor is configured to execute the instructions to cause the electronic device to:
acquiring a first test case; the first test case is a test case for testing a first interface by using first interface parameters, the first interface parameters are interface parameters used by the software to be tested in a first application scene, and the first test case comprises: the first interface parameters and corresponding input data;
obtaining a test value of the first interface parameter and a corresponding expected output result according to the interface description file of the first interface;
and generating a test case set of the first interface parameter according to the input data corresponding to the first interface parameter, the test value of the first interface parameter and the corresponding expected output result, wherein the test case set is used for realizing the test of the first interface.
8. The electronic device according to claim 7, wherein the generating a test case set of the first interface parameter according to the input data corresponding to the first interface parameter, the test value of the first interface parameter, and the corresponding expected output result specifically includes:
for each of the first interface parameters:
generating a test case set of the interface parameters according to the test values of the interface parameters and input data corresponding to other interface parameters in the first interface parameters;
the test case set of the interface parameters comprises test cases which correspond to the test values of the interface parameters one by one; the input data of the interface parameters of one test case is a test value, and the input data of the other interface parameters is the input data corresponding to the other interface parameters.
9. The electronic device of claim 7, wherein the interface description file for the first interface comprises: all interface parameters of the first interface, all input data of each interface parameter, and an expected output result of the first interface of each interface parameter under different input data;
the obtaining of the test value of the first interface parameter and the corresponding expected output result according to the interface description file of the first interface specifically includes:
analyzing the interface description file to determine the type of the first interface parameter;
acquiring a test value of the first interface parameter according to the type of the first interface parameter and all input data of the first interface parameter;
and acquiring an expected output result corresponding to the test value of the first interface parameter according to the expected output result of the first interface under different input data of the first interface parameter.
10. The electronic device of any of claims 7-9, wherein the processor is configured to execute the instructions to further cause the electronic device to:
and analyzing the first test case to determine the first interface parameters and the corresponding input data.
11. The electronic device of any of claims 7-9, wherein the processor is configured to execute the instructions to further cause the electronic device to:
and analyzing the first test case, determining the first interface, and acquiring an interface description file of the first interface.
12. The electronic device of claim 7, wherein the test values include normal values and abnormal values, wherein the normal values correspond to a successful expected output result, and wherein the abnormal values correspond to a failed expected output result.
13. A computer readable storage medium having stored thereon computer program instructions; it is characterized in that the preparation method is characterized in that,
the computer program instructions, when executed by an electronic device, cause the electronic device to implement the method of any of claims 1 to 6.
14. A computer program product comprising computer readable code which, when run in an electronic device, causes the electronic device to implement the method of any of claims 1 to 6.
CN202110626466.2A 2021-06-04 2021-06-04 Test case generation method and electronic equipment Active CN113407446B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110626466.2A CN113407446B (en) 2021-06-04 2021-06-04 Test case generation method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110626466.2A CN113407446B (en) 2021-06-04 2021-06-04 Test case generation method and electronic equipment

Publications (2)

Publication Number Publication Date
CN113407446A true CN113407446A (en) 2021-09-17
CN113407446B CN113407446B (en) 2022-05-03

Family

ID=77676426

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110626466.2A Active CN113407446B (en) 2021-06-04 2021-06-04 Test case generation method and electronic equipment

Country Status (1)

Country Link
CN (1) CN113407446B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8448146B2 (en) * 2011-03-31 2013-05-21 Infosys Limited Generation of functional tests for re-hosted applications
US20140304688A1 (en) * 2012-05-17 2014-10-09 Cognizant Technology Solutions India Pvt. Ltd. Method and system for generating and processing black box test cases
US20180329810A1 (en) * 2017-05-15 2018-11-15 Toyota Jidosha Kabushiki Kaisha Test method and non-transitory computer readable medium storing program
CN109062788A (en) * 2018-07-17 2018-12-21 招银云创(深圳)信息技术有限公司 Method for generating test case, device, computer equipment and storage medium
CN109885488A (en) * 2019-01-30 2019-06-14 上海卫星工程研究所 The satellite orbit software for calculation automated testing method and system of use-case table- driven
CN110851361A (en) * 2019-11-08 2020-02-28 拉扎斯网络科技(上海)有限公司 Interface testing method and device, electronic equipment and readable storage medium
CN111444096A (en) * 2020-03-25 2020-07-24 北京市信息技术研究所 Interface test case generation method and device
CN111782526A (en) * 2020-06-30 2020-10-16 北京同邦卓益科技有限公司 Interface testing method and device, electronic equipment and storage medium
CN112306861A (en) * 2020-09-27 2021-02-02 泰山信息科技有限公司 Unittest and Jenkins tool-based interface automatic testing system and method
CN112328419A (en) * 2020-11-27 2021-02-05 北京字节跳动网络技术有限公司 Test case generation method and device for remote procedure call interface, storage medium and electronic equipment
CN112597052A (en) * 2020-12-29 2021-04-02 深圳Tcl新技术有限公司 Interface testing method and device and computer readable storage medium

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8448146B2 (en) * 2011-03-31 2013-05-21 Infosys Limited Generation of functional tests for re-hosted applications
US20140304688A1 (en) * 2012-05-17 2014-10-09 Cognizant Technology Solutions India Pvt. Ltd. Method and system for generating and processing black box test cases
US20180329810A1 (en) * 2017-05-15 2018-11-15 Toyota Jidosha Kabushiki Kaisha Test method and non-transitory computer readable medium storing program
CN109062788A (en) * 2018-07-17 2018-12-21 招银云创(深圳)信息技术有限公司 Method for generating test case, device, computer equipment and storage medium
CN109885488A (en) * 2019-01-30 2019-06-14 上海卫星工程研究所 The satellite orbit software for calculation automated testing method and system of use-case table- driven
CN110851361A (en) * 2019-11-08 2020-02-28 拉扎斯网络科技(上海)有限公司 Interface testing method and device, electronic equipment and readable storage medium
CN111444096A (en) * 2020-03-25 2020-07-24 北京市信息技术研究所 Interface test case generation method and device
CN111782526A (en) * 2020-06-30 2020-10-16 北京同邦卓益科技有限公司 Interface testing method and device, electronic equipment and storage medium
CN112306861A (en) * 2020-09-27 2021-02-02 泰山信息科技有限公司 Unittest and Jenkins tool-based interface automatic testing system and method
CN112328419A (en) * 2020-11-27 2021-02-05 北京字节跳动网络技术有限公司 Test case generation method and device for remote procedure call interface, storage medium and electronic equipment
CN112597052A (en) * 2020-12-29 2021-04-02 深圳Tcl新技术有限公司 Interface testing method and device and computer readable storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
CSDN风清扬: ""测试用例 自动生成工具PICT与AllPairs"", 《HTTPS://BLOG.CSDN.NET/HEXIESHANGWANG/ARTICLE/DETAILS/49924641》 *
RIJWAN KHAN: ""Optimization of Automatic Generated Test Cases for Path Testing Using Genetic Algorithm"", 《2016 SECOND INTERNATIONAL CONFERENCE ON COMPUTATIONAL INTELLIGENCE & COMMUNICATION TECHNOLOGY (CICT)》 *
宋晓秋等: ""两两组合测试用例生成的遍历搜索算法"", 《计算机工程与设计》 *

Also Published As

Publication number Publication date
CN113407446B (en) 2022-05-03

Similar Documents

Publication Publication Date Title
CN112039900B (en) Network security risk detection method, system, computer device and storage medium
CN110633198A (en) Block chain-based software test data storage method and system
CN110990276A (en) Automatic testing method and device for interface field and storage medium
CN110287104A (en) Method for generating test case, device, terminal and computer readable storage medium
WO2014070070A1 (en) Method, apparatus and computer program for detecting deviations in data sources
CN112948233A (en) Interface testing method, device, terminal equipment and medium
CN107203373B (en) Interface control acquiring method, interface control testing method, interface control acquiring device and interface control testing device
CN112561690B (en) Method, system, equipment and storage medium for testing credit card staged service interface
CN113407446B (en) Test case generation method and electronic equipment
CN112395339B (en) Intersystem data admission verification method, device, computer equipment and storage medium
CN113691972B (en) Service configuration method and device of android system
CN115114135B (en) Software data testing method, device, equipment, medium and product
CN110543394A (en) server sensor information consistency testing method, system, terminal and storage medium
CN116431522A (en) Automatic test method and system for low-code object storage gateway
CN115544132A (en) Data import method and system and electronic equipment
CN110727475B (en) Intelligent service calling method based on configuration
CN114721969A (en) Method and device for separating interface automation test data and test codes
CN109491699B (en) Resource checking method, device, equipment and storage medium of application program
CN114371866A (en) Version reconfiguration test method, device and equipment of service system
CN114817067B (en) Automatic mock testing method and device
CN116893978B (en) Test plan generation method, system and storage medium based on PTCRB authentication
CN117667693A (en) Automatic message testing method, device, equipment and storage medium
CN117195311A (en) Verification method and verification device for e-commerce platform and terminal equipment
CN118656289A (en) Data processing method and related device
CN117827908A (en) Client resource information display method and device, electronic 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
TR01 Transfer of patent right

Effective date of registration: 20230918

Address after: 201306 building C, No. 888, Huanhu West 2nd Road, Lingang New District, China (Shanghai) pilot Free Trade Zone, Pudong New Area, Shanghai

Patentee after: Shanghai Glory Smart Technology Development Co.,Ltd.

Address before: Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518040

Patentee before: Honor Device Co.,Ltd.

TR01 Transfer of patent right