Disclosure of Invention
An object of the embodiments of the present application is to provide a data verification method and apparatus, which can automatically detect the matching between the attribute of the data table field and the field attribute of the code, and has short time consumption, greatly saves labor cost, and can avoid the defect of incomplete manual inspection, thereby improving the accuracy of the test.
An embodiment of the present invention provides a data verification method, applied to a data verification tool, including:
acquiring a data field to be verified;
acquiring a code set of a system to be verified according to the data field;
acquiring a field attribute set of the data field;
comparing the code set with the field attribute set according to a preset matching rule to obtain a comparison result;
and determining a data verification result according to the comparison result.
In the implementation process, the data verification tool can obtain the data field to be verified preferentially; then, acquiring a code set of the system to be verified according to the data field; then, acquiring a field attribute set of the data field; then, comparing the code set with the field attribute set according to a preset matching rule to obtain a comparison result; and finally, determining a data verification result according to the comparison result. Therefore, the method can automatically detect the matching of the attribute of the data table field and the field attribute of the code, has short time consumption, greatly saves labor cost, can avoid the defect of incomplete manual inspection, and further improves the accuracy of the test.
Further, before the obtaining the data field to be verified, the method further includes:
acquiring a pre-constructed data verification tool;
and configuring the data verification tool into a code packet of a target system, and configuring a storage catalog of the data verification tool into the target system.
Further, the acquiring the code set of the system to be verified according to the data field includes:
acquiring codes related to the data fields from a code packet of a system to be checked;
analyzing the codes to obtain code analysis results;
and generating a code set according to a preset first data format and the code analysis result.
Further, the acquiring the field attribute set of the data field includes:
accessing a data table in a database to be checked;
acquiring field related attributes of the data fields from the data table;
and generating a data field set according to a preset second data format and the field related attribute.
Further, the determining the data verification result according to the comparison result includes:
when the comparison result completely meets the matching rule, determining that the verification result passes verification;
when the comparison result comprises a first preset error reporting return value, determining whether the check result is empty and the check is not passed;
and when the comparison result comprises a second preset error return value, determining that the verification result does not pass the verification of the data structure.
A second aspect of the embodiments of the present application provides a data verification device, where the data verification device includes:
the first acquisition unit is used for acquiring the data field to be verified;
the second acquisition unit is used for acquiring a code set of the system to be verified according to the data field;
a third obtaining unit, configured to obtain a field attribute set of the data field;
the comparison unit is used for comparing the code set with the field attribute set according to a preset matching rule to obtain a comparison result;
and the determining unit is used for determining a data verification result according to the comparison result.
In the implementation process, the device may first acquire the data field to be verified through the first acquisition unit; acquiring a code set of the system to be checked according to the data field by a second acquisition unit; acquiring a field attribute set of the data field through a third acquisition unit; then, comparing the code set with the field attribute set according to a preset matching rule by a comparison unit to obtain a comparison result; and finally, determining a data verification result according to the comparison result by a determination unit. Therefore, the device can automatically detect the matching of the attribute of the data table field and the field attribute of the code, is short in time consumption, greatly saves labor cost, can avoid the defect of incomplete manual inspection, and further improves the accuracy of the test.
Further, the data verification device further includes:
the first obtaining unit is further configured to obtain a pre-constructed data verification tool before the data field to be verified is obtained;
and the configuration unit is used for configuring the data verification tool into a code packet of a target system and configuring a storage catalog of the data verification tool into the target system.
Further, the second acquisition unit includes:
a code acquisition subunit, configured to acquire a code related to the data field in a code packet of a system to be verified;
a code analysis subunit, configured to analyze the code to obtain a code analysis result;
and the code generation subunit is used for generating a code set according to a preset first data format and the code analysis result.
Further, the third acquisition unit includes:
an access subunit, configured to access a data table in the database to be checked;
an attribute obtaining subunit, configured to obtain a field related attribute of the data field from the data table;
and the data generation subunit is used for generating a data field set according to a preset second data format and the field related attribute.
Further, the determining unit is specifically configured to determine that the verification result is passed through verification when the comparison result is that the matching rule is completely satisfied; or when the comparison result comprises a first preset error reporting return value, determining whether the check result is empty and the check is not passed; or when the comparison result comprises a second preset error return value, determining that the verification result is not passed for data structure verification.
A third aspect of the embodiments of the present application provides an electronic device, including a memory and a processor, where the memory is configured to store a computer program, and the processor is configured to execute the computer program to cause the electronic device to perform the data verification method according to any one of the first aspect of the embodiments of the present application.
A fourth aspect of the embodiments of the present application provides a computer readable storage medium storing computer program instructions which, when read and executed by a processor, perform a data verification method according to any one of the first aspects of the embodiments of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only to distinguish the description, and are not to be construed as indicating or implying relative importance.
Example 1
Referring to fig. 1, fig. 1 is a flowchart of a data verification method according to the present embodiment. The data verification method comprises the following steps:
s101, acquiring a data field to be verified.
S102, acquiring a code set of the system to be verified according to the data field.
S103, acquiring a field attribute set of the data field.
S104, comparing the code set with the field attribute set according to a preset matching rule to obtain a comparison result.
S105, determining a data verification result according to the comparison result.
In this embodiment, the execution subject of the method may be a computing device such as a computer or a server, which is not limited in this embodiment.
In this embodiment, the execution body of the method may be an intelligent device such as a smart phone or a tablet computer, which is not limited in this embodiment.
Therefore, by implementing the data verification method described in the embodiment, manual comparison and testing of the filling-in attribute and the data type of each data field by developers and testers can be reduced in iteration of the new version, so that the effect of automatically finding out related functional defects in the new iteration version/regression test is achieved, further, the labor cost is greatly saved, and the efficiency is improved. Meanwhile, the defect of incomplete manual inspection can be avoided, the testing accuracy is improved, the consistency of a data table and codes of a database is ensured, and further, the data storage errors caused by the data structure in the data table or whether the attribute errors are empty are avoided, and the production fault sending probability of losing data and causing data loss can be greatly reduced.
Example 2
Referring to fig. 2, fig. 2 is a flowchart of a data verification method according to the present embodiment. The data verification method comprises the following steps:
s201, acquiring a pre-constructed data verification tool.
S202, configuring the data verification tool into a code packet of the target system, and configuring a storage catalog of the data verification tool into the target system.
S203, acquiring a data field to be verified.
S204, acquiring codes related to the data fields from a code packet of the system to be checked.
S205, analyzing the codes to obtain code analysis results.
S206, generating a code set according to a preset first data format and a code analysis result.
S207, accessing a data table in the database to be checked.
S208, acquiring field related attributes of the data fields from the data table.
S209, generating a data field set according to a preset second data format and field related attributes.
S210, comparing the code set with the field attribute set according to a preset matching rule to obtain a comparison result.
S211, when the comparison result is that the matching rule is completely met, determining that the verification result is passing verification; or when the comparison result comprises a first preset error reporting return value, determining whether the check result is empty and the check is not passed; or when the comparison result comprises a second preset error return value, determining that the verification result does not pass the verification of the data structure.
In this embodiment, whether or not the test is empty refers to a test procedure.
In this embodiment, the method automatically checks the relevant attribute of the data of the target system code based on the matching of the attribute of the data table field and the attribute of the code field, for example, detects whether the field of the relevant data implemented by the code can be empty or not, and whether the field of the data table field is controllably matched or not; for another example, it is detected whether the data field returned in the code implementation is consistent with the data structure of the data defined by the data table.
It can be seen that the method can return three different results according to different comparison results: by passing, errors are reported (whether empty test is not passed), errors are reported (data structure is not passed).
In this embodiment, the method proposes a method for automatically detecting the matching of the attribute of the data table field and the field attribute of the code, which can be applied to the financial field. The basic idea of the method is as follows: the codes of the database and the system are connected through a tool, the tool can select the fields of the data table of the database and the codes related to the data fields (the data model layer, the attribute of the control layer and the data, whether the data structure of the fields can be empty or not) to carry out automatic comparison and verification, and the running tool can check:
(1) Whether the field of the relevant data of the code implementation can be empty or not is consistent with the field of the data table or not. If not, it is suggested which fields are inconsistent with respect to non-empty properties.
(2) Whether the data type of the data field in the code implementation is consistent with the data structure of the data defined by the data table.
Referring to fig. 5, fig. 5 shows a basic workflow of the method, and a specific example is described as follows:
(1) The tool requests the code. See sections 1.1 and 1.2 of fig. 5, wherein the tool requests the system code and the data field related code, and after sending the request, the tool gets a response that is a set of all data field related code modules. The tool has the function of automatically triggering a unit test of whether the data is empty or not, by which the field is assigned a value of whether the attribute is empty or not. Specifically: notNull if it cannot be empty and NULL if it can be empty.
And (3) obtaining a similar structure of the data by automatically analyzing the corresponding codes by the tool: { code path, data table where field is located, field, data structure of field, whether it can be null }. The set of codes is exemplified as follows: { application/subassembly fo, applicationTable, applyID, string, notNull }, { application/subassembly fo, application Table, application name, string, null }, and the like.
(2) The tool requests attributes of the data fields of the data table and responds to the data. See sections 2.1 and 2.2 of the figure. Wherein, request data table results: the data field related attribute, after sending the request, the response obtained by the tool is the definition set of all the data field related attributes.
The tool can support access to databases of different types through a public interface, such as supporting access to the main stream databases of oracle, mysql and the like, and then analyze the table structure of the data table to obtain the return type of the data, wherein the structure is { table, field, data structure of field, whether the data structure can be empty }; the return type set of data is exemplified as follows: { ApplicationTable, applyID, varchar, notNull }, { application Table, application name, varchar, null }, and the like.
(3) Tool analysis, see sections 3.1 and 3.2 of the figure, is described as follows:
the tool will automatically compare and analyze the data of steps 1 and 2: and (3) obtaining a similar structure of the data and the attribute of the data field of the tool request data table through automatic analysis of the corresponding codes of the tool. The criteria for the data structure returned by the code and the value returned by the data table are different, matching rules are configured in the tool, if the matching rules are satisfied, a comparison pass is represented, otherwise no pass is represented.
The matching rules are exemplified as follows. If the code returns string, the data table returns nvarchar or varchar, then the data structure check passes.
| Code return | Data table return |
| Character string | String | Nvarchar,varchar,…… |
| … | | |
The comparison process is an automatic checking process, and whether the two processes are matched or not is judged. When the tool is run, the verification result of the tool can appear in the following scenario.
In this embodiment, the execution subject of the method may be a computing device such as a computer or a server, which is not limited in this embodiment.
In this embodiment, the execution body of the method may be an intelligent device such as a smart phone or a tablet computer, which is not limited in this embodiment.
Therefore, by implementing the data verification method described in the embodiment, manual comparison and testing of the filling-in attribute and the data type of each data field by developers and testers can be reduced in iteration of the new version, so that the effect of automatically finding out related functional defects in the new iteration version/regression test is achieved, further, the labor cost is greatly saved, and the efficiency is improved. Meanwhile, the defect of incomplete manual inspection can be avoided, the testing accuracy is improved, the consistency of a data table and codes of a database is ensured, and further, the data storage errors caused by the data structure in the data table or whether the attribute errors are empty are avoided, and the production fault sending probability of losing data and causing data loss can be greatly reduced.
Example 3
Referring to fig. 3, fig. 3 is a schematic structural diagram of a data verification device according to the present embodiment. As shown in fig. 3, the data verification apparatus includes:
a first obtainingunit 310, configured to obtain a data field to be verified;
a second obtainingunit 320, configured to obtain a code set of the system to be verified according to the data field;
a third obtainingunit 330, configured to obtain a field attribute set of the data field;
a comparingunit 340, configured to compare the code set and the field attribute set according to a pre-configured matching rule, so as to obtain a comparison result;
a determiningunit 350, configured to determine a data verification result according to the comparison result.
In this embodiment, the explanation of the data verification apparatus may refer to the description in embodiment 1 or embodiment 2, and the description is not repeated in this embodiment.
Therefore, by implementing the data verification device described in the embodiment, manual comparison and testing of the filling-in attribute and the data type of each data field by developers and testers can be reduced in iteration of a new version, so that the effect of automatically finding out related functional defects in the new iteration version/regression test is achieved, further, the labor cost is greatly saved, and the efficiency is improved. Meanwhile, the defect of incomplete manual inspection can be avoided, the testing accuracy is improved, the consistency of a data table and codes of a database is ensured, and further, the data storage errors caused by the data structure in the data table or whether the attribute errors are empty are avoided, and the production fault sending probability of losing data and causing data loss can be greatly reduced.
Example 4
Referring to fig. 4, fig. 4 is a schematic structural diagram of a data verification device according to the present embodiment. As shown in fig. 4, the data verification apparatus includes:
a first obtainingunit 310, configured to obtain a data field to be verified;
a second obtainingunit 320, configured to obtain a code set of the system to be verified according to the data field;
a third obtainingunit 330, configured to obtain a field attribute set of the data field;
a comparingunit 340, configured to compare the code set and the field attribute set according to a pre-configured matching rule, so as to obtain a comparison result;
a determiningunit 350, configured to determine a data verification result according to the comparison result.
As an alternative embodiment, the data verification device further includes:
the first obtainingunit 310 is further configured to obtain a pre-constructed data verification tool before obtaining the data field to be verified;
and theconfiguration unit 360 is used for configuring the data verification tool into the code package of the target system and configuring the storage catalog of the data verification tool into the target system.
As an alternative embodiment, thesecond acquisition unit 320 includes:
acode obtaining subunit 321, configured to obtain a code related to the data field from a code packet of the system to be verified;
acode analysis subunit 322, configured to analyze the code to obtain a code analysis result;
thecode generating subunit 323 is configured to generate a code set according to a preset first data format and a code analysis result.
As an alternative embodiment, thethird acquisition unit 330 includes:
anaccess subunit 331, configured to access a data table in the database to be checked;
anattribute obtaining subunit 332, configured to obtain a field related attribute of the data field from the data table;
thedata generating subunit 333 is configured to generate a set of data fields according to the preset second data format and the field related attribute.
As an optional implementation manner, the determiningunit 350 is specifically configured to determine that the verification result is passing the verification when the comparison result is that the matching rule is completely satisfied; or when the comparison result comprises a first preset error reporting return value, determining whether the check result is empty and the check is not passed; or when the comparison result comprises a second preset error return value, determining that the verification result does not pass the verification of the data structure.
In this embodiment, the explanation of the data verification apparatus may refer to the description in embodiment 1 or embodiment 2, and the description is not repeated in this embodiment.
Therefore, by implementing the data verification device described in the embodiment, manual comparison and testing of the filling-in attribute and the data type of each data field by developers and testers can be reduced in iteration of a new version, so that the effect of automatically finding out related functional defects in the new iteration version/regression test is achieved, further, the labor cost is greatly saved, and the efficiency is improved. Meanwhile, the defect of incomplete manual inspection can be avoided, the testing accuracy is improved, the consistency of a data table and codes of a database is ensured, and further, the data storage errors caused by the data structure in the data table or whether the attribute errors are empty are avoided, and the production fault sending probability of losing data and causing data loss can be greatly reduced.
An embodiment of the present application provides an electronic device, including a memory and a processor, where the memory is configured to store a computer program, and the processor is configured to execute the computer program to cause the electronic device to execute a data verification method in embodiment 1 or embodiment 2 of the present application.
The present embodiment provides a computer readable storage medium storing computer program instructions that, when read and executed by a processor, perform the data verification method of embodiment 1 or embodiment 2 of the present application.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other manners as well. The apparatus embodiments described above are merely illustrative, for example, flow diagrams and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present application may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely exemplary embodiments of the present application and is not intended to limit the scope of the present application, and various modifications and variations may be suggested to one skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application. It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
The foregoing is merely specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes and substitutions are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.