A method and device for software testing

By automatically generating test data and using the dynamic proxy interface to call external interfaces, the problem of test failure caused by increased software functions is solved and testing efficiency is improved.

CN113760714BActive Publication Date: 2024-10-18BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011190212.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-30
Publication Date
2024-10-18
Estimated Expiration
2040-10-30

AI Technical Summary

Technical Problem

As software functions increase, the instability of external interfaces and data sources leads to test failures and reduces the testing efficiency of technicians.

Method used

Test data is automatically generated by calling the results of the external interface, test data is generated according to the data type, and the external interface is called through the dynamic proxy interface to ensure that the test can continue.

Benefits of technology

It improves the efficiency of software testing and ensures that testing can continue when the external interface cannot be connected or there is a lack of test data in the data source.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113760714B_ABST
    Figure CN113760714B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for software testing, and relates to the field of computer technology. A specific implementation of the method includes: calling an external interface corresponding to the software to be tested, and determining whether the calling result includes the production data of the software to be tested; when the calling result does not include the production data of the software to be tested, determining the data type of the test data corresponding to the software to be tested, and generating the test data corresponding to the software to be tested according to the data type; and testing the software to be tested according to the test data. When the software to be tested cannot be connected to the external interface so that the external data source cannot be obtained, or the external data source does not contain the test data, the implementation can automatically generate the test data according to the calling result of the external interface, and test the software to be tested according to the test data, so that the software test can continue, thereby improving the testing efficiency of the software.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for software testing. Background Art

[0002] Testing is a very important step in the software development process. Technicians often need to call external interfaces to obtain external data sources to test the developed functions. This requires ensuring that the external interfaces can be called normally in the test environment and that the corresponding external data sources have complete test data.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] As software functions increase, more and more external interfaces are called, and the external data sources relied on during testing are also growing. Since the external interfaces and their corresponding external data sources are not stable, when the external interface cannot be connected to obtain the external data source, or the external data source does not contain test data, the test will fail, reducing the testing efficiency of technicians. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a method and device for software testing. When the software to be tested cannot be connected to an external interface and cannot obtain an external data source, or the external data source does not contain test data, the test data can be automatically generated according to the call result of the external interface, and the software to be tested can be tested according to the test data, so that the software testing can continue, thereby improving the testing efficiency of the software.

[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a software testing method is provided.

[0007] A software testing method according to an embodiment of the present invention includes:

[0008] Calling the external interface corresponding to the software to be tested, and determining whether the calling result includes the production data of the software to be tested;

[0009] When the call result does not include the production data of the software to be tested, determining the data type of the test data corresponding to the software to be tested, and generating the test data corresponding to the software to be tested according to the data type;

[0010] According to the test data, the software to be tested is tested.

[0011] Optionally,

[0012] Generate test data corresponding to the software to be tested based on the data type, including:

[0013] When the data type is a composite type, recursively query the composite type to determine a plurality of simple types corresponding to the composite type, wherein the test data of the composite type is generated by combining the test data of the plurality of simple types;

[0014] Generate test data corresponding to the software to be tested based on the preset data corresponding to the simple type.

[0015] Optionally,

[0016] Recursively query the composite type to determine the multiple simple types corresponding to the composite type, including:

[0017] The following steps are executed repeatedly until multiple simple types corresponding to the composite type are determined or the recursive query level reaches the preset maximum depth:

[0018] Use the combined type as the current type to be queried;

[0019] Use Java reflection mechanism to determine the subtype corresponding to the current query type;

[0020] Determine whether the subtype is a simple type. If so, determine the preset data corresponding to the simple type; otherwise, determine whether the recursive query level reaches the preset maximum depth. If not, use the subtype as the current type to be queried.

[0021] Optionally,

[0022] Generate test data corresponding to the software to be tested based on the preset data corresponding to the simple type, including:

[0023] According to the hierarchical relationship between the simple types obtained by the recursive query and the combined types, the preset data corresponding to the simple types are combined to generate test data.

[0024] Optionally,

[0025] Generate test data based on the identifier and data type of the external interface.

[0026] Optionally,

[0027] Determining whether the identifier of the external interface includes a preset field indicating a target type;

[0028] If yes, generate test data according to the attributes of the target type; the target type includes any one or more of the following: age, mobile phone number, date, username and password.

[0029] Optionally,

[0030] Determine the data type of the test data corresponding to the software to be tested, including:

[0031] Use Java reflection mechanism to determine the data type of test data.

[0032] Optionally,

[0033] The method further includes:

[0034] When the call result includes production data of the software to be tested, the production data is recorded to generate test data.

[0035] Optionally,

[0036] The method further includes: storing the test data in correspondence with the identifier of the external interface;

[0037] Test the software to be tested based on the test data, including:

[0038] According to the corresponding stored external interface identifier and test data, and the external interface identifier corresponding to the software to be tested, the test data corresponding to the software to be tested is called to test the software to be tested.

[0039] Optionally,

[0040] Call the external interface corresponding to the software to be tested, including:

[0041] Determine the dynamic proxy interface corresponding to the software to be tested, and call the external interface through the dynamic proxy interface.

[0042] To achieve the above objective, according to another aspect of an embodiment of the present invention, a software testing device is provided.

[0043] A software testing device according to an embodiment of the present invention comprises an interface calling module, a data generating module and a software testing module; wherein:

[0044] The interface calling module is used to call the external interface corresponding to the software to be tested and determine whether the calling result includes the production data of the software to be tested;

[0045] A data generation module, used to determine the data type of the test data corresponding to the software to be tested when the interface calling module determines that the calling result does not include the production data of the software to be tested, and generate the test data corresponding to the software to be tested according to the data type;

[0046] The software testing module is used to test the software to be tested according to the test data generated by the data generation module.

[0047] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device for software testing is provided.

[0048] An electronic device for software testing according to an embodiment of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a method for software testing according to an embodiment of the present invention.

[0049] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided.

[0050] A computer-readable storage medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a software testing method according to an embodiment of the present invention is implemented.

[0051] An embodiment of the above invention has the following advantages or beneficial effects: when the software to be tested cannot be connected to the external interface and cannot obtain the external data source, or the external data source does not contain test data, it can automatically generate test data according to the call result of the external interface, and test the software to be tested according to the test data, so that the software testing can continue, thereby improving the software testing efficiency.

[0052] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0054] Figure 1 is a schematic diagram of main steps of a software testing method according to an embodiment of the present invention;

[0055] Figure 2 This is a schematic diagram of a merchant's after-sales software directly calling an external interface;

[0056] Figure 3 This is a schematic diagram of a merchant's after-sales software calling an external interface through a dynamic proxy interface;

[0057] Figure 4 is a schematic diagram of main steps of a method for generating test data according to an embodiment of the present invention;

[0058] Figure 5 is a schematic diagram of main steps of a method for determining a simple type corresponding to a combination type according to an embodiment of the present invention;

[0059] Figure 6 is a schematic diagram of main steps of another method for generating test data according to an embodiment of the present invention;

[0060] Figure 7is a schematic diagram of main modules of a software testing device according to an embodiment of the present invention;

[0061] Figure 8 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0062] Fig. 9 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0063] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0064] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.

[0065] Figure 1 It is a schematic diagram of main steps of a software testing method according to an embodiment of the present invention.

[0066] like Figure 1 As shown, a software testing method according to an embodiment of the present invention mainly includes the following steps:

[0067] Step S101: calling the external interface corresponding to the software to be tested, and determining whether the calling result includes the production data of the software to be tested.

[0068] At present, with the increase of software functions, the number of external interfaces that the software needs to call is also increasing. Take the after-sales software of a certain merchant on the market as an example. Figure 2 As shown, Figure 2 This is a schematic diagram of a merchant's after-sales software directly calling an external interface. The data to be processed by the software includes more than 40 types of data, including order data, logistics data, and service order data. Therefore, the software needs to call more than 40 external interfaces including order data interface, logistics data interface, and service order data interface.

[0069] For these more than 40 external interfaces, the software can call them one by one during testing to obtain test data. However, in this way, the software needs to take into account the status of more than 40 external interfaces, which not only increases the resources occupied by the software during operation, but also when an external interface cannot be connected, the software cannot obtain the test data corresponding to the external interface.

[0070] Therefore, in the embodiment of the present invention, the software to be tested can generate a dynamic proxy interface for the external interface it depends on, and call the external interface through the dynamic proxy interface, such as Figure 3 As shown, when the external interface cannot be called directly due to network, configuration, firewall and other reasons, the software to be tested can also call the external interface normally through the dynamic proxy interface and obtain test data. Moreover, even if the external interface can be called directly, or the software needs to obtain production data, the software can also give priority to calling the dynamic proxy interface, because at this time the software only needs to manage this one interface, and then the dynamic proxy interface manages other external interfaces, without the software having to take care of the status of multiple external interfaces, which can reduce the resources occupied by the software when it is running.

[0071] Step S102: when the call result does not include the production data of the software to be tested, determine the data type of the test data corresponding to the software to be tested, and generate the test data corresponding to the software to be tested according to the data type.

[0072] In an embodiment of the present invention, when the call result does not include the production data of the software to be tested, the method for generating the test data corresponding to the software to be tested is as follows: Figure 4 As shown, a method of generating test data according to an embodiment of the present invention mainly includes the following steps:

[0073] Step S401: Determine the data type of the test data corresponding to the software to be tested.

[0074] In the embodiment of the present invention, data types may include simple types and composite types. Simple types may include the eight basic types of Java, namely, char type, boolean type, byte type, short type, int type, long type, float type and double type, and string type; composite types are generated by combining multiple simple types, and composite types may be common array types, map types, list types, enumeration types, generic types, etc., or other user-defined data types.

[0075] In the embodiment of the present invention, the Java reflection mechanism can be used to determine the data type of the test data corresponding to the software to be tested.

[0076] Step S402: Generate test data corresponding to the software to be tested according to the data type.

[0077] In an embodiment of the present invention, when the Java reflection mechanism is used to determine that the data type of the test data is a simple type, the test data corresponding to the software to be tested can be generated according to the preset data corresponding to the simple type; or the preset data corresponding to the simple type can be directly used as the test data corresponding to the software to be tested. For example, the preset data of some simple types in a software to be tested are shown in the following table:

[0078] Data Types Preset Data Boolean Type ture int type 123 string type "abc"

[0079] When an external interface is called and the returned call result does not include production data, the Java reflection mechanism is first used to determine that the data type of the test data corresponding to the external interface is int type, and then the preset data 123 can be directly used as the test data corresponding to the software to be tested.

[0080] In an embodiment of the present invention, when the Java reflection mechanism is used to determine that the data type of the test data is a combination type, the combination type can be recursively queried first to determine multiple simple types corresponding to the combination type, wherein the test data of the combination type is generated by combining the test data of multiple simple types; then, according to the preset data corresponding to the simple type, the test data corresponding to the software to be tested is generated.

[0081] Figure 5 4 is a schematic diagram of main steps of a method for determining a simple type corresponding to a combination type according to an embodiment of the present invention.

[0082] like Figure 5 As shown, the method of recursively querying the composite type to determine multiple simple types corresponding to the composite type mainly includes the following steps:

[0083] Step S501: taking the combined type as the current type to be queried.

[0084] Step S502: Using the Java reflection mechanism, determine the subtype corresponding to the current type to be queried, and execute steps S503-S507 for each subtype.

[0085] Step S503: Determine whether the subtype is a simple type, if so, execute step S504, otherwise execute step S505.

[0086] Step S504: Determine the preset data corresponding to the simple type, and generate test data corresponding to the software to be tested according to the preset data.

[0087] In an embodiment of the present invention, test data corresponding to the software to be tested is generated according to preset data corresponding to simple types, which can be: according to the hierarchical relationship between simple types and combination types obtained by recursive query, the preset data corresponding to the simple types are combined as test data. For example, the subtype of a first combination type includes a string type and a second combination type, and then the Java reflection mechanism is used to determine that the subtype of the second combination type includes an int type and a boolean type, indicating that the first combination type has two layers, and then according to the hierarchical relationship between the simple types obtained by the query and the combination types, the first layer "abc" and the second layer 123 and ture are combined as test data, and the combined form can be as follows:

[0088]

[0089] Step S505: Determine whether the recursive query level reaches a preset maximum depth, if yes, execute step S507, otherwise execute step S506.

[0090] Under normal circumstances, the subtype of a combination type will also contain a combination type, and the subtype of the combination type in the subtype will also contain a combination type, and so on... At this time, it may cause too many recursive queries on the combination type, occupying too many computing resources. In order to prevent this problem, in an embodiment of the present invention, a preset maximum depth can be set for the recursive query to limit the maximum level of recursive queries on the combination type. When the recursive query level has reached the preset maximum depth, and there are still combination types in the subtype, the return value of the combination type in the subtype can be replaced with a null value. The preset maximum depth can be manually configured by a technician, or it can be automatically set by the software to be tested according to the operating environment, and this embodiment of the present invention does not specifically limit this.

[0091] Step S506: Use the subtype as the current type to be queried, and return to execute step S502.

[0092] Step S507: End the current process.

[0093] In an embodiment of the present invention, for some special scenarios, test data can also be generated according to the identifier and data type of the external interface. Specifically, first determine whether the identifier of the external interface contains a preset field indicating the target type; if so, generate test data according to the attributes of the target type. Among them, the target type includes any one or more of the following: age, mobile phone number, date, user name and password; and the attribute of the target type can be the number of digits of the target type or the format of the target type. The target type and its preset fields and the generated test data can be shown in the following table:

[0094] Target Type Preset fields Generated test data age age 18 Phone number phone "13112345678” date date 2020-07-21 username username chenjunjun password password "123456”

[0095] For example, in the scenario of calling the external interface for querying mobile phone numbers, if it is detected that the identifier of the external interface contains the preset field "phone" of the target type, then an 11-digit phone number can be generated as test data based on the number of digits of the target type, or the preset "13112345678" can be directly used as test data. In the scenario of calling the external interface for querying dates, if it is detected that the identifier of the external interface contains the preset field "date" of the target type, then a date in the same format can be generated as test data based on the format of the target type "xx-xx-xx", or the preset "2020-07-21" can be directly used as test data.

[0096] In the embodiment of the present invention, the target type and its preset fields can be composed of the above-mentioned daily vocabulary, and can also be configured according to different businesses. For example, for shopping software, some commonly used target types and their preset fields can be configured, such as the preset field of the target type of merchant ID can be venderId, the preset field of the target type of order number can be orderId, etc. This can make the generated test data more accurate and further improve the efficiency of software testing.

[0097] In an embodiment of the present invention, when the call result includes production data of the software to be tested, the production data can be recorded to generate test data corresponding to the software to be tested. Figure 6 As shown, another method for generating test data according to an embodiment of the present invention mainly includes the following steps:

[0098] Step S601: The software to be tested configures environment variables to enable a recording function;

[0099] Step S602: the software to be tested calls the dynamic proxy interface to generate a data proxy class;

[0100] Step S603: the data proxy class calls the external interface, and when the call result includes the production data of the software to be tested, the production data is recorded to generate test data;

[0101] Step S604: The data proxy class serializes the test data into a json format file and uploads it to the FTP server for next use.

[0102] In an embodiment of the present invention, when the software to be tested is in a scenario such as grayscale testing, the data proxy class calls an external interface and obtains the production data of the software to be tested. It can then return the production data directly to the software to be tested without any processing while recording, so as to ensure the normal operation of the software to be tested.

[0103] In the embodiment of the present invention, the data proxy class can also serialize the test data into a text file in other formats. In a preferred embodiment of the present invention, the identification name of the text file is: interface class name + method name.

[0104] In the embodiment of the present invention, after the data proxy class serializes the test data into a json format file, the json format file may also be saved locally without being uploaded to the FTP server.

[0105] In an embodiment of the present invention, after the data proxy class uploads the json format file to the FTP server, when the test data of the external interface is needed next time, the json format file can be directly downloaded from the FTP server, and the test data of the external interface can be obtained after parsing without having to call the external interface again, thereby improving the efficiency of software testing.

[0106] Step S103: testing the software to be tested according to the test data.

[0107] In an embodiment of the present invention, the generated test data is returned to the software to be tested to complete the entire test data generation process. While returning, a third-party tool can be used to serialize the returned test data into a text file and store it for use next time. In a preferred embodiment of the present invention, a third-party JSON serialization tool can be used to serialize the returned test data into a json format file and store it, because compared to other text files, json format files can directly use some third-party packages fastjson or gson for object conversion, and json format files are convenient to operate, modify and format in most development tools, and json format files are lighter than other text files, and occupy less bandwidth during network transmission.

[0108] In an embodiment of the present invention, the method also includes: storing the test data in correspondence with the identifier of the external interface; testing the software to be tested according to the test data, including: calling the test data corresponding to the software to be tested according to the corresponding stored external interface identifier and test data, and the external interface identifier corresponding to the software to be tested, so as to test the software to be tested.

[0109] It can be seen from a software testing method according to an embodiment of the present invention that when the software to be tested cannot be connected to an external interface and therefore cannot obtain an external data source, or the external data source does not contain test data, it is possible to automatically generate test data based on the call result of the external interface, and test the software to be tested based on the test data, so that software testing can continue, thereby improving software testing efficiency.

[0110] Figure 7It is a schematic diagram of main modules of a software testing device according to an embodiment of the present invention.

[0111] like Figure 7 As shown, a software testing device 700 according to an embodiment of the present invention includes: an interface calling module 701, a data generating module 702 and a software testing module 703; wherein:

[0112] The interface calling module 701 is used to call the external interface corresponding to the software to be tested and determine whether the calling result includes the production data of the software to be tested;

[0113] The data generating module 702 is used to determine the data type of the test data corresponding to the software to be tested when the interface calling module 701 determines that the calling result does not include the production data of the software to be tested, and generate the test data corresponding to the software to be tested according to the data type;

[0114] The software testing module 703 is used to test the software to be tested according to the test data generated by the data generating module 702 .

[0115] In an embodiment of the present invention, the data generation module 702 can also be used for: when the data type is a combination type, recursively querying the combination type to determine multiple simple types corresponding to the combination type, wherein the test data of the combination type is generated by combining the test data of multiple simple types; and generating test data corresponding to the software to be tested according to the preset data corresponding to the simple type.

[0116] In an embodiment of the present invention, the data generation module 702 can also be used to: loop the following steps until multiple simple types corresponding to the combined type are determined or the recursive query level reaches a preset maximum depth: use the combined type as the current type to be queried; use the Java reflection mechanism to determine the subtype corresponding to the current type to be queried; determine whether the subtype is a simple type, if so, determine the preset data corresponding to the simple type; otherwise determine whether the recursive query level reaches the preset maximum depth, if not, use the subtype as the current type to be queried.

[0117] In the embodiment of the present invention, the data generation module 702 may also be used to: combine preset data corresponding to simple types according to the hierarchical relationship between simple types and combined types obtained by recursive query to generate test data.

[0118] In the embodiment of the present invention, the data generation module 702 may also be used to generate test data according to the identifier and data type of the external interface.

[0119] In an embodiment of the present invention, the data generation module 702 can also be used to: determine whether the identifier of the external interface contains a preset field indicating the target type; if so, generate test data according to the attributes of the target type; the target type includes any one or more of the following: age, mobile phone number and date.

[0120] In the embodiment of the present invention, the data generation module 702 may also be used to determine the data type of the test data using a Java reflection mechanism.

[0121] In the embodiment of the present invention, when the call result includes production data of the software to be tested, the data generation module 702 can also be used to record the production data to generate test data.

[0122] In an embodiment of the present invention, the software testing module 703 can also be used to: store the test data in correspondence with the identifier of the external interface; call the test data corresponding to the software to be tested according to the corresponding stored external interface identifier and test data, and the external interface identifier corresponding to the software to be tested, so as to test the software to be tested.

[0123] In the embodiment of the present invention, the interface calling module 701 may also be used to: determine the dynamic proxy interface corresponding to the software to be tested, and call the external interface through the dynamic proxy interface.

[0124] It can be seen from a software testing device according to an embodiment of the present invention that when the software to be tested cannot be connected to an external interface so that the external data source cannot be obtained, or the external data source does not contain test data, it can automatically generate test data according to the call result of the external interface, and test the software to be tested according to the test data, so that the software testing can continue, thereby improving the software testing efficiency.

[0125] Figure 8 An exemplary system architecture 800 is shown to which a method for software testing or an apparatus for software testing according to an embodiment of the present invention may be applied.

[0126] like Figure 8 As shown, system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. Network 804 is used to provide a medium for communication links between terminal devices 801, 802, 803 and server 805. Network 804 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0127] Users can use terminal devices 801, 802, and 803 to interact with server 805 through network 804 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 801, 802, and 803, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0128] The terminal devices 801 , 802 , and 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0129] The server 805 may be a server that provides various services, such as a backend management server that provides support for shopping websites browsed by users using the terminal devices 801, 802, and 803. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information and product information) to the terminal device.

[0130] It should be noted that the software testing method provided in the embodiment of the present invention is generally executed by the electronic device 805 , and accordingly, a software testing device is generally disposed in the electronic device 805 .

[0131] It should be understood that Figure 8 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0132] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 of a terminal device suitable for implementing an embodiment of the present invention. Fig. 9 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0133] like Fig. 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0134] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.

[0135] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present invention are executed.

[0136] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0137] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0138] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be arranged in a processor, for example, they may be described as: a processor including an interface calling module, a data generating module, and a software testing module. The names of these modules do not constitute a limitation on the modules themselves in certain circumstances, for example, the interface calling module may also be described as a "module for calling an external interface corresponding to the software to be tested".

[0139] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: calling an external interface corresponding to the software to be tested; generating test data corresponding to the software to be tested according to the call result of the external interface; and testing the software to be tested according to the test data.

[0140] According to the technical solution of the embodiments of the present invention, when the software to be tested cannot be connected to the external interface and cannot obtain the external data source, or the external data source does not contain test data, it is possible to automatically generate test data based on the call result of the external interface, and test the software to be tested based on the test data, so that the software testing can continue, thereby improving the software testing efficiency.

[0141] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for software testing, characterized in that: include: Calling the external interface corresponding to the software to be tested, and determining whether the calling result includes the production data of the software to be tested; When the call result does not include the production data of the software to be tested, determining the data type of the test data corresponding to the software to be tested, and generating the test data corresponding to the software to be tested according to the data type; Testing the software to be tested according to the test data; The calling of the external interface corresponding to the software to be tested includes: The dynamic proxy interface corresponding to the software to be tested is determined, and the external interface is called through the dynamic proxy interface.

2. The method according to claim 1, characterized in that Generating test data corresponding to the software to be tested according to the data type includes: When the data type is a combination type, recursively query the combination type to determine a plurality of simple types corresponding to the combination type, wherein the test data of the combination type is generated by combining the test data of the plurality of simple types; According to the preset data corresponding to the simple type, test data corresponding to the software to be tested is generated.

3. The method according to claim 2, characterized in that The recursive querying of the combination type to determine a plurality of simple types corresponding to the combination type includes: The following steps are executed in a loop until multiple simple types corresponding to the combined type are determined or the recursive query level reaches a preset maximum depth: Taking the combination type as the current type to be queried; Determine the subtype corresponding to the current type to be queried using the Java reflection mechanism; Determine whether the subtype is the simple type, if yes, determine the preset data corresponding to the simple type; otherwise determine whether the recursive query level reaches a preset maximum depth, if no, use the subtype as the current type to be queried.

4. The method according to claim 2 or 3, characterized in that: The step of generating test data corresponding to the software to be tested according to the preset data corresponding to the simple type includes: According to the hierarchical relationship between the simple types obtained by the recursive query and the combined types, the preset data corresponding to the simple types are combined to generate the test data.

5. The method according to claim 1, characterized in that The test data is generated according to the identifier of the external interface and the data type.

6. The method according to claim 5, characterized in that Determining whether the identifier of the external interface includes a preset field indicating a target type; If yes, the test data is generated according to the attributes of the target type; the target type includes any one or more of the following: age, mobile phone number, date, user name and password.

7. The method according to claim 1, characterized in that Determining the data type of the test data corresponding to the software to be tested includes: The Java reflection mechanism is used to determine the data type of the test data.

8. The method according to claim 1, characterized in that The method further includes: When the calling result includes production data of the software to be tested, the production data is recorded to generate the test data.

9. The method according to claim 1, characterized in that: The method further includes: storing the test data in correspondence with the identifier of the external interface; The testing of the software to be tested according to the test data includes: According to the corresponding stored external interface identifier and test data, and the external interface identifier corresponding to the software to be tested, the test data corresponding to the software to be tested is called to test the software to be tested.

10. A software testing device, characterized in that: It includes an interface calling module, a data generating module and a software testing module; among which: The interface calling module is used to call the external interface corresponding to the software to be tested, and determine whether the calling result includes the production data of the software to be tested; The data generating module is used to determine the data type of the test data corresponding to the software to be tested when the interface calling module determines that the calling result does not include the production data of the software to be tested, and generate the test data corresponding to the software to be tested according to the data type; The software testing module is used to test the software to be tested according to the test data generated by the data generating module; The interface calling module is also used to: determine the dynamic proxy interface corresponding to the software to be tested, and call the external interface through the dynamic proxy interface.

11. An electronic device for software testing, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 9.

12. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Software test integrated control method and system

    CN104866426A