Black box test method and system without expected result injection

Through the combination of large language models and black box testing tools, test cases for state machine functions are generated and verified to detect logic error risks, solving the problems of low unit testing efficiency and insufficient automation level in the existing technology, and realizing an efficient black box Test automation.

CN118550836AInactive Publication Date: 2024-08-27ZHIZHISHENGONG (SHANGHAI) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410824109.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2024-03-14
Filing Date
2024-06-25
Publication Date
2024-08-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing unit testing tools require a lot of manual intervention, especially in verifying the accuracy of the expected output of automatically generated use cases, resulting in low testing efficiency and high false detection rate, and cannot effectively improve the automation level of black box testing.

Method used

Use a large language model to identify the input parameters and output parameters of the state machine function, combine with the black box testing tool to generate use case templates, and update the use case templates through random sampling to generate a large number of test cases to form a state transition table to detect logical error risks, including Source state, well state, island state and duplicate state.

Benefits of technology

It realizes unit testing without manual injection of expected results, significantly improves the testing efficiency of state machine functions, reduces manual workload, while ensuring test quality and improving the automation level of black box testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550836A
    Figure CN118550836A
Patent Text Reader

Abstract

The invention provides a black box test method and system without expected result injection, and the method comprises the steps: recognizing the parameter types of an input parameter and an output parameter of a to-be-tested state machine function, and extracting a variable of a common enumeration parameter type as a state machine variable; when the to-be-tested state machine function is executed, the pre-jump variable value jumps to the post-jump variable value based on the jump condition; generating a test case template by using a black box test tool; obtaining a value range of input parameters of a to-be-tested state machine function through the trained large-scale language model, and randomly sampling in the value range through the trained large-scale language model so as to update a use case template; repeating the process of random sampling and case template updating for a plurality of times to generate a plurality of test cases; executing the test case, obtaining an output parameter of the to-be-tested state machine function, forming an input-output pair of the test case, and forming a state transition table of the to-be-tested state machine function; and detecting and logic error risks through the trained large language model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer black box testing, and in particular to a black box testing method and system without the need for expected result injection. Background Art

[0002] Black box testing is a key link in software testing, and unit testing is a major application of black box testing, which is used to verify whether each function of the software code meets the test requirements. The main form of unit testing is to design test cases, assign values ​​to the input variables of the function to be tested, and then run the function to be tested to verify whether the function output is consistent with the expected output. Since each test case is only a point in the input space of the function, it is theoretically impossible to fully verify the correctness of the function in its input space (unless all variables constituting the input space are finitely discrete, and full coverage of the space can be achieved through traversal). It can only verify whether the output of the function under a single input point is correct. Therefore, a large number of test cases are often required to verify the function in order to improve the reliability and accuracy of the test.

[0003] However, since a large number of unit test cases need to be designed for each function to be tested, and the design goals of the function are difficult for the AI ​​algorithm to accurately understand, the expected output of each case cannot be automatically obtained by the algorithm and can only be given manually. In this way, unit testing requires a lot of manpower investment and the test efficiency will be greatly reduced. Therefore, in order to perform unit test verification more fully and efficiently, it is necessary to reduce manual operations as much as possible while ensuring the reliability of case verification.

[0004] Although there are many UT testing tools that can automatically generate use cases, including automatically estimating the expected output of the corresponding use case input, this estimation cannot be guaranteed to be absolutely reliable, resulting in the need for manual verification of whether the expected output of each use case is correct, and it cannot fundamentally improve the level of automation of unit testing.

[0005] There are many black box testing tools on the software market, which can be roughly divided into two categories. One is to provide a unit test framework, such as gTest, PyTest, etc. This type of unit test tool can automatically generate test function templates, automatically run test cases and give test conclusions, but it is necessary to manually design and write test cases in the test function, including assigning values ​​to the input of the function to be tested, setting expected outputs, etc. Therefore, this type of tool is mainly for various programming languages ​​to automatically generate various software modules for the process of black box unit testing, and does not involve intelligent algorithm generation of test cases. The other type is to add the function of automatically generating test cases on the basis of the above tools, such as Utbot, Testim, etc. This type of tool can formally realize the full automation of the entire unit test process, that is, the unit test results can be obtained without manual intervention. However, since these tools estimate the expected results of each test case through internal algorithms, the accuracy of the expected results cannot be guaranteed. Therefore, during use, it is often necessary to manually verify whether the expected results of each test case are correct and modify the wrong estimates. If the manual verification work is reduced, the test will have a higher false detection rate and missed detection rate for error recognition. In this way, in order to ensure the quality of testing, unit testing must retain a large amount of manual work, which cannot effectively improve testing efficiency. Summary of the invention

[0006] In order to overcome the above technical defects, the purpose of the present invention is to provide a black box testing method and system that can automatically generate a large number of test cases without the need for manual injection of expected results.

[0007] The present invention discloses a black box testing method without the need for expected result injection, comprising the following steps: selecting a state machine function to be tested and defining it as the state machine function to be tested; identifying the parameter types of input parameters and output parameters of the state machine function to be tested by a first type of tool, and extracting variables of the enumerated parameter type common to the input parameters and the output parameters as state machine variables; the state machine variables of the input parameters include a pre-jump variable value and a jump condition, and the state machine variables of the output parameters include a post-jump variable value; when the state machine function to be tested is executed, the pre-jump variable value jumps to the post-jump variable value based on the jump condition; using a black box testing tool to generate a test case template; obtaining the value range of the input parameters of the state machine function to be tested by a trained large language model, and randomly sampling within the value range by the trained large language model, Thereby updating the use case template; repeating the random sampling and updating process of the use case template for several times, thereby generating several test cases; executing the test case through a black box testing tool, obtaining the output parameters of the state machine function to be tested corresponding to the input parameters, and forming the input-output pairs of the test case; several input-output pairs of several test cases form a state transition table [MI, MO, C] of the state machine function to be tested; wherein MI represents the pre-jump variable value in the input parameter, MO represents the post-jump variable value in the output parameter, and C represents the jump condition; detecting and displaying the logic error risk in the state machine function to be tested based on the state transition table [MI, MO, C] through a trained large language model, wherein the logic error risk includes source state, well state, island state, repeated state, and repeated condition.

[0008] Preferably, the process of repeating the random sampling and updating the use case template for several times to generate several test cases includes: repeating the random sampling and updating the use case template for x times to generate x test cases; obtaining the proportion feedback value of the x times within the value range; if the proportion feedback value is less than the preset proportion value, increasing the number of x times until the proportion feedback value of the x times within the value range is greater than the preset proportion value.

[0009] Preferably, the trained large language model detects and displays the logic error risks in the state machine function to be tested based on the state transition table [MI, MO, C], including: if a state machine variable only exists in Mi but not in Mo, then the state referred to by the state machine variable is the source state; if a state machine variable only exists in Mo but not in Mi, then the state referred to by the state machine variable is the well state; taking any state machine variable as the origin, searching for several first-level state machine variables connected to the origin; then searching for the second-level state machine variables connected to several of the first-level state machine variables, traversing in sequence until the next-level state machine variables can no longer be connected; if there are still unsearched state machine variables at this time, then the unsearched state machine variables are island states.

[0010] Preferably, the trained large language model detects and displays the risk of logical errors in the state machine function to be tested based on the state transition table [MI, MO, C], including: encoding the execution code under each state machine variable, if the similarity between the encodings of the execution codes of two state machine variables is less than a preset similarity, then the two state machine variables are considered to be duplicate states.

[0011] Preferably, encoding the execution code under each state machine variable includes: encoding the execution code under each state machine variable through an Enbedding model in the trained large language model.

[0012] Preferably, the large language model after training detects and displays the risk of logical errors in the state machine function to be tested based on the state transition table [MI, MO, C], including: transforming the state machine function through the code generation model in the large language model after training: changing the progressive if conditional judgment to a parallel if conditional judgment; if there is a use case that makes two or more if conditional judgments in the parallel if conditional judgments be satisfied, it means that there are repeated conditions in the progressive if conditional judgments.

[0013] Preferably, obtaining the value range of the input parameters of the state machine function to be tested through the trained large language model includes: reading the code of the state machine function to be tested through the trained large language model to obtain the value range of the input parameters of the state machine function to be tested.

[0014] Preferably, obtaining the value range of the input parameters of the state machine function to be tested through the trained large language model includes: reading the description document of the state machine function to be tested through the trained large language model to obtain the value range of the input parameters of the state machine function to be tested.

[0015] Preferably, the first category of tools includes the black box testing tool and the trained large language model.

[0016] The present invention also discloses a black box testing system without the need for injection of expected results, which is used to implement the above-mentioned black box testing method without the need for injection of expected results, including a state machine function module, a black box testing tool and a trained large language model; a state machine function to be tested is selected in the state machine function module and defined as the state machine function to be tested; the parameter types of the input parameters and output parameters of the state machine function to be tested are identified by the black box testing tool or the trained large language model, and variables of the enumerated parameter type shared by the input parameters and the output parameters are extracted as state machine variables; the state machine variables of the input parameters include the pre-jump variable value and the jump condition, and the state machine variables of the output parameters include the post-jump variable value; when the state machine function to be tested is executed, the pre-jump variable value jumps to the post-jump variable value based on the jump condition; the black box testing tool is used to generate a test case template; the input of the state machine function to be tested is obtained by the trained large language model. The method comprises the following steps: determining a value range of a parameter, and randomly sampling within the value range through the trained large language model, thereby updating the use case template; repeating the random sampling and updating of the use case template for several times, thereby generating several test cases; executing the test case through the black box testing tool, obtaining the output parameters of the state machine function to be tested corresponding to the input parameters, and forming the input-output pairs of the test case; forming a state transition table [MI, MO, C] of the state machine function to be tested through several input-output pairs of several test cases; wherein MI represents the pre-jump variable value in the input parameter, MO represents the post-jump variable value in the output parameter, and C represents the jump condition; detecting and displaying the logic error risk in the state machine function to be tested based on the state transition table [MI, MO, C] through the trained large language model, wherein the logic error risk includes source state, well state, island state, repeated state, and repeated condition.

[0017] Compared with the prior art, the above technical solution has the following beneficial effects:

[0018] 1. The present invention uses a large language model to read the code and related documents of the state machine function to be tested, identifies the input parameter information, and combines the use case template given by the traditional black box testing tool to simulate the template code, randomly sample within the parameter value range, and update the use case input assignment, thereby randomly generating a large number of executable use cases; based on the logical characteristics of the state machine, effectively locate the developer's incorrect coding or missing coding when writing the state machine function, and realize the use case verification without giving the expected output, thereby effectively improving the unit test efficiency of the state machine function. While reducing the manual workload, the present invention can also ensure the test quality, thereby effectively improving the unit test efficiency of the black box test under the premise of ensuring the test quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A flowchart of a preferred embodiment of a black box testing method without injection of expected results provided by the present invention. DETAILED DESCRIPTION

[0020] The advantages of the present invention are further described below in conjunction with the accompanying drawings and specific embodiments.

[0021] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0022] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0023] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0024] In the description of the present invention, it is necessary to understand that the terms "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.

[0025] In the description of the present invention, unless otherwise specified and limited, it should be noted that the terms "installed", "connected" and "connected" should be understood in a broad sense. For example, it can be a mechanical connection or an electrical connection, or it can be the internal connection between two components. It can be a direct connection or an indirect connection through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to the specific circumstances.

[0026] In the following description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present invention, and have no specific meanings. Therefore, "module" and "component" can be used interchangeably.

[0027] See attached Figure 1 The present invention discloses a black box testing method without the need for expected result injection, which mainly includes the following processes: selecting a state machine function (function to be tested), generating a test case template, expanding the test case (generating a large number of test cases), executing the test case to generate a state transition table, and detecting logic errors based on the state transition table. Specifically:

[0028] The state machine function (function to be tested) selection process, first, (the user) selects the state machine function to be tested and defines it as the state machine function to be tested. (More practical level,) and manually select to trigger the state machine black box test check. In order to facilitate the subsequent assignment of parameters in the use case template, it is also necessary to know the parameter types of input parameters and output parameters. That is, the parameter types of the input parameters and output parameters of the state machine function to be tested are identified through the first type of tool, and the variables of the enumerated parameter types shared by the input parameters and output parameters are extracted as state machine variables. Among them, the state machine variable of the input parameter includes the variable value before the jump and the jump condition, and the state machine variable of the output parameter includes the variable value after the jump. When the state machine function to be tested is executed, the variable value before the jump jumps to the variable value after the jump based on the jump condition. For example, the state machine variable of the input parameter includes the variable value before the jump is 2, and the state machine variable of the output parameter includes the variable value after the jump is 5. The jump condition is the first jump condition. When the first jump condition is met, the input "2" jumps to the output "5". A more concrete example: the state machine variable of the input parameter includes the variable value before the jump as "single mouse right button", the state machine variable of the output parameter includes the variable value after the jump as "open document 1", and the jump condition is "the mouse cursor is within the preset area", so the jump logic is: if the mouse cursor is within the preset area, then single mouse right button can open document 1.

[0029] In the process of generating the use case template, the present invention preferably uses the existing black box testing tools to generate the test use case template, such as gTest, PyTest, Utbot, Testim, etc. The use case template includes the function name of the state machine function to be tested, the assignment statement of the input parameters, the execution statement for running the state machine function to be tested, etc. Among them, the format of the assignment statement corresponds to the parameter type of the input parameters and output parameters of the above-mentioned state machine function, for example, integer, floating point, enumeration, etc. That is, if the parameter type of the input parameter and output parameter of the state machine function is integer, then only the value of the integer parameter type can be assigned when assigning; if the parameter type of the input parameter and output parameter of the state machine function is floating point, then only the value of the floating point parameter type can be assigned when assigning.

[0030] During the test case expansion (generating a large number of test cases), the value range of the input parameters of the state machine function to be tested is obtained through the trained large language model (specifically, the prompt command can be used), and random sampling is performed within the value range through the trained large language model to update the test case template. Repeat the process of random sampling and updating the test case template several times to generate several test cases.

[0031] Execute test cases to generate a state transition table process, execute the test cases through a black box test tool, obtain the output parameters of the state machine function to be tested that correspond to the input parameters, and form input-output pairs of the test cases; several input-output pairs of several test cases form the state transition table [MI, MO, C] of the state machine function to be tested; among them, MI represents the pre-jump variable value in the input parameter, MO represents the post-jump variable value in the output parameter, and C represents the jump condition.

[0032] The process of detecting logical errors based on the state transition table is to detect and display the logical error risks in the state machine function to be tested based on the state transition table [MI, MO, C] through the trained large language model. The logical error risks include source state, well state, island state, repeated state, and repeated conditions.

[0033] The state machine design logic can be understood as a directed connected graph, where each jump state is a "node" in the directed connected graph, and the jump conditions between each jump state are the "edges" between each node.

[0034] 1) The source state is a state that can only be transferred to other states. No state can be transferred back to the source state, that is, "only out but not in", usually the initial state;

[0035] 2) The well state is a state that cannot be transferred to other states and can only be entered by transferring from other states, that is, "only in but not out", usually a terminal state;

[0036] 3) If there is a set of states that are only connected to each other but not to other states, then this set of states is an island state. Under normal conditions, the jump of a state machine function should correspond to a connected directed graph. If there is an island state, it means that the state jump condition (i.e. the edge of the directed connected graph mentioned above) is missing. If there are originally two sets of unconnected states, then they should be implemented by two state machine functions, and should not appear in the same state machine function.

[0037] If there are multiple source states, well states, or island states, you need to confirm whether they are consistent with the design. It is possible that the normal state with both input and output is implemented as a source state or a well state due to missing coding. For example, when writing a state machine function, if you omit the jump conditions between certain states, it will lead to the appearance of source states, well states, and island states.

[0038] 4) If the actions corresponding to two states (specifically, the code executed in the state) are the same, then the two states are duplicate states. When writing conditional statements for state jumps, sometimes the codes executed in different states are different in just a few parameter values, and there are often many copy and paste operations. If the modification to the target state after pasting is omitted, the executed code in the two states will be the same, resulting in duplicate states.

[0039] 5) If a state corresponds to a jump condition that may transfer to two different states, then the jump condition is a duplicate condition. When writing a conditional statement for state jump, sometimes the condition involves many judgments, and some condition boundary values ​​may be omitted during the copy and paste modification process, resulting in state overlap or state missing in the jump condition space.

[0040] The present invention combines the existing black box testing tools and large language models, and provides a use case template for testing a state machine function through the existing black box testing tools; the large language model is trained to enable it to extract the value range of the input parameter from the state machine function, thereby generating a large number of test cases within the value range; based on the characteristics of the state machine function, the state jump table can be obtained by executing the large number of test cases, and based on the design logic of the state machine (a directed connectivity graph), the risk of logical errors in the state jump table can be detected.

[0041] Specifically, the trained large language model detects and displays the logical error risks of source states, well states, island states, repeated states, and repeated conditions in the state machine function to be tested based on the state transition table [MI, MO, C], including:

[0042] 1) If a state machine variable only exists in Mi but not in Mo, the state referred to by the state machine variable is the source state;

[0043] 2) If a state machine variable only exists in Mo but not in Mi, then the state referred to by the state machine variable is the well state;

[0044] 3) Taking any state machine variable as the origin, search for several first-level state machine variables connected to the origin; then search for the second-level state machine variables connected to several first-level state machine variables, and traverse in sequence until the next-level state machine variables can no longer be connected; if there are still unsearched state machine variables at this time, then the unsearched state machine variables are island states.

[0045] 4) Encode the execution code under each state machine variable. If the similarity between the encodings of the execution codes of two state machine variables is less than a preset similarity, the two state machine variables are considered to be duplicate states. Preferably, the execution code under each state machine variable can be encoded by an Enbedding model in a trained large language model.

[0046] 5) The state machine function is transformed through the code generation model in the trained large language model: the progressive if conditional judgment is changed to a parallel if conditional judgment; if there is a use case that satisfies two or more if conditional judgments in the parallel if conditional judgment, it means that there are repeated conditions in the progressive if conditional judgment. For example:

[0047] Judge If (the first level judgment statement in the progressive if conditional judgment): b>0&b<=20 (but in fact the correct boundary value of this condition is 10, not 20);

[0048] If yes, then state 1 jumps to state 2;

[0049] If not, further judge if (the second level judgment statement in the progressive if conditional judgment): b>10&b<20;

[0050] If yes, then state 1 jumps to state 3;

[0051] If not, state 1 jumps to state 4.

[0052] Due to the error in the boundary value in the previous judgment statement, there is a repeated interval between the first-level judgment statement and the second-level judgment statement. For the progressive if conditional judgment, if the first-level judgment statement is satisfied, the second-level judgment statement will not be entered. Therefore, in the case of the above-mentioned error boundary value, if b=15, then directly state 1→state 2, while under normal circumstances, state 1 should jump to state 3.

[0053] Therefore, the present invention here modifies the above-mentioned progressive if conditional judgment into a parallel if conditional judgment, that is:

[0054] Judge if: b>0&b<=20;

[0055] If yes, state 1 jumps to state 2.

[0056] And judge if: b>10&b<20;

[0057] If yes, state 1 jumps to state 3.

[0058] And judge if: b<=0||b>20;

[0059] If yes, state 1 jumps to state 4.

[0060] In this case, if b=15, the execution of state 1 jumping to state 2 and state 1 jumping to state 3 will occur simultaneously, so that the logical risk error of the repeated condition can be detected.

[0061] It should be noted that the detected logical risks do not represent definite errors and need to be verified by humans after presentation. Compared with the use cases of manual verification input in the prior art, the workload of result verification is reduced by several orders of magnitude.

[0062] Preferably, in the process of "repeating the process of random sampling several times, updating the use case template, and thus generating several test cases", since it is impossible to set the exact number of random sampling times at one time to fill the value range, that is, to ensure that the number of use case templates is sufficient to cover all optional situations within the value range, at this time, we can use the feedback value to adjust the number of random samplings in real time. Specifically: repeat the process of random sampling x times, updating the use case template, and thus generating x test cases; obtain the feedback value of the proportion of x times within the value range; if the feedback value of the proportion is less than the preset proportion value, increase the number of times by x, until the feedback value of the proportion of x times within the value range is greater than the preset proportion value.

[0063] Preferably, obtaining the value range of the input parameters of the state machine function to be tested through the trained large language model can be achieved by reading the code of the state machine function to be tested with the trained large language model, or by reading the description document of the state machine function to be tested with the trained large language model.

[0064] Preferably, in the present invention, the first category of tools preferably includes black box testing tools or trained large language models.

[0065] The present invention also discloses a black box testing system without the need for injection of expected results, which is used to implement the above-mentioned black box testing method without the need for injection of expected results, and includes a state machine function module, a black box testing tool and a trained large language model.

[0066] A state machine function to be tested is selected in the state machine function module and defined as the state machine function to be tested; the parameter types of the input parameters and output parameters of the state machine function to be tested are identified by a black box testing tool or a trained large language model, and variables of the enumerated parameter type common to the input parameters and the output parameters are extracted as state machine variables; the state machine variables of the input parameters include the variable value before the jump and the jump condition, and the state machine variables of the output parameters include the variable value after the jump; when the state machine function to be tested is executed, the variable value before the jump jumps to the variable value after the jump based on the jump condition;

[0067] Use black box testing tools to generate test case templates;

[0068] The value range of the input parameter of the state machine function to be tested is obtained through the trained large language model, and random sampling is performed within the value range through the trained large language model to update the use case template; the process of random sampling and updating the use case template is repeated several times to generate several test cases;

[0069] Execute the test case through the black box test tool to obtain the output parameters of the state machine function to be tested corresponding to the input parameters, and form the input-output pair of the test case; several input-output pairs of several test cases form the state transition table [MI, MO, C] of the state machine function to be tested; wherein MI represents the pre-jump variable value in the input parameter, MO represents the post-jump variable value in the output parameter, and C represents the jump condition;

[0070] The trained large language model is used to detect and display the logic error risks in the state machine function to be tested based on the state transition table [MI, MO, C]. The logic error risks include source state, well state, island state, repeated state, and repeated conditions.

[0071] The purpose of the present invention is to analyze the state jump logic by performing a large amount of random sampling on the function input based on the logical requirements of the state machine function. Since the mathematical basis of the state machine is a directed graph, it is possible to determine whether the state machine design has a logical defect error based on the logical properties of the directed graph. The method does not require manual given function expected results, and can fully automatically verify the errors of the state machine. Generally speaking, a state machine can be expressed as a complete directed connected graph, and the state must meet connectivity, mutual difference and completeness. The so-called connectivity means that there should be no isolated state, and there is no jump connection with other states. The so-called mutual difference includes state mutual difference and condition mutual difference. State mutual difference means that the function code (action) executed in different states should be different, otherwise it can be completely merged into one state; and condition mutual difference means that a state should have only one jump target state under a certain condition. The so-called completeness means that there should be a clear jump target in the parameter space of the jump condition, otherwise there will be no jump target when a certain jump condition appears in the state, resulting in the collapse of the code function. If a state machine function does not meet the above three characteristics, it is often caused by the developer's coding errors. Therefore, detection based on these three characteristics can accurately locate the developer's coding errors.

[0072] It should be noted that this method is not intended to verify the functionality of a state machine function. The functionality of a function can only be verified by humans by confirming its expected output based on design requirements. However, this method can effectively detect logical errors (coding implementation errors) in state machine functions.

[0073] It should be noted that the embodiments of the present invention have better practicability and do not impose any form of limitation on the present invention. Any technician familiar with the field may use the technical content disclosed above to change or modify it into an equivalent effective embodiment. However, any modification or equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of the technical solution of the present invention.

Claims

1. A black box testing method without the need for expected result injection, characterized in that: The steps include: A state machine function to be tested is selected and defined as the state machine function to be tested; the parameter types of the input parameters and output parameters of the state machine function to be tested are identified by the first type of tool, and variables of the enumerated parameter type common to the input parameters and the output parameters are extracted as state machine variables; the state machine variables of the input parameters include the variable value before the jump and the jump condition, and the state machine variables of the output parameters include the variable value after the jump; When executing the state machine function to be tested, the pre-jump variable value jumps to the post-jump variable value based on the jump condition; Use black box testing tools to generate test case templates; Obtaining the value range of the input parameter of the state machine function to be tested through the trained large language model, and randomly sampling within the value range through the trained large language model, thereby updating the use case template; repeating the random sampling and updating of the use case template several times, thereby generating several test cases; Execute the test case through a black box test tool, obtain the output parameters of the state machine function to be tested corresponding to the input parameters, and form the input-output pairs of the test case; several input-output pairs of several test cases form the state transition table [MI, MO, C] of the state machine function to be tested; wherein MI represents the pre-jump variable value in the input parameter, MO represents the post-jump variable value in the output parameter, and C represents the jump condition; The trained large language model is used to detect and display the logic error risks in the state machine function to be tested based on the state transition table [MI, MO, C], and the logic error risks include source state, well state, island state, repeated state, and repeated conditions.

2. The black box testing method without expected result injection according to claim 1, characterized in that: The process of repeating the random sampling and updating the use case template for several times to generate several test cases includes: Repeat the random sampling and the updating of the use case template x times, thereby generating x test cases; Obtaining a feedback value of the proportion of the x times within the value range; If the proportion feedback value is less than the preset proportion value, the number of x times is increased until the proportion feedback value of the x times within the value range is greater than the preset proportion value.

3. The black box testing method without expected result injection according to claim 1, characterized in that: The large language model after training detects and displays the logic error risk in the state machine function to be tested based on the state transition table [MI, MO, C], including: If a state machine variable only exists in Mi but not in Mo, the state referred to by the state machine variable is the source state; If a state machine variable only exists in Mo but not in Mi, the state referred to by the state machine variable is the well state; Taking any state machine variable as the origin, searching for a number of first-level state machine variables connected to the origin; Then search for the second-level state machine variables connected to the plurality of the first-level state machine variables, and traverse in sequence until the next-level state machine variables can no longer be connected; If there are still unsearched state machine variables at this time, the unsearched state machine variables are island states.

4. The black box testing method without expected result injection according to claim 1, characterized in that: The large language model after training detects and displays the logic error risk in the state machine function to be tested based on the state transition table [MI, MO, C], including: The execution code under each state machine variable is encoded. If the similarity between the encodings of the execution codes of two state machine variables is less than a preset similarity, it is considered that the two state machine variables are in a repeated state.

5. The black box testing method without expected result injection according to claim 4, characterized in that: The encoding of the execution code under each state machine variable includes: The execution code under each state machine variable is encoded through the Enbedding model in the trained large language model.

6. The black box testing method without expected result injection according to claim 1, characterized in that: The large language model after training detects and displays the logic error risk in the state machine function to be tested based on the state transition table [MI, MO, C], including: The state machine function is transformed by using the code generation model in the trained large language model: the progressive if conditional judgment is changed to a parallel if conditional judgment; If there is a use case that satisfies two or more if conditional judgments in the parallel if conditional judgment, it means that there are repeated conditions in the progressive if conditional judgment.

7. The black box testing method without expected result injection according to claim 1, characterized in that: The value range of the input parameter of the state machine function to be tested obtained by the trained large language model includes: The code of the state machine function to be tested is read through the trained large language model to obtain the value range of the input parameter of the state machine function to be tested.

8. The black box testing method without expected result injection according to claim 1, characterized in that: The value range of the input parameter of the state machine function to be tested obtained by the trained large language model includes: The description document of the state machine function to be tested is read through the trained large language model to obtain the value range of the input parameter of the state machine function to be tested.

9. The black box testing method without expected result injection according to claim 1, characterized in that: The first category of tools includes the black box testing tool and the trained large language model.

10. A black box testing system without expected result injection, used to implement the black box testing method without expected result injection as described in any one of claims 1 to 9, characterized in that: Includes state machine function modules, black box testing tools, and trained large language models; A state machine function to be tested is selected in the state machine function module and defined as the state machine function to be tested; the parameter types of the input parameters and output parameters of the state machine function to be tested are identified by the black box testing tool or the trained large language model, and variables of the enumerated parameter type common to the input parameters and the output parameters are extracted as state machine variables; the state machine variables of the input parameters include the variable value before the jump and the jump condition, and the state machine variables of the output parameters include the variable value after the jump; When executing the state machine function to be tested, the pre-jump variable value jumps to the post-jump variable value based on the jump condition; Generate a test case template using the black box testing tool; Obtaining the value range of the input parameter of the state machine function to be tested through the trained large language model, and randomly sampling within the value range through the trained large language model, thereby updating the use case template; repeating the random sampling and updating of the use case template several times, thereby generating several test cases; Execute the test case through the black box test tool, obtain the output parameters of the state machine function to be tested corresponding to the input parameters, and form the input-output pairs of the test case; several input-output pairs of several test cases form the state transition table [MI, MO, C] of the state machine function to be tested; wherein MI represents the pre-jump variable value in the input parameter, MO represents the post-jump variable value in the output parameter, and C represents the jump condition; The trained large language model is used to detect and display the logic error risks in the state machine function to be tested based on the state transition table [MI, MO, C], and the logic error risks include source state, well state, island state, repeated state, and repeated conditions.