Function testing method and device
By expanding the values of input parameters and determining parameter combinations, the function is comprehensively tested, which solves the problems of insufficient coverage and difficulty in test case design in the existing technology, and achieves efficient function testing.
Patent Information
- Application Number
- CN202411514352.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-01-24
AI Technical Summary
Existing automated testing technologies cannot fully cover all test links of functions, resulting in hidden defects not being discovered, and test cases are difficult to design and maintenance costs.
Through the parameter sample provided by the user, the value of the parameters is expanded, the value collection of the parameters is obtained, the combination of each parameter is determined, and the combination of these parameters is used to test the function to ensure that each possible test link is covered.
All links of comprehensive testing functions are implemented, automatic analysis and detection of parameter combinations, intelligent generating parameter adjustment recommendations until full coverage, improving the coverage and efficiency of test cases.
Smart Images

Figure CN119357061A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a function testing method. Background Art
[0002] In the process of software development, automated testing is an important means to ensure code quality. Existing automated testing technologies mainly focus on the verification of specific functions and often lack comprehensive coverage of the internal links of functions, which may lead to some hidden defects not being discovered during the development process.
[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] 1. Insufficient coverage: Traditional automated testing cannot cover all test links of a function;
[0005] 2. Difficulty in test case design: It takes a lot of time and effort to design test cases that can cover all test links;
[0006] 3. High maintenance cost: With the iteration of software, test cases need to be constantly updated to adapt to new changes. Summary of the invention
[0007] In view of this, an embodiment of the present invention provides a method and device for function testing, which expands the values of input parameters through parameter samples provided by the user, obtains a value set of the input parameters, determines various parameter combinations, and uses various parameter combinations to test the function, which can comprehensively test all links of the function and ensure that every possible test link is covered.
[0008] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for function testing is provided, comprising:
[0009] According to the parameter samples of each input parameter in the function to be tested, the value of each input parameter is expanded to obtain a value set of the input parameter;
[0010] Determine each parameter combination of the function to be tested according to the value set of each input parameter;
[0011] The function to be tested is tested according to the various parameter combinations.
[0012] Optionally, based on parameter samples of each input parameter in the function to be tested, the value of each input parameter is expanded, including: based on parameter samples of each input parameter in the function to be tested, expanding each input parameter to at least one of the following values: null value, random value, boundary value, preset value.
[0013] Optionally, each parameter combination of the function to be tested is determined according to the value set of each input parameter, including: according to the value set of each input parameter, all input parameters in the function to be tested are arranged and combined to obtain each parameter combination of the function to be tested.
[0014] Optionally, testing the function to be tested according to the various parameter combinations includes:
[0015] Determine the expected test link corresponding to each of the parameter combinations to obtain an expected test link set;
[0016] Detect the function to be tested according to the various parameter combinations, and generate an access link set according to the test links corresponding to the parameter combinations with successful detection results;
[0017] By comparing the expected test link set and the access link set, a test result of the function to be tested is obtained.
[0018] Optionally, detecting the function to be tested according to the various parameter combinations includes: detecting the function to be tested using a backtracking algorithm according to the various parameter combinations.
[0019] Optionally, the method further includes: after testing the function to be tested according to the various parameter combinations, in response to the existence of a parameter combination that fails detection, adjusting the values of at least some input parameters in the parameter combination that fails detection, and then testing the function to be tested again according to the various parameter combinations.
[0020] According to a second aspect of an embodiment of the present invention, there is provided a function testing device, comprising:
[0021] A parameter expansion module, which expands the value of each input parameter according to the parameter samples of each input parameter in the function to be tested, and obtains a value set of the input parameter;
[0022] A parameter combination module determines each parameter combination of the function to be tested according to a value set of each input parameter;
[0023] The parameter testing module tests the function to be tested according to the various parameter combinations.
[0024] Optionally, the parameter extension module expands the value of each input parameter according to parameter samples of each input parameter in the function to be tested, including: according to parameter samples of each input parameter in the function to be tested, expanding each input parameter to at least one of the following values: a null value, a random value, a boundary value, and a preset value.
[0025] Optionally, the parameter combination module determines each parameter combination of the function to be tested according to the value set of each input parameter, including: according to the value set of each input parameter, all input parameters in the function to be tested are arranged and combined to obtain each parameter combination of the function to be tested.
[0026] Optionally, the parameter testing module tests the function to be tested according to each parameter combination, including:
[0027] Determine the expected test link corresponding to each of the parameter combinations to obtain an expected test link set;
[0028] Detect the function to be tested according to the various parameter combinations, and generate an access link set according to the test links corresponding to the parameter combinations with successful detection results;
[0029] By comparing the expected test link set and the access link set, a test result of the function to be tested is obtained.
[0030] The step of detecting the function to be tested according to the various parameter combinations includes: detecting the function to be tested by using a backtracking algorithm according to the various parameter combinations.
[0031] Optionally, the method further includes: after testing the function to be tested according to the various parameter combinations, in response to the existence of a parameter combination that fails detection, adjusting the values of at least some input parameters in the parameter combination that fails detection, and then testing the function to be tested again according to the various parameter combinations.
[0032] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for function testing, comprising:
[0033] one or more processors;
[0034] a storage device for storing one or more programs,
[0035] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.
[0036] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.
[0037] An embodiment of the above invention has the following advantages or beneficial effects: through the parameter samples provided by the user, the values of the input parameters are expanded to obtain the value set of the input parameters, and each parameter combination is determined. The function is tested using each parameter combination, and all links of the function can be comprehensively tested to ensure that each possible test link is covered. The parameter combination that fails to be detected is automatically analyzed and detected, and parameter adjustment suggestions are intelligently generated. The function is retested using the intelligently generated parameters until full coverage is achieved.
[0038] 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
[0039] Figure 1 It is a schematic diagram of the main process of the function testing method of an embodiment of the present invention;
[0040] Figure 2 It is a schematic diagram of the main process of obtaining function test results according to an embodiment of the present invention;
[0041] Figure 3 It is a schematic diagram of the main process of the test order processing function of an embodiment of the present invention;
[0042] Figure 4 is a schematic diagram of main modules of a function test apparatus according to an embodiment of the present invention;
[0043] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0044] Figure 6 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
[0045] 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.
[0046] According to one aspect of an embodiment of the present invention, a function testing method is provided.
[0047] Figure 1 FIG. 1 is a schematic diagram of the main flow of the method for function testing of an embodiment of the present invention. Figure 1 As shown, the method of function testing includes:
[0048] Step S101: according to the parameter samples of each input parameter in the function to be tested, expand the value of each input parameter to obtain the value set of the input parameter;
[0049] Step S102: determining each parameter combination of the function to be tested according to each value set of the input parameter;
[0050] Step S103: testing the function to be tested according to the various parameter combinations.
[0051] Optionally, based on parameter samples of each input parameter in the function to be tested, the value of each input parameter is expanded, including: based on parameter samples of each input parameter in the function to be tested, expanding each input parameter to at least one of the following values: null value, random value, boundary value, preset value.
[0052] Among them, parameter samples play a vital role in software testing. They refer to the input parameter examples provided by users in order to test a function. Take the function to be tested f(p1, p2) as an example, where p1 and p2 are the two parameters of the function, and the specific values of p1 and p2 provided by the user constitute the parameter sample. In actual testing, we are often not satisfied with testing only a single parameter sample, because such a test has a limited scope and it is difficult to find potential defects. Therefore, we need to expand the parameter sample, that is, expand the value of each parameter so that it can cover more test scenarios.
[0053] Among them, a function is a block of code that performs a specific task. It receives certain inputs (parameters), performs specific operations or calculations, and returns outputs (return values). Functions usually consist of the following parts:
[0054] 1) Function name: used to identify the function so that it can be used when calling it in the code;
[0055] 2) Parameters: data required by the function when executing;
[0056] 3) Function body: the actual code logic of the function, consisting of several statements;
[0057] 4) Return value: the result after the function body code is executed.
[0058] Among them, null values are boundary values, random values are intended to simulate real business situations as much as possible and traverse more scenarios. The number of function input parameters is user-defined and usually does not exceed 5 according to the specification.
[0059] Optionally, according to the parameter samples of each input parameter in the function to be tested, the value of each input parameter is expanded, including: according to different input parameter data types, more abundant input parameter values are expanded, exemplarily:
[0060] 1) Numeric type: For floating-point numbers, the value range is expanded to include positive numbers, negative numbers, zero, maximum values, minimum values, and minimum precision values; for integers, the value range is expanded to include positive integers, negative integers, zero, maximum values, and minimum values;
[0061] 2) String type: Extend the value length, including empty string, short string, long string, etc.; extend special characters, such as space, tab, newline, special symbols, etc.; extend regular expressions, such as strings containing specific characters and specific formats, etc.;
[0062] 3) Object type: Expand the combination of object attributes, such as empty attribute value, specific attribute value, specific relationship between attribute values, etc.; expand the value of nested objects, such as attribute values of nested objects, relationship between nested objects, etc.
[0063] The function testing method of this embodiment performs more comprehensive parameter expansion for different data types, and can generate richer test cases, thereby improving the coverage and testing efficiency of test cases, effectively discovering potential defects, and improving software quality.
[0064] Optionally, each parameter combination of the function to be tested is determined according to the value set of each input parameter, including: according to the value set of each input parameter, all input parameters in the function to be tested are arranged and combined to obtain each parameter combination of the function to be tested.
[0065] Optionally, determining each parameter combination of the function to be tested according to the value set of each input parameter includes: analyzing each input parameter, identifying the dependency relationship between the input parameters, and determining the parameter combination based on the relationship between the input parameters, for example:
[0066] 1) Combination strategy based on logical relationship: Design parameter combination strategy based on the logical relationship between input parameters;
[0067] 2) Combination strategy based on state association: Design parameter combination strategy based on the association between input parameters and internal state of the function.
[0068] For example, suppose there is an order processing function of an e-commerce platform. The input parameters of the function are: product ID, quantity, delivery address, and payment method. The relationship between the parameters is as follows:
[0069] Product ID and quantity: The product ID must exist in the database, and the quantity cannot exceed the inventory;
[0070] Delivery address: It must comply with the format specifications, such as including province, city, district, street, postal code, etc.
[0071] Payment method: You need to select a valid payment method.
[0072] The combination strategy based on logical relations is:
[0073] The product ID does not exist, the quantity is arbitrary, the delivery address is arbitrary, and the payment method is arbitrary (test exception handling);
[0074] The product ID exists, the quantity exceeds the inventory, the delivery address is arbitrary, and the payment method is arbitrary (testing insufficient inventory);
[0075] The product ID exists, the quantity is legal, the delivery address format is incorrect, and the payment method is arbitrary (the test address format is incorrect);
[0076] The product ID exists, the quantity is legal, the delivery address format is correct, and the payment method does not exist (test payment method error);
[0077] Combined strategy based on state association:
[0078] The product ID exists, the quantity is legal, the delivery address format is correct, the payment method exists, and the payment is successful (testing the normal process);
[0079] The product ID exists, the quantity is legal, the delivery address format is correct, the payment method exists, and the payment fails (test payment failed).
[0080] In this embodiment, by analyzing the dependencies between parameters and designing a more reasonable parameter combination strategy, more effective test cases can be generated, thereby improving the coverage and test efficiency of test cases, effectively discovering potential defects, and improving software quality.
[0081] Optionally, testing the function to be tested according to the various parameter combinations includes:
[0082] Determine the expected test link corresponding to each of the parameter combinations to obtain an expected test link set;
[0083] Detect the function to be tested according to the various parameter combinations, and generate an access link set according to the test links corresponding to the parameter combinations with successful detection results;
[0084] By comparing the expected test link set and the access link set, a test result of the function to be tested is obtained.
[0085] The test link refers to the code flow that is triggered by a specific parameter combination during the function testing process. The function starts from the entry and goes through a series of internal judgments, loops, calls and other logical operations until the function is executed or the result is returned.
[0086] The step of detecting the function to be tested according to the various parameter combinations includes: detecting the function to be tested by using a backtracking algorithm according to the various parameter combinations.
[0087] Figure 2 A schematic diagram showing a main process of obtaining a function test result that can be applied to an embodiment of the present invention;
[0088] like Figure 2 As shown, first determine the expected test link corresponding to each parameter combination to obtain the expected test link set, and before determining the expected test link set, initialize the access link set to be empty, wherein the access link set is the set of test links corresponding to the parameter combination that has been successfully detected;
[0089] The function to be tested is called according to each parameter combination and the test result is recorded. If the test result returns an error (for example: function execution exception, function return error type), the error information is recorded and the current parameter combination is skipped, and the subsequent parameter combinations are continued to be executed. The test link corresponding to the parameter combination with the detection result of successful detection is added to the access link set, and the values of at least part of the input parameters in the parameter combination that failed to detect are adjusted. Then, the function to be tested is tested again according to each parameter combination, and multiple parameter combinations are traversed, and the test is continuously performed (some parameters are prepared in advance, and it is believed that these parameters can be executed to this expected test link, but they are not executed). When all possible parameter combinations have been traversed and the expected test link cannot be executed, it means that there may be a problem with the function code. This result is fed back to the user, and the user is required to check whether there is a problem with the code. When the detection result corresponding to a certain parameter combination is successful detection, it is added to the access link set, and the expected test link set and the access link set are compared to obtain the test result of the function to be tested. The entire testing process does not require human intervention, and automated testing is realized.
[0090] Optionally, obtaining the test result of the function to be tested by comparing the expected test link set with the access link set comprises the following steps:
[0091] 1) Determine the sub-links and key nodes in the function to be tested based on the business logic and internal implementation of the function;
[0092] 2) Use various parameter combinations to test the function to be tested, and record the link information accessed during the test, including: function call sequence, parameter values, return values, and key nodes passed during execution, to obtain the access link set;
[0093] 3) After obtaining the access link set, compare it with the expected test link set. In addition to comparing the integrity of the entire link, you can also pay attention to the matching of sub-links, for example, check whether a sub-link appears in the access link set and whether the key nodes are correctly accessed. If a sub-link or key node mismatch is found, further analysis is required, which may be due to insufficient test case design, incorrect code implementation, or improper test environment configuration.
[0094] 4) Generate a detailed test report based on the comparison results, indicating which sub-links or key nodes are not covered or failed to match, and provide targeted feedback suggestions to guide developers to modify the code or optimize the test cases.
[0095] Among them, a sub-link is a series of interrelated code paths or fragments of execution steps passed during the function execution process. A complete link can be regarded as composed of multiple sub-links, and the sub-links can be divided based on the function's calling relationship, control flow structure or data dependency relationship; the key node is the execution point or judgment point in the function execution link that has an important influence or is decisive for the test results. The key node can be a location with a significant impact, such as function call, conditional judgment, loop structure, etc.
[0096] In this embodiment, sub-link matching can more accurately identify the differences between links, improve the accuracy and effectiveness of the test, and by focusing on sub-links and key nodes, the internal logic and potential problems of the function can be better understood.
[0097] Optionally, detecting the function to be tested according to the various parameter combinations includes: detecting the function to be tested using a retry mechanism according to the various parameter combinations, exemplarily:
[0098] Determine the relevant parameters of the retry mechanism, such as the maximum number of retries, retry interval, etc. For each parameter combination, perform the following steps:
[0099] 1) Call the function to be tested for the first time, pass in the current parameter combination, and get the call result;
[0100] 2) Check the call result. If the function to be tested throws an exception or returns an error status, enter the retry process;
[0101] 3) Set the maximum number of retries and the retry interval, call the function to be tested again, and pass in the current parameter combination to check whether the maximum number of retries has been reached. If not, wait for the specified retry interval and call the function to be tested again. Repeat the above steps until the test is successfully completed or the maximum number of retries has been reached.
[0102] 4) Regardless of whether the test succeeds or fails (after reaching the maximum number of retries), the test results are recorded, including success / failure status, time consumption, exception information, etc.
[0103] 5) Based on the test results, optimize parameters such as the maximum number of retries and retry interval.
[0104] Among them, setting the maximum number of retries can prevent infinite loops and needs to be set according to the specific application scenario. Setting the retry interval (the waiting time between each retry) can help reduce the pressure on system resources and may avoid the system avalanche effect caused by too frequent retries. The retry interval can be fixed or adjusted as needed.
[0105] Optionally, the method further includes: after testing the function to be tested according to the various parameter combinations, in response to the presence of a parameter combination that fails to be detected, adjusting the values of at least some input parameters in the parameter combination that fails to be detected, and then testing the function to be tested again according to the various parameter combinations, wherein the adjustment strategy includes:
[0106] 1) Adjustment based on experience: Based on experience, select appropriate parameter values for adjustment;
[0107] 2) Rule-based adjustment: select appropriate parameters for adjustment according to preset rules;
[0108] 3) Adjustment based on machine learning: Use machine learning algorithms to automatically learn the test case generation rules and make adjustments based on the learning results. For example:
[0109] Collect all parameter combinations that failed to be detected and the corresponding test results, extract features from these parameter combinations, such as parameter type, value range, value type, etc., select appropriate machine learning algorithms (such as decision trees, random forests, neural networks, etc.), use the extracted features to train the machine learning model to predict whether a new parameter combination may lead to a detection failure, and intelligently generate adjustment parameters based on the model's prediction results to continue function testing. This embodiment uses the parameter samples provided by the user to expand the values of the input parameters, obtain a set of values for the input parameters, determine each parameter combination, and use each parameter combination to test the function. It can comprehensively test all links of the function, ensure that every possible test link is covered, automatically analyze the parameter combination that failed to be detected, intelligently generate parameter adjustment suggestions, and retest the function using the intelligently generated parameters until it is fully covered.
[0110] Figure 3 A schematic diagram showing the main flow of a test order processing function to which an embodiment of the present invention can be applied;
[0111] like Figure 3As shown in the figure, an e-commerce platform has an order processing function processOrder, which is responsible for receiving user order requests and performing a series of operations such as creating orders, deducting inventory, and calculating shipping costs. The processOrder function receives multiple parameters, such as product ID, quantity, delivery address, etc.
[0112] The developer provides several typical order processing parameter samples, including valid order parameters and some edge cases, such as the product ID does not exist, the quantity is zero, etc., and then expands the value of each input parameter to obtain the value set of the input parameter;
[0113] Determine each parameter combination of the function to be tested according to the value set of each input parameter;
[0114] Testing the function to be tested according to the various parameter combinations, and recording the execution results of the various parameter combinations, including: successful order creation, insufficient inventory error, invalid address, etc.;
[0115] During the test execution process, all executed code links are monitored and recorded. When it is found that a specific link (exception handling when the product ID does not exist) is not executed, the developer is notified of the existence of the untested link and the possible cause analysis is provided. For example, it may be that the parameter combination does not contain the empty product ID. Parameter adjustment suggestions are intelligently generated. Based on the intelligently generated parameters, the function is tested again to finally confirm that all links are accessed. After the test is completed, a detailed test report is generated, indicating all executed links and problems found for the developer to review and fix.
[0116] In this embodiment, each logical branch of the processOrder function is fully tested through the automated testing strategy, ensuring the stability and reliability of the order processing function. Developers can discover and fix potential defects in a timely manner, thereby improving software quality and user satisfaction.
[0117] According to a second aspect of an embodiment of the present invention, a device for implementing the above method is provided.
[0118] Figure 4 Schematic diagram of main modules of a function test apparatus according to an embodiment of the present invention. Figure 4 As shown, the function test device 400 includes:
[0119] The parameter expansion module 401 expands the value of each input parameter according to the parameter samples of each input parameter in the function to be tested, and obtains the value set of the input parameter;
[0120] A parameter combination module 402 determines each parameter combination of the function to be tested according to each value set of the input parameter;
[0121] The parameter testing module 403 tests the function to be tested according to the various parameter combinations.
[0122] Optionally, the parameter extension module expands the value of each input parameter according to parameter samples of each input parameter in the function to be tested, including: according to parameter samples of each input parameter in the function to be tested, expanding each input parameter to at least one of the following values: a null value, a random value, a boundary value, and a preset value.
[0123] Optionally, the parameter combination module determines each parameter combination of the function to be tested according to the value set of each input parameter, including: according to the value set of each input parameter, all input parameters in the function to be tested are arranged and combined to obtain each parameter combination of the function to be tested.
[0124] Optionally, the parameter testing module tests the function to be tested according to each parameter combination, including:
[0125] Determine the expected test link corresponding to each of the parameter combinations to obtain an expected test link set;
[0126] Detect the function to be tested according to the various parameter combinations, and generate an access link set according to the test links corresponding to the parameter combinations with successful detection results;
[0127] By comparing the expected test link set and the access link set, a test result of the function to be tested is obtained.
[0128] The step of detecting the function to be tested according to the various parameter combinations includes: detecting the function to be tested by using a backtracking algorithm according to the various parameter combinations.
[0129] Optionally, the method further includes: after testing the function to be tested according to the various parameter combinations, in response to the existence of a parameter combination that fails detection, adjusting the values of at least some input parameters in the parameter combination that fails detection, and then testing the function to be tested again according to the various parameter combinations.
[0130] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for function testing, comprising:
[0131] one or more processors;
[0132] a storage device for storing one or more programs,
[0133] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.
[0134] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.
[0135] Figure 5 An exemplary system architecture 500 is shown to which the method for function testing or the apparatus for function testing according to the embodiment of the present invention can be applied.
[0136] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0137] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0138] The terminal devices 501 , 502 , and 503 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.
[0139] The server 505 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 501, 502, and 503. 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, product information - only an example) to the terminal device.
[0140] It should be noted that the function testing method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the function testing device is generally set in the server 505 .
[0141] It should be understood that Figure 5 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.
[0142] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6The 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.
[0143] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0144] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0145] 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 contains 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 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0146] 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. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, 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.
[0147] 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.
[0148] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor, for example, may be described as: a processor comprising: a parameter expansion module, which expands the value of each input parameter according to the parameter samples of each input parameter in the function to be tested to obtain a value set of the input parameter; a parameter combination module, which determines each parameter combination of the function to be tested according to each value set of the input parameter; and a parameter testing module, which tests the function to be tested according to each parameter combination. Among them, the names of these modules do not constitute a limitation on the module itself in some cases. For example, the parameter expansion module may also be described as a "module for generating a value set of the input parameter."
[0149] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it 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: according to the parameter samples of each input parameter in the function to be tested, expanding the value of each input parameter to obtain the value set of the input parameter; according to the value set of each input parameter, determining each parameter combination of the function to be tested; and testing the function to be tested according to each parameter combination.
[0150] According to the technical solution of the embodiment of the present invention, through the parameter samples provided by the user, the values of the input parameters are expanded, the value set of the input parameters is obtained, the various parameter combinations are determined, and the function is tested using the various parameter combinations. This can comprehensively test all links of the function to ensure that each possible test link is covered, automatically analyze and detect failed parameter combinations, intelligently generate parameter adjustment suggestions, and retest the function using the intelligently generated parameters until full coverage is achieved.
[0151] 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 function testing method, characterized in that: include: Expanding the value of each input parameter according to the parameter samples of each input parameter in the function to be tested to obtain a value set of the input parameter; Determine each parameter combination of the function to be tested according to the value set of each input parameter; The function to be tested is tested according to the various parameter combinations.
2. The method according to claim 1, characterized in that According to the parameter samples of each input parameter in the function to be tested, the value of each input parameter is expanded, including: According to the parameter samples of each input parameter in the function to be tested, at least one of the following values is expanded for each input parameter: a null value, a random value, a boundary value, and a preset value.
3. The method according to claim 1, characterized in that Determine each parameter combination of the function to be tested according to the value set of each input parameter, including: According to the value set of each input parameter, all input parameters in the function to be tested are arranged and combined to obtain various parameter combinations of the function to be tested.
4. The method according to claim 1, characterized in that Testing the function to be tested according to the various parameter combinations includes: Determine the expected test link corresponding to each of the parameter combinations to obtain an expected test link set; Detect the function to be tested according to the various parameter combinations, and generate an access link set according to the test links corresponding to the parameter combinations with successful detection results; By comparing the expected test link set and the access link set, a test result of the function to be tested is obtained.
5. The method according to claim 1, characterized in that Detecting the function to be tested according to the various parameter combinations includes: According to the various parameter combinations, a backtracking algorithm is used to detect the function to be tested.
6. The method according to claim 1, characterized in that The method further comprises: After the function to be tested is tested according to the various parameter combinations, in response to the existence of a parameter combination that fails to be detected, the values of at least some input parameters in the parameter combination that fails to be detected are adjusted, and then the function to be tested is tested again according to the various parameter combinations.
7. A function testing device, characterized in that: include: A parameter expansion module, which expands the value of each input parameter according to the parameter samples of each input parameter in the function to be tested, and obtains a value set of the input parameter; A parameter combination module determines each parameter combination of the function to be tested according to a value set of each input parameter; The parameter testing module tests the function to be tested according to the various parameter combinations.
8. An electronic device for function 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 6.
9. 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 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.