Method, device, equipment and readable storage medium for obtaining verification data

By converting the expression to be tested into a readable expression and calling a preset script, the problem of inefficient acquisition of expression verification data in automated tests is solved, and fast and accurate acquisition of verification data is achieved.

CN114077545BActive Publication Date: 2025-03-25SUPCON TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111370228.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2025-03-25
Estimated Expiration
2041-11-18

AI Technical Summary

Technical Problem

In the automated testing process, the verification data acquisition of expressions is inefficient and prone to errors, especially because the expressions are complex in form and have wide coverage.

Method used

By obtaining the data to be tested, including the expression to be tested and the data source information, the expression to be tested is converted into a readable expression, and using the readable expression and data source information as script parameters, the preset script is called to obtain the verification data.

Benefits of technology

This enables rapid and accurate acquisition of verification data, improves testing efficiency and reduces errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114077545B_ABST
    Figure CN114077545B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a method, apparatus, device and readable storage medium for obtaining verification data, obtaining data source information, obtaining a readable expression of the expression to be tested, using the readable expression and data source information as script parameters, calling a first preset script, and obtaining verification data of the expression to be tested, wherein the verification data includes a target result and a solution set corresponding to the target result, and the target result includes whether the readable expression holds and / or does not hold. Since the expression to be tested includes a variable to be tested and a fixed quantity to be tested, the data source information includes a correspondence between the variable to be tested and the variable type, and the variable type indicates a value range, the first preset script is used to obtain the values ​​of each variable to be tested with the target result as a condition, as a solution set corresponding to the target result, therefore, the method can automatically obtain verification data of the expression to be tested by converting the expression to be tested into a readable expression and using the first preset script.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device, equipment and readable storage medium for obtaining verification data. Background Art

[0002] In the automated testing process, verification data is one of the important factors to ensure the correctness and efficiency of the test, especially in the expression testing process. Due to the complexity of the expression and its wide coverage, manually calculating the verification data of the expression is inefficient and prone to errors. Therefore, how to quickly and accurately obtain verification data is an urgent problem to be solved in the expression testing process. Summary of the invention

[0003] The present application provides a method, device, equipment and readable storage medium for obtaining verification data, as follows:

[0004] A method for obtaining verification data, comprising:

[0005] Acquire data to be tested, wherein the data to be tested includes an expression to be tested and data source information, wherein the expression to be tested includes a variable to be tested and a fixed quantity to be tested; the data source information includes a correspondence between the variable to be tested and the variable type, and the variable type of the variable to be tested indicates a value range of the variable to be tested;

[0006] Convert the expression to be tested into a readable expression;

[0007] With the readable expression and the data source information as script parameters, the first preset script is called to obtain verification data of the expression to be tested; the verification data includes a target result and a solution set corresponding to the target result, and the first preset script is used to obtain the values ​​of each variable to be tested with the target result as a condition, as a solution set corresponding to the target result, and the target result includes whether the readable expression is true and / or false.

[0008] Optionally, converting the expression to be tested into a readable expression includes:

[0009] From the expression to be tested, identifying the character string of each variable to be tested and the character string of each fixed quantity to be tested;

[0010] According to the character string of each variable to be measured, the script character string of each variable to be measured and the order of the script character string are obtained; the script character string of the variable to be measured is an expression form applied to the first preset script;

[0011] According to the character string of each fixed quantity to be measured, a script character string of each fixed quantity to be measured is obtained; the script character string of the fixed quantity to be measured is an expression form applied to the first preset script;

[0012] A readable expression of the expression to be tested is generated according to the script character string of each of the variables to be tested and the script character string of each of the fixed quantities to be tested.

[0013] Optionally, according to the character string of the target variable to be measured, the script character string of the target variable to be measured and the order of the script character string are obtained, and the target variable to be measured is any variable to be measured, including:

[0014] Using a regular expression to match the target variable to be measured to obtain a script string that matches the target variable to be measured;

[0015] Performing generalization processing on the script character string that matches the target variable to be measured, and using the generalization processing result as the script character string of the target variable to be measured;

[0016] The order of the target variable to be tested in a variable sequence is obtained as the order of the script string of the target variable to be tested, wherein the variable sequence includes the variables to be tested in the expression to be tested arranged in a front-to-back order.

[0017] Optionally, according to a character string of a target fixed quantity to be measured, a script character string of the target fixed quantity to be measured is obtained, wherein the target fixed quantity to be measured is any fixed quantity to be measured, including:

[0018] If the target fixed quantity to be measured is a function or an operator, the script string corresponding to the target fixed quantity to be measured in the preset conversion dictionary is used as the script string of the target fixed quantity to be measured; the conversion dictionary includes a mapping relationship between the string of each fixed quantity to be measured and the script string;

[0019] If the target fixed quantity to be measured is a constant, the character string of the target fixed quantity to be measured is used as the script character string of the target fixed quantity to be measured.

[0020] Optionally, obtaining the data to be tested includes:

[0021] According to a preset test document template, a test document is obtained, wherein the test document includes a preset first-category script parameter field, wherein the first-category script parameter field includes an original expression and original data source information; wherein the original expression is obtained by orthogonally combining preset test points;

[0022] The original expression is used as the expression to be tested, and the original data source information corresponding to the original expression is used as the data source information.

[0023] Optionally, before the first preset script is called with the readable expression and the data source information as script parameters to obtain the verification data of the expression to be tested, the method further includes:

[0024] Verify whether the readable expression meets the preset correctness condition.

[0025] The step of taking the readable expression and the data source information as script parameters, calling a first preset script, and obtaining verification data of the expression to be tested includes:

[0026] If the readable expression satisfies the correctness condition, the first preset script is called with the readable expression and the data source information as script parameters to obtain verification data of the expression to be tested.

[0027] A device for obtaining verification data, comprising:

[0028] A test data acquisition unit, used to acquire data to be tested, wherein the data to be tested includes an expression to be tested and data source information, wherein the expression to be tested includes a variable to be tested and a fixed quantity to be tested; the data source information includes a correspondence between the variable to be tested and the variable type, and the variable type of the variable to be tested indicates a value range of the variable to be tested;

[0029] A readable expression acquisition unit, used for converting the expression to be tested into a readable expression;

[0030] A verification data acquisition unit is used to call a first preset script with the readable expression and the data source information as script parameters to obtain verification data of the expression to be tested; the verification data includes a target result and a solution set corresponding to the target result, and the first preset script is used to obtain the values ​​of each variable to be tested with the target result as a condition, as a solution set corresponding to the target result, and the target result includes whether the readable expression is true and / or false.

[0031] Optionally, the readable expression acquisition unit is used to convert the expression to be tested into a readable expression, including: the readable expression acquisition unit is specifically used to:

[0032] From the expression to be tested, identifying the character string of each variable to be tested and the character string of each fixed quantity to be tested;

[0033] According to the character string of each variable to be measured, the script character string of each variable to be measured and the order of the script character string are obtained; the script character string of the variable to be measured is an expression form applied to the first preset script;

[0034] According to the character string of each fixed quantity to be measured, a script character string of each fixed quantity to be measured is obtained; the script character string of the fixed quantity to be measured is an expression form applied to the first preset script;

[0035] A readable expression of the expression to be tested is generated according to the script character string of each of the variables to be tested and the script character string of each of the fixed quantities to be tested.

[0036] A verification data acquisition device, comprising: a memory and a processor;

[0037] The memory is used to store programs;

[0038] The processor is used to execute the program to implement each step of the method for obtaining verification data.

[0039] A readable storage medium stores a computer program, which, when executed by a processor, implements each step of a method for obtaining verification data.

[0040] It can be seen from the above technical scheme that the verification data acquisition method, device, equipment and readable storage medium provided in the embodiment of the present application acquire and data source information, acquire the readable expression of the expression to be tested, use the readable expression and data source information as script parameters, call the first preset script, and obtain the verification data of the expression to be tested, wherein the verification data includes the target result and the solution set corresponding to the target result, and the target result includes whether the readable expression is true and / or false. Since the expression to be tested includes the variables to be tested and the fixed quantity to be tested, the data source information includes the correspondence between the variables to be tested and the variable type, and the variable type indicates the value range, the first preset script is used to obtain the values ​​of each variable to be tested with the target result as the condition, as the solution set corresponding to the target result, therefore, the method can automatically obtain the verification data of the expression to be tested by converting the expression to be tested into a readable expression and using the first preset script. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0042] Figure 1 A flowchart of a specific implementation method of a method for obtaining verification data provided in an embodiment of the present application;

[0043] Figure 2 A schematic diagram of a test document template provided in an embodiment of the present application;

[0044] Figure 3 A flowchart of a method for obtaining verification data provided in an embodiment of the present application;

[0045] Figure 4 A schematic diagram of the structure of a verification data acquisition device provided in an embodiment of the present application;

[0046] Figure 5 A schematic diagram of the structure of a verification data acquisition device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0048] A method for obtaining verification data provided in an embodiment of the present application is applied to but not limited to obtaining verification data of an expression to be tested, wherein the verification data is used to verify whether the result of the software to be tested running the expression to be tested is correct. This embodiment is applied to but not limited to the process of obtaining verification data in the automatic testing flow of the test points of the industrial control software, wherein the test points include but are not limited to operators, variable types, and functions. It can be seen that the test points include the smallest operation unit that implements the software function.

[0049] Figure 1 A method for obtaining verification data provided in an embodiment of the present application is as follows: Figure 1 As shown, the method includes:

[0050] 101. Obtain the data to be tested.

[0051] In this embodiment, the data to be tested includes expressions to be tested and data source information, and the expressions to be tested include variables to be tested and fixed quantities to be tested. The fixed quantities to be tested include operators, constants, and functions, and the data source information includes the correspondence between the order of the variables to be tested and the variable types, wherein the variable types indicate the value range of the variables to be tested.

[0052] Optionally, the data to be tested is obtained from a test document, the test document template is a preset Excel document, and the header of the test document template indicates various preset script parameter fields corresponding to the same test case, and the script parameter fields include but are not limited to: identification, original expression, data source information (including data source address and data source type), first solution set, second solution set, and test results. It should be noted that the script parameter fields are obtained by parameter extraction, and the details can be referred to the prior art.

[0053] like Figure 2 As shown in the figure, in the scenario of alarm function test, the script parameter fields included in the header of the test document template include: alarm name (AlarmName), alarm ID (AlarmID), expression (Expression), data source (TagNamei), data source type (TagTypei), first solution set (TagValue i_generate), and second solution set (TagValuei_ingenerate). It also includes: test result result and failed case error reason note.

[0054] The original expression can be composed of operators, constants, variables and functions, where the operators at least include relational operators, and the expression has true and false solution sets. For example, Figure 2 In the expression 1 shown in (the expression in the test case in the first row under the table header), "EXP_INT51" and "EXP_INT52" are variables, "INT" indicates the variable type, "TAG("var: / / [variable name]")" is a preset custom function, "+" is the addition operator, and ">" is the greater than relational operator. The alarm name and alarm ID are both preset field values, please refer to the prior art for details.

[0055] Where i is less than or equal to n, n is the number of variables in the expression, TagName i represents the data source of the i-th variable in the original expression, and TagType i represents the type of the data source of the i-th variable in the original expression. The first solution set (TagValue i_generate) is the value of the i-th variable in expression 1 when expression 1 is true, and the second solution set (TagValue i_ingenerate) is the value of the i-th variable in the original expression when expression 1 is false.

[0056] It should be noted that Figure 2 Only the original expression with 2 variables is taken as an example. In this embodiment, when the number of variables in the original expression is greater than 2, i is correspondingly greater than 2, which will not be described in detail.

[0057] In this embodiment, the test document is generated according to the test document template, and the specific generation method includes:

[0058] The identification, original expression, and original data source information of the test case are obtained, and recorded accordingly in the test document template to obtain the test document.

[0059] It should be noted that the test document includes the identification of the test case, the original expression, and the original data source information, wherein the expression form of the original expression is a first grammatical expression, and the first grammatical expression is a preset expression form of the object under test (software).

[0060] Optionally, the original expression is obtained by orthogonal combination of preset test points. In this embodiment, a number of original expressions are obtained by covering all test points through an orthogonal combination method, and syntax coverage is performed by using operators, functions, and combinations of variables of different variable types, thereby improving the coverage of the test points by the original expression, that is, improving the coverage of the functional points of the functional test. It should be noted that the specific orthogonal combination method can be referred to the prior art.

[0061] It should be noted that the number of solution sets can be one or more. This embodiment only takes the solution set including the first solution set and the second solution set as an example. Optionally, the first solution set is the solution set that makes the original expression valid (that is, the true solution set of the original expression), and the second solution set is the solution set that makes the original expression invalid (that is, the false solution set of the original expression).

[0062] In this embodiment, the method for obtaining the data to be tested from the test document includes:

[0063] The original expression in the test document is used as the expression to be tested, and the original data source corresponding to the original expression is used as the data source information of the expression to be tested.

[0064] S102: Identify, from the expression to be tested, the character string of the variable to be tested and the character string of the fixed quantity to be tested.

[0065] In this embodiment, the measured quantity includes the measured variable and the measured fixed quantity. The expression to be tested is recorded in the test document in the form of a first grammatical expression, wherein the first grammatical expression is a preset grammar of the software to be tested. That is, the character string of each variable to be tested is in the first expression form.

[0066] It should be noted that the method for identifying and obtaining the character string of the variable to be tested can refer to the prior art.

[0067] S103 . Obtain the script string of each variable to be measured and the sequence of the script string according to the string of each variable to be measured.

[0068] In this embodiment, the script character strings are all second grammatical expressions, and the second grammatical expressions are programmable readable expressions, that is, expressions applied to the first preset script. The order of the script character string of the variable to be tested indicates the order of the variable to be tested in the variable sequence of the expression to be tested, and the variable sequence includes the variables to be tested arranged in a front-to-back order.

[0069] In this embodiment, the specific method of obtaining the script string of any variable to be measured includes:

[0070] A1. Use a regular expression to match the variable to be tested, and obtain a script string that matches the variable to be tested.

[0071] A2. Generalize the script string that matches the variable to be measured, and use the generalized script string as the script string of the variable to be measured.

[0072] It should be noted that, for all variables to be measured, the method further includes removing duplicate script strings of the variables to be measured to obtain the script strings of the variables to be measured and the order of the script strings of the variables to be measured.

[0073] It should be noted that this method uses the method of removing duplicates of the variables to be tested to retain the order of the original list elements. This is to ensure the validity of the verification data obtained when the variables are referenced multiple times in the same expression. And through generalization, the variables to be tested with the same mathematical meaning are standardized, so that the variables to be tested are not limited to specific variable names.

[0074] S104 , obtaining a script character string for each fixed quantity to be measured according to the character string for each fixed quantity to be measured.

[0075] In this embodiment, the specific method for obtaining the script string of any fixed quantity to be measured (recorded as the target fixed quantity to be measured) includes:

[0076] B1. Obtain a conversion dictionary, where the conversion dictionary includes a mapping relationship between a string of a fixed quantity to be measured and a script string.

[0077] In this embodiment, script strings are all recorded in the form of programming readable expressions (ie, second language expressions), and the conversion dictionary includes: a temporary replacement dictionary, a universal replacement dictionary, and a specific language replacement script dictionary.

[0078] The temporary replacement dictionary stores the mapping relationship between the first type of fixed variables and the script string. The first type of fixed variables includes operators or functions that are easily confused. For example, negation "!" and not equal to "!=" are to replace easily confused strings.

[0079] The general replacement dictionary stores the mapping relationship between the second type of fixed variables and the script string. The second type of fixed variables includes general operators and functions. For example, logical operators are represented in the same form in all function libraries of a programming language.

[0080] The specific language replacement script dictionary stores the mapping relationship between the third type of fixed quantities and the script string. The third type of fixed quantities includes operators and functions of the programming language function library, as well as temporarily matched functions or operators.

[0081] B2. If the target fixed quantity to be measured is a function or an operator, the script string corresponding to the target fixed quantity to be measured in the conversion dictionary is used as the script string of the fixed quantity to be measured.

[0082] B3. If the target fixed quantity to be measured is a constant, the character string of the target fixed quantity to be measured is directly used as the script character string of the target fixed quantity to be measured.

[0083] S105 . Generate a readable expression of the expression to be tested according to the script character string of the variable to be tested and the script character string of the fixed quantity to be tested.

[0084] S106: Verify whether the readable expression of the expression to be tested meets the preset correctness condition.

[0085] In this embodiment, the correctness conditions include but are not limited to: there are no human-caused (operator or function) syntax usage errors, there are no unsupported expression errors, there are no errors in obtaining verification data to avoid division by zero, and there are no input parameter type errors and out-of-range errors.

[0086] It should be noted that the specific correctness verification method refers to the prior art. It can be seen that this step ensures the readability of the readable expression of the expression to be tested by verifying the correctness of the readable expression of the expression to be tested, avoids test failure caused by construction errors of the readable expression of the expression to be tested, and further improves the accuracy of the test.

[0087] It should be noted that if the readable expression does not meet the correctness condition, it will be marked and warned.

[0088] S107: If the readable expression meets the correctness condition, the first preset script is called with the readable expression and data source information of the expression to be tested as script parameters to obtain verification data of the expression to be tested.

[0089] In this embodiment, the verification data includes a target result and a solution set corresponding to the target result, and the first preset script is used to obtain the values ​​of each variable to be tested of the expression to be tested based on the target result as the solution set corresponding to the target result. The target result includes that the expression to be tested is established and / or that the expression to be tested is not established.

[0090] In this embodiment, the data source information at least includes the correspondence between the order of the variable to be measured and the variable type, and the variable type is used to constrain the value range of the variable to be measured. The constraint rules are determined according to the preset data dictionary. For details, please refer to the prior art, and this embodiment will not be repeated.

[0091] In this embodiment, the verification data of the expression to be tested includes: a first solution set corresponding to the establishment of the expression to be tested, and a second solution set corresponding to the failure of the expression to be tested.

[0092] The method for obtaining the first solution set and the second solution set by the first preset script includes: taking the test expression as a condition, obtaining the value of each variable to be tested according to the variable type corresponding to the sequence of each variable to be tested, obtaining the true solution set of the test expression, and randomly obtaining the first solution set from the true solution set and outputting it. Taking the test expression as a condition that it is not established, obtaining the value of each variable to be tested according to the variable type corresponding to the sequence of each variable to be tested, obtaining the false solution set of the test expression, and randomly obtaining the second solution set from the false solution set and outputting it.

[0093] It should be noted that the readable expression of the expression to be tested is only a grammatical form of the expression to be tested. Therefore, the establishment of the expression to be tested is equivalent to the establishment of the readable expression, and the failure of the expression to be tested is equivalent to the failure of the readable expression.

[0094] It should be noted that, for any expression to be tested, if it is not the first time to obtain the verification data of the expression to be tested, a set of values ​​of the variables to be tested is randomly obtained again from the true solution set of the expression to be tested obtained for the first time, as the first solution set of the expression to be tested, and a set of values ​​of the variables to be tested is randomly obtained again from the false solution set of the expression to be tested obtained for the first time, as the second solution set of the expression to be tested. It can be seen that this method adopts a variable random value strategy to obtain the first solution set and / or the second solution set in the verification data, which, on the one hand, reduces the computational resource consumption of calculating the true solution set or the false solution set each time, and on the other hand, reduces the risk of missing defects due to test design, and improves the coverage and randomness of test data.

[0095] It can be seen from the above technical scheme that an embodiment of the present application provides a method for obtaining verification data, which obtains an expression to be tested and data source information, obtains a readable expression of the expression to be tested, uses the readable expression and data source information as script parameters, calls a first preset script, and obtains verification data of the expression to be tested, wherein the verification data includes a target result and a solution set corresponding to the target result, and the target result includes whether the readable expression holds and / or does not hold. Since the expression to be tested includes variables to be tested and fixed quantities to be tested, the data source information includes the correspondence between the variables to be tested and the variable types, and the variable types indicate the value range, the first preset script is used to obtain the values ​​of each variable to be tested with the target result as a condition, as the solution set corresponding to the target result, therefore, the method can automatically obtain the verification data of the expression to be tested by converting the expression to be tested into a readable expression and using the first preset script.

[0096] Furthermore, the mapping relationship between the fixed quantity to be measured (operator and function) and the script string (second expression form) is pre-stored in a classified dictionary manner, thereby improving the efficiency of obtaining the script string of the fixed quantity to be measured. The data value range of the variable type is stored in a dictionary manner, and the value of the variable to be measured is constrained to ensure the correctness of the value of the variable to be measured.

[0097] It should be noted that Figure 1 This is only a specific implementation method of a method for obtaining verification data provided in an embodiment of the present application. The present application also includes other specific implementation methods. For example, S102 is only an optional method for obtaining a script string of a variable to be tested, and S103 is only an optional method for obtaining a script string of a variable to be fixed.

[0098] In summary, the probability of obtaining verification data provided by the embodiment of the present application is summarized as follows: Figure 2 As shown in the process. Figure 3 As shown, the method includes:

[0099] S301, obtaining data to be tested.

[0100] In this embodiment, the data to be tested includes an expression to be tested and data source information. The expression to be tested is composed of a plurality of preset test points. The expression to be tested includes a variable to be tested and a fixed quantity to be tested. The data source information includes a correspondence between the variable to be tested and the variable type. The variable type of the variable to be tested indicates the value range of the variable to be tested.

[0101] In this embodiment, there are multiple methods for obtaining the data to be tested. For example, the expression to be tested and the data source information are obtained from the historical test data. For another example, an optional specific method for obtaining the data to be tested can be referred to the above embodiment.

[0102] S302: Convert the expression to be tested into a readable expression.

[0103] The present application includes multiple methods for converting the expression to be tested into a readable expression. An optional specific method for obtaining a readable expression can be found in the above embodiment.

[0104] S303: Using the readable expression and data source information as script parameters, calling the first preset script to obtain verification data of the expression to be tested.

[0105] In this embodiment, the verification data includes the target result and the solution set corresponding to the target result. The first preset script is used to obtain the values ​​of each variable to be measured with the target result as the condition, as the solution set corresponding to the target result. The target result includes whether a readable expression is true and / or false.

[0106] It can be seen from the above technical scheme that an embodiment of the present application provides a method for obtaining verification data, which obtains data source information, obtains a readable expression of the expression to be tested, uses the readable expression and the data source information as script parameters, calls a first preset script, and obtains verification data of the expression to be tested, wherein the verification data includes a target result and a solution set corresponding to the target result, and the target result includes whether the readable expression holds and / or does not hold. Since the expression to be tested includes the variables to be tested and the fixed quantity to be tested, the data source information includes the correspondence between the variables to be tested and the variable types, and the variable type indicates the value range, the first preset script is used to obtain the values ​​of each variable to be tested with the target result as the condition, as the solution set corresponding to the target result, therefore, the method can automatically obtain the verification data of the expression to be tested by converting the expression to be tested into a readable expression and using the first preset script.

[0107] Figure 4 A schematic diagram of the structure of a verification data acquisition device provided in an embodiment of the present application is shown. Figure 4 As shown, the device may include:

[0108] The test data acquisition unit 401 is used to acquire the data to be tested, wherein the data to be tested includes an expression to be tested and data source information, wherein the expression to be tested includes a variable to be tested and a fixed quantity to be tested; the data source information includes a correspondence between the variable to be tested and the variable type, and the variable type of the variable to be tested indicates the value range of the variable to be tested;

[0109] A readable expression acquisition unit 402, used to convert the expression to be tested into a readable expression;

[0110] The verification data acquisition unit 403 is used to call the first preset script with the readable expression and the data source information as script parameters to obtain the verification data of the expression to be tested; the verification data includes a target result and a solution set corresponding to the target result, and the first preset script is used to obtain the values ​​of each variable to be tested with the target result as a condition, as the solution set corresponding to the target result, and the target result includes whether the readable expression is true and / or false.

[0111] Optionally, the readable expression acquisition unit is used to convert the expression to be tested into a readable expression, including: the readable expression acquisition unit is specifically used to:

[0112] From the expression to be tested, identifying the character string of each variable to be tested and the character string of each fixed quantity to be tested;

[0113] According to the character string of each variable to be measured, the script character string of each variable to be measured and the order of the script character string are obtained; the script character string of the variable to be measured is an expression form applied to the first preset script;

[0114] According to the character string of each fixed quantity to be measured, a script character string of each fixed quantity to be measured is obtained; the script character string of the fixed quantity to be measured is an expression form applied to the first preset script;

[0115] A readable expression of the expression to be tested is generated according to the script character string of each of the variables to be tested and the script character string of each of the fixed quantities to be tested.

[0116] Optionally, the readable expression acquisition unit is used to acquire the script string of the target variable to be measured and the order of the script string according to the string of the target variable to be measured, wherein the target variable to be measured is any variable to be measured, including: the readable expression acquisition unit is specifically used to:

[0117] Using a regular expression to match the target variable to be measured to obtain a script string that matches the target variable to be measured;

[0118] Performing generalization processing on the script character string that matches the target variable to be measured, and using the generalization processing result as the script character string of the target variable to be measured;

[0119] The order of the target variable to be tested in a variable sequence is obtained as the order of the script string of the target variable to be tested, wherein the variable sequence includes the variables to be tested in the expression to be tested arranged in a front-to-back order.

[0120] Optionally, the readable expression acquisition unit is used to acquire a script string of the target fixed quantity to be measured according to the string of the target fixed quantity to be measured, wherein the target fixed quantity to be measured is any fixed quantity to be measured, including: the readable expression acquisition unit is specifically used to:

[0121] If the target fixed quantity to be measured is a function or an operator, the script string corresponding to the target fixed quantity to be measured in the preset conversion dictionary is used as the script string of the target fixed quantity to be measured; the conversion dictionary includes a mapping relationship between the string of each fixed quantity to be measured and the script string;

[0122] If the target fixed quantity to be measured is a constant, the character string of the target fixed quantity to be measured is used as the script character string of the target fixed quantity to be measured.

[0123] Optionally, the test data acquisition unit is used to acquire the data to be tested, including: the test data acquisition unit is specifically used to:

[0124] According to a preset test document template, a test document is obtained, wherein the test document includes a preset first-category script parameter field, wherein the first-category script parameter field includes an original expression and original data source information; wherein the original expression is obtained by orthogonally combining preset test points;

[0125] The original expression is used as the expression to be tested, and the original data source information corresponding to the original expression is used as the data source information.

[0126] Optionally, it also includes a verification unit for verifying whether the readable expression meets a preset correctness condition before calling a first preset script with the readable expression and the data source information as script parameters to obtain verification data of the expression to be tested.

[0127] The verification data acquisition unit is used to call a first preset script with the readable expression and the data source information as script parameters to obtain the verification data of the expression to be tested, including: the verification data acquisition unit is specifically used to: if the readable expression meets the correctness condition, call the first preset script with the readable expression and the data source information as script parameters to obtain the verification data of the expression to be tested.

[0128] Figure 5 A schematic diagram of the structure of the verification data acquisition device is shown, and the device may include: at least one processor 501, at least one communication interface 502, at least one memory 503 and at least one communication bus 504;

[0129] In the embodiment of the present application, the number of the processor 501, the communication interface 502, the memory 503, and the communication bus 504 is at least one, and the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504;

[0130] The processor 501 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention;

[0131] The memory 503 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;

[0132] The memory stores a program, and the processor can execute the program stored in the memory to implement the steps of a method for obtaining verification data provided in an embodiment of the present application, as follows:

[0133] A method for obtaining verification data, comprising:

[0134] Acquire data to be tested, wherein the data to be tested includes an expression to be tested and data source information, wherein the expression to be tested includes a variable to be tested and a fixed quantity to be tested; the data source information includes a correspondence between the variable to be tested and the variable type, and the variable type of the variable to be tested indicates a value range of the variable to be tested;

[0135] Convert the expression to be tested into a readable expression;

[0136] With the readable expression and the data source information as script parameters, the first preset script is called to obtain verification data of the expression to be tested; the verification data includes a target result and a solution set corresponding to the target result, and the first preset script is used to obtain the values ​​of each variable to be tested with the target result as a condition, as a solution set corresponding to the target result, and the target result includes whether the readable expression is true and / or false.

[0137] Optionally, converting the expression to be tested into a readable expression includes:

[0138] From the expression to be tested, identifying the character string of each variable to be tested and the character string of each fixed quantity to be tested;

[0139] According to the character string of each variable to be measured, the script character string of each variable to be measured and the order of the script character string are obtained; the script character string of the variable to be measured is an expression form applied to the first preset script;

[0140] According to the character string of each fixed quantity to be measured, a script character string of each fixed quantity to be measured is obtained; the script character string of the fixed quantity to be measured is an expression form applied to the first preset script;

[0141] A readable expression of the expression to be tested is generated according to the script character string of each of the variables to be tested and the script character string of each of the fixed quantities to be tested.

[0142] Optionally, according to the character string of the target variable to be measured, the script character string of the target variable to be measured and the order of the script character string are obtained, and the target variable to be measured is any variable to be measured, including:

[0143] Using a regular expression to match the target variable to be measured to obtain a script string that matches the target variable to be measured;

[0144] Performing generalization processing on the script character string that matches the target variable to be measured, and using the generalization processing result as the script character string of the target variable to be measured;

[0145] The order of the target variable to be tested in a variable sequence is obtained as the order of the script string of the target variable to be tested, wherein the variable sequence includes the variables to be tested in the expression to be tested arranged in a front-to-back order.

[0146] Optionally, according to a character string of a target fixed quantity to be measured, a script character string of the target fixed quantity to be measured is obtained, wherein the target fixed quantity to be measured is any fixed quantity to be measured, including:

[0147] If the target fixed quantity to be measured is a function or an operator, the script string corresponding to the target fixed quantity to be measured in the preset conversion dictionary is used as the script string of the target fixed quantity to be measured; the conversion dictionary includes a mapping relationship between the string of each fixed quantity to be measured and the script string;

[0148] If the target fixed quantity to be measured is a constant, the character string of the target fixed quantity to be measured is used as the script character string of the target fixed quantity to be measured.

[0149] Optionally, obtaining the data to be tested includes:

[0150] According to a preset test document template, a test document is obtained, wherein the test document includes a preset first-category script parameter field, wherein the first-category script parameter field includes an original expression and original data source information; wherein the original expression is obtained by orthogonally combining preset test points;

[0151] The original expression is used as the expression to be tested, and the original data source information corresponding to the original expression is used as the data source information.

[0152] Optionally, before the first preset script is called with the readable expression and the data source information as script parameters to obtain the verification data of the expression to be tested, the method further includes:

[0153] Verify whether the readable expression meets the preset correctness condition.

[0154] The step of taking the readable expression and the data source information as script parameters, calling a first preset script, and obtaining verification data of the expression to be tested includes:

[0155] If the readable expression satisfies the correctness condition, the first preset script is called with the readable expression and the data source information as script parameters to obtain verification data of the expression to be tested.

[0156] The embodiment of the present application further provides a readable storage medium, which can store a computer program suitable for execution by a processor. When the computer program is executed by the processor, the steps of a method for obtaining verification data provided in the embodiment of the present application are implemented as follows:

[0157] A method for obtaining verification data, comprising:

[0158] Acquire data to be tested, wherein the data to be tested includes an expression to be tested and data source information, wherein the expression to be tested includes a variable to be tested and a fixed quantity to be tested; the data source information includes a correspondence between the variable to be tested and the variable type, and the variable type of the variable to be tested indicates a value range of the variable to be tested;

[0159] Convert the expression to be tested into a readable expression;

[0160] With the readable expression and the data source information as script parameters, the first preset script is called to obtain verification data of the expression to be tested; the verification data includes a target result and a solution set corresponding to the target result, and the first preset script is used to obtain the values ​​of each variable to be tested with the target result as a condition, as a solution set corresponding to the target result, and the target result includes whether the readable expression is true and / or false.

[0161] Optionally, converting the expression to be tested into a readable expression includes:

[0162] From the expression to be tested, identifying the character string of each variable to be tested and the character string of each fixed quantity to be tested;

[0163] According to the character string of each variable to be measured, the script character string of each variable to be measured and the order of the script character string are obtained; the script character string of the variable to be measured is an expression form applied to the first preset script;

[0164] According to the character string of each fixed quantity to be measured, a script character string of each fixed quantity to be measured is obtained; the script character string of the fixed quantity to be measured is an expression form applied to the first preset script;

[0165] A readable expression of the expression to be tested is generated according to the script character string of each of the variables to be tested and the script character string of each of the fixed quantities to be tested.

[0166] Optionally, according to the character string of the target variable to be measured, the script character string of the target variable to be measured and the order of the script character string are obtained, and the target variable to be measured is any variable to be measured, including:

[0167] Using a regular expression to match the target variable to be measured to obtain a script string that matches the target variable to be measured;

[0168] Performing generalization processing on the script character string that matches the target variable to be measured, and using the generalization processing result as the script character string of the target variable to be measured;

[0169] The order of the target variable to be tested in a variable sequence is obtained as the order of the script string of the target variable to be tested, wherein the variable sequence includes the variables to be tested in the expression to be tested arranged in a front-to-back order.

[0170] Optionally, according to a character string of a target fixed quantity to be measured, a script character string of the target fixed quantity to be measured is obtained, wherein the target fixed quantity to be measured is any fixed quantity to be measured, including:

[0171] If the target fixed quantity to be measured is a function or an operator, the script string corresponding to the target fixed quantity to be measured in the preset conversion dictionary is used as the script string of the target fixed quantity to be measured; the conversion dictionary includes a mapping relationship between the string of each fixed quantity to be measured and the script string;

[0172] If the target fixed quantity to be measured is a constant, the character string of the target fixed quantity to be measured is used as the script character string of the target fixed quantity to be measured.

[0173] Optionally, obtaining the data to be tested includes:

[0174] According to a preset test document template, a test document is obtained, wherein the test document includes a preset first-category script parameter field, wherein the first-category script parameter field includes an original expression and original data source information; wherein the original expression is obtained by orthogonally combining preset test points;

[0175] The original expression is used as the expression to be tested, and the original data source information corresponding to the original expression is used as the data source information.

[0176] Optionally, before the first preset script is called with the readable expression and the data source information as script parameters to obtain the verification data of the expression to be tested, the method further includes:

[0177] Verify whether the readable expression meets the preset correctness condition.

[0178] The step of taking the readable expression and the data source information as script parameters, calling a first preset script, and obtaining verification data of the expression to be tested includes:

[0179] If the readable expression satisfies the correctness condition, the first preset script is called with the readable expression and the data source information as script parameters to obtain verification data of the expression to be tested.

[0180] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0181] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0182] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for obtaining verification data, characterized in that: include: Acquire data to be tested, wherein the data to be tested includes an expression to be tested and data source information, and the expression to be tested includes a variable to be tested and a fixed quantity to be tested; The data source information includes a correspondence between a variable to be measured and a variable type, and the variable type of the variable to be measured indicates a value range of the variable to be measured; Convert the expression to be tested into a readable expression; Using the readable expression and the data source information as script parameters, calling a first preset script to obtain verification data of the expression to be tested; The verification data includes a target result and a solution set corresponding to the target result, the first preset script is used to obtain the values ​​of each of the variables to be measured with the target result as a condition, as a solution set corresponding to the target result, and the target result includes whether the readable expression is true and / or false; The verification data of the expression to be tested specifically includes: a first solution set corresponding to the establishment of the expression to be tested, and a second solution set corresponding to the failure of the expression to be tested; The method for obtaining the first solution set and the second solution set by the first preset script includes: taking the establishment of the expression to be tested as a condition, obtaining the value of each variable to be tested according to the variable type corresponding to the order of each variable to be tested, obtaining the true solution set of the expression to be tested, and randomly obtaining the first solution set from the true solution set and outputting it; taking the failure of the expression to be tested as a condition, obtaining the value of each variable to be tested according to the variable type corresponding to the order of each variable to be tested, obtaining the false solution set of the expression to be tested, and randomly obtaining the second solution set from the false solution set and outputting it.

2. The method according to claim 1, characterized in that The converting the expression to be tested into a readable expression comprises: From the expression to be tested, identifying the character string of each variable to be tested and the character string of each fixed quantity to be tested; According to the character string of each variable to be measured, the script character string of each variable to be measured and the order of the script character string are obtained; the script character string of the variable to be measured is an expression form applied to the first preset script; According to the character string of each fixed quantity to be measured, a script character string of each fixed quantity to be measured is obtained; the script character string of the fixed quantity to be measured is an expression form applied to the first preset script; A readable expression of the expression to be tested is generated according to the script character string of each of the variables to be tested and the script character string of each of the fixed quantities to be tested.

3. The method according to claim 2, characterized in that According to the character string of the target variable to be measured, the script character string of the target variable to be measured and the order of the script character string are obtained, wherein the target variable to be measured is any variable to be measured, including: Using a regular expression to match the target variable to be measured to obtain a script string that matches the target variable to be measured; Performing generalization processing on the script character string that matches the target variable to be measured, and using the generalization processing result as the script character string of the target variable to be measured; The sequence of the target variable to be tested in a variable sequence is obtained as the sequence of the script character string of the target variable to be tested, wherein the variable sequence includes the variables to be tested in the expression to be tested arranged in a front-to-back order.

4. The method according to claim 2, characterized in that: According to the character string of the target fixed quantity to be measured, a script character string of the target fixed quantity to be measured is obtained, wherein the target fixed quantity to be measured is any fixed quantity to be measured, including: If the target fixed quantity to be measured is a function or an operator, the script string corresponding to the target fixed quantity to be measured in the preset conversion dictionary is used as the script string of the target fixed quantity to be measured; the conversion dictionary includes a mapping relationship between the string of each fixed quantity to be measured and the script string; If the target fixed quantity to be measured is a constant, the character string of the target fixed quantity to be measured is used as the script character string of the target fixed quantity to be measured.

5. The method according to claim 1, characterized in that: The obtaining of the data to be tested comprises: According to a preset test document template, a test document is obtained, wherein the test document includes a preset first-category script parameter field, wherein the first-category script parameter field includes an original expression and original data source information; wherein the original expression is obtained by orthogonally combining preset test points; The original expression is used as the expression to be tested, and the original data source information corresponding to the original expression is used as the data source information.

6. The method according to claim 1, characterized in that Before the first preset script is called with the readable expression and the data source information as script parameters to obtain the verification data of the expression to be tested, the method further includes: Verifying whether the readable expression satisfies a preset correctness condition; The method of calling a first preset script with the readable expression and the data source information as script parameters to obtain verification data of the expression to be tested includes: if the readable expression meets the correctness condition, calling the first preset script with the readable expression and the data source information as script parameters to obtain verification data of the expression to be tested.

7. A device for obtaining verification data, characterized in that: include: A test data acquisition unit, used to acquire data to be tested, wherein the data to be tested includes an expression to be tested and data source information, and the expression to be tested includes a variable to be tested and a fixed quantity to be tested; The data source information includes a correspondence between a variable to be measured and a variable type, and the variable type of the variable to be measured indicates a value range of the variable to be measured; A readable expression acquisition unit, used for converting the expression to be tested into a readable expression; A verification data acquisition unit, configured to call a first preset script with the readable expression and the data source information as script parameters to obtain verification data of the expression to be tested; The verification data includes a target result and a solution set corresponding to the target result, the first preset script is used to obtain the values ​​of each of the variables to be measured with the target result as a condition, as a solution set corresponding to the target result, and the target result includes whether the readable expression is true and / or false; The verification data of the expression to be tested specifically includes: a first solution set corresponding to the establishment of the expression to be tested, and a second solution set corresponding to the failure of the expression to be tested; The method for obtaining the first solution set and the second solution set by the first preset script includes: taking the establishment of the expression to be tested as a condition, obtaining the value of each variable to be tested according to the variable type corresponding to the order of each variable to be tested, obtaining the true solution set of the expression to be tested, and randomly obtaining the first solution set from the true solution set and outputting it; taking the failure of the expression to be tested as a condition, obtaining the value of each variable to be tested according to the variable type corresponding to the order of each variable to be tested, obtaining the false solution set of the expression to be tested, and randomly obtaining the second solution set from the false solution set and outputting it.

8. The device according to claim 7, wherein the readable expression acquisition unit is used to convert the expression to be tested into a readable expression, comprising: The readable expression acquisition unit is specifically used for: From the expression to be tested, identifying the character string of each variable to be tested and the character string of each fixed quantity to be tested; According to the character string of each variable to be measured, the script character string of each variable to be measured and the order of the script character string are obtained; the script character string of the variable to be measured is an expression form applied to the first preset script; According to the character string of each fixed quantity to be measured, a script character string of each fixed quantity to be measured is obtained; the script character string of the fixed quantity to be measured is an expression form applied to the first preset script; A readable expression of the expression to be tested is generated according to the script character string of each of the variables to be tested and the script character string of each of the fixed quantities to be tested.

9. A verification data acquisition device, characterized in that: include: Memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the method for obtaining verification data according to any one of claims 1 to 6.

10. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the method for obtaining verification data according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Structured data conversion method and device, computer equipment and storage medium

    CN110377291A

  • Interface testing method and device

    CN111324540A

  • Interface testing method and device, equipment and readable storage medium

    CN113127347A