Software data comparison method based on DIFF and storage medium
Through the DIFF-based software data comparison method, the database interface is used to obtain and convert data, intercept and reorganize source data fields, and compare it with the DIFF method, the problem of difficulty in realizing full data comparison in the existing technology is solved, efficient and automated software data comparison is achieved, and the reliability of the software is improved.
Patent Information
- Application Number
- CN202311091756.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-28
- Publication Date
- 2025-02-28
AI Technical Summary
Existing software testing technology is difficult to achieve fast and efficient comparison of the entire amount of data, resulting in insufficient reliability of the software data. The existing data comparison mainly focuses on JSON format data, making it difficult to effectively compare nested data.
Using the DIFF-based software data comparison method, the required data is obtained through the database interface to generate a data dictionary and convert it into target data; intercept and reorganize the required comparison fields in the software source data to generate data to be compared, and use the DIFF method to compare to obtain the comparison results.
The automation and high-speed comparison of software data can greatly improve the testing efficiency and realize the full data inspection and testing of source data, which is conducive to improving the reliability of the software.
Smart Images

Figure CN119537655A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software development, and in particular to a software data comparison method based on DIFF. In addition, the present invention also relates to a storage medium. Background Art
[0002] Digital transformation is a high-level transformation based on digital conversion and digital upgrade, which further touches the core business of software development and aims to create a new business model. Digital transformation is an important means to develop digital technology and supporting capabilities to create a dynamic digital business model.
[0003] In software development, software testing is a process used to promote the identification of the correctness, integrity, security and quality of software. In other words, software testing is a review or comparison process between actual output and expected output. The classic definition of software testing is: the process of operating a program under specified conditions to discover program errors, measure software quality, and evaluate whether it meets design requirements.
[0004] At present, in the field of software testing technology, software raw data is generally automatically sorted through automated tools to achieve efficient visual processing of data with high accuracy. In the test comparison stage, the original test data is manually processed, and small amounts of data can also be processed manually; however, due to the huge workload of full data testing, it is difficult to check and process manually. Therefore, full data comparison testing is generally not performed. Instead, manual inspection and repair are performed after the problem funnel is found during the later use of the software, resulting in insufficient reliability of software data.
[0005] In general, in the process of software development, it is an important and arduous task to conduct fast and efficient comparative testing of raw data. Although there are relevant processes for current software testing, it is basically performed by people, which is inefficient and prone to errors. The existing data comparison mainly performs a single comparison on JOSN (JavaScript Object Notation, a lightweight data exchange format) format data, and cannot better compare nested data. Test coverage is difficult to be comprehensive, and some incremental tests are difficult to cover manually, which is inconvenient to manage. Generally speaking, the integration test time of development projects is generally short, and a large amount of test data is difficult to organize and implement manually. Therefore, there is an urgent need for a complete automated testing method and its application in combination with the development process to effectively improve the above-mentioned problems in the software testing process. Summary of the invention
[0006] In view of this, the present invention aims to propose a software data comparison method based on DIFF to improve the efficiency of software testing.
[0007] To achieve the above object, the technical solution of the present invention is achieved as follows:
[0008] A software data comparison method based on DIFF, comprising:
[0009] The required data is obtained through the database interface to generate a data dictionary and converted into target data; the fields that need to be DIFF compared in the source data of the software are intercepted and reorganized to generate the data to be compared, and the DIFF method is used to compare the data to be compared with the target data to obtain the DIFF comparison result.
[0010] Furthermore, the database adopts VINBOM database, and the target data is target JSON data in JSON format.
[0011] Furthermore, the obtaining of required data by calling the database interface to generate a data dictionary and converting the data into target data includes:
[0012] The interface data of the VINBOM database is called to generate string set data, the json_load function of Python is used to convert the string set data into the data dictionary, and then the data dictionary is converted to generate target JSON data.
[0013] Furthermore, the data dictionary is converted into target JSON data using Python's json_dump function.
[0014] Furthermore, the intercepting and reorganizing the fields in the source data of the software that need to be DIFF compared to generate the data to be compared includes:
[0015] The source data is formatted into standard format data, and the fields that need to be DIFF compared in the standard format data are intercepted and reorganized to form the data to be compared.
[0016] Furthermore, the source data, the standard format data and the data to be compared are all in JSON format.
[0017] Furthermore, the use of the DIFF method to compare the data to be compared and the target data includes:
[0018] When there are multiple nested references in the data to be compared and the fields to be DIFF compared in the target data, all key-value pairs in the data to be compared are traversed to generate first intermediate source data, all key-value pairs in the target data are traversed to generate first intermediate target data, and DIFF comparison is performed on each of the key-value pairs in the first intermediate source data and the first intermediate target data to obtain the DIFF comparison result;
[0019] Otherwise, only the first group of key-value pairs in the data to be compared is traversed to generate the second intermediate source data, only the first group of key-value pairs in the target data is traversed to generate the second intermediate target data, and a DIFF comparison is performed on each of the key-value pairs in the second intermediate source data and the second intermediate target data to obtain the DIFF comparison result.
[0020] Furthermore, the use of the DIFF method to compare the data to be compared and the target data also includes:
[0021] When performing a DIFF comparison on each of the key-value pairs in the first intermediate source data and the first intermediate target data, and when performing a DIFF comparison on each of the key-value pairs in the second intermediate source data and the second intermediate target data, the cases where each of the key-value pairs passes the DIFF comparison are counted separately, and the counting results are displayed in the final file of the DIFF comparison results.
[0022] Furthermore, the content of the counting result displayed in the final file of the DIFF comparison result includes:
[0023] The total number of key-value pairs compared in this DIFF, the number of successful matches, and the number of failed matches.
[0024] Compared with the prior art, the present invention has the following advantages:
[0025] The software data comparison method based on DIFF of the present invention can retrieve the required data of the key string by utilizing the parameter interface of the software database to generate a data dictionary, and then convert it into target data as a standard for comparison and error correction; intercept the fields that need to be DIFF compared in the software source data to generate the data to be compared, and then use the DIFF comparison method to automatically and efficiently realize the testing and error checking of the software data, thereby greatly improving the testing efficiency, and realizing the full data inspection and testing of the source data, which is beneficial to improving the reliability of the software.
[0026] In addition, the database uses the VINBOM database, which can fully utilize the stable characteristics of the VINBOM database technology architecture and can well complete the storage and reading of software-related data; the target data uses the JSON format, which is a lightweight data exchange format. It uses a text format that is completely independent of the programming language to store and represent data. It has a concise and clear hierarchical structure and can facilitate data exchange.
[0027] Another object of the present invention is to provide a storage medium, wherein at least one computer program is stored in the storage medium, and the DIFF-based software data comparison method as described in the present invention can be implemented by loading and executing the computer program through a processor.
[0028] The storage medium of the present invention has the technical advantages possessed by the above-mentioned DIFF-based software data comparison method. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings, which constitute part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention. The directional terms such as front and back, up and down, etc. involved therein are only used to indicate relative positional relationships and do not constitute improper limitations on the present invention. In the accompanying drawings:
[0030] Figure 1 This is a schematic diagram of the overall steps of the DIFF-based software data comparison method according to the first embodiment of the present invention;
[0031] Figure 2 This is a schematic diagram of source data according to Embodiment 1 of the present invention;
[0032] Figure 3 This is a schematic diagram of standard format data formed by formatting source data according to Embodiment 1 of the present invention;
[0033] Figure 4 A schematic diagram of comparing new and old data in the software data comparison method according to the first embodiment of the present invention;
[0034] Figure 5 A schematic diagram of a final file generated by the DIFF comparison result according to the first embodiment of the present invention;
[0035] Figure 6 This is a schematic diagram of a final file with comparison situation count display according to the first embodiment of the present invention. DETAILED DESCRIPTION
[0036] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0037] In the description of the present invention, limiting terms such as "first, second, A, B, C, D" are only used to distinguish similar features of different positions, affiliations or uses, etc., so as to achieve the descriptive purpose of avoiding ambiguity and confusion, and cannot be understood as indicating or implying relative importance. Among them, DIFF (Data DIFFerence) described in the present invention is a brand-new concept proposed for the field of data analysis. It is different from previous data analysis methods. It processes and analyzes a large amount of raw data and then returns the final result to the user. The purpose of DIFF is to use this data as the basis for business decisions, so it has very high requirements for data.
[0038] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0039] Embodiment 1
[0040] This embodiment relates to a software data comparison method based on DIFF, which is conducive to improving software testing efficiency; an exemplary step flow is as follows: Figure 1 shown.
[0041] In general, the DIFF-based software data comparison method includes:
[0042] Obtain the required data through the database interface to generate a data dictionary and convert it into target data;
[0043] The fields that need to be DIFF compared in the source data of the software are intercepted and reorganized to generate data to be compared, and the data to be compared and the target data are compared using the DIFF method to obtain a DIFF comparison result.
[0044] As known to those skilled in the art, the biggest feature of DIFF (Data DIFFerence) is that it processes a large amount of raw data, which is exactly the opposite of the general method of statistical analysis of raw data. Because in statistical analysis, a large amount of raw data needs to be processed, and in many cases we have no way to manually check and compare all the raw data, so we can only screen out some representative and valuable data. But DIFF is different. It requires that all raw data must be processed and analyzed, which leads to the screening of raw data and detailed processing of key area data. The software data comparison method of this embodiment is aimed at the requirements and characteristics of the above-mentioned DIFF comparison, and the source data of the software and the data dictionary obtained from the database are standardizedly transformed and sorted, so as to meet the requirements of DIFF comparison.
[0045] Specifically, the database of this embodiment preferably adopts VINBOM database, and the target data preferably adopts target JSON data in JSON format. The database adopts VINBOM database, which can make full use of the stable characteristics of VINBOM database technology architecture and can well complete the storage and reading of software-related data; the target data adopts JSON format, which is a lightweight data exchange format that uses a text format completely independent of the programming language to store and represent data, has a concise and clear hierarchical structure, and can easily exchange data.
[0046] Before performing DIFF comparison, first obtain the required data by calling the database interface to generate a data dictionary and convert it into target data. Specifically, it includes:
[0047] The interface data of the VINBOM database is called to generate string set data, and the json_load function of Python is used to convert the string set data into a data dictionary, and then the data dictionary is converted to generate the target JSON data. Furthermore, when converting the target JSON data from the data dictionary, it is also preferred to use the json_dump function of Python. The interface data of the database can be used to comprehensively obtain the key strings in the software source data, thereby generating the content to be compared and tested. In addition, the use of Python's related functions for data conversion has good applicability and high conversion efficiency, and can convert string set data and data dictionary data into data content that is convenient for DIFF comparison.
[0048] When intercepting and reorganizing the fields that need to be DIFF compared in the source data of the software to generate the data to be compared, the following are specifically included:
[0049] First, the source data is formatted into standard format data, and then the fields that need to be DIFF compared in the reorganized standard format data are intercepted to form the data to be compared.
[0050] Preferably, the above-mentioned source data, standard format data and data to be compared are also in JSON format. As shown in Figure 2, an example of a file of source data is shown; Figure 3 An exemplary file of the standard format data after formatting is shown. Similar to the format adopted by the target data, the source data, the standard format data and the data to be compared are all in JSON format, which has a concise and clear hierarchical structure, facilitating subsequent data exchange and comparison.
[0051] Based on the above data preprocessing, when using the DIFF method to compare the data to be compared and the target data, it can be divided into the following two cases:
[0052] Case 1: When there are multiple nested references in the data to be compared and the fields to be DIFF compared in the target data, all key-value pairs (i.e., KEY and VALUE) in the data to be compared are traversed to generate the first intermediate source data, all key-value pairs in the target data are traversed to generate the first intermediate target data, and DIFF comparison is performed on each key-value pair in the first intermediate source data and the first intermediate target data to obtain the DIFF comparison result;
[0053] Case 2: When there are no multiple nested references to the fields to be compared in the data to be compared and the target data (that is, the fields to be compared are unique), only the first group of key-value pairs in the data to be compared are traversed to generate the second intermediate source data, only the first group of key-value pairs in the target data are traversed to generate the second intermediate target data, and a DIFF comparison is performed on each key-value pair in the second intermediate source data and the second intermediate target data to obtain the DIFF comparison result.
[0054] During the DIFF comparison process, the comparison processing of the fields can be referred to Figure 4 As shown, the new and old data are compared. If the content is the same, the test passes; if there is a difference, the old start subscript moves back one space. Figure 2 The new and old nodes at position a are the same, and the position moves to position b. At this time, the new node is f, and the two nodes are different, so the new and old data are updated and adjusted.
[0055] FIG5 shows a final file generated by an exemplary DIFF comparison result; in addition, Figure 6 As shown, preferably, in the process of comparing the data to be compared and the target data using the DIFF method, the following contents may also be included:
[0056] When performing DIFF comparison on each key-value pair in the first intermediate source data and the first intermediate target data, and when performing DIFF comparison on each key-value pair in the second intermediate source data and the second intermediate target data, the cases where each key-value pair passes the DIFF comparison are counted separately, and the counting results are displayed in the final file of the DIFF comparison results.
[0057] And, as shown in the figure, preferably, the content displayed in the final file of the DIFF comparison result regarding the counting result should include the total number of key-value pairs compared in this DIFF, the number of successful comparisons, and the number of failed comparisons.
[0058] By displaying the total number of compared key-value pairs, the number of successful comparisons, and the number of failed comparisons in the final file, programmers can understand the overall testing status of the software at a glance.
[0059] To sum up, the DIFF-based software data comparison method of this embodiment, by utilizing the parameter interface of the software database, can retrieve the required data of the key string to generate a data dictionary, and then convert it into target data as a standard for comparison and error correction; intercept the fields that need to be DIFF compared in the software source data to generate data to be compared, and then use the DIFF comparison method to automatically and efficiently realize the testing and error checking of the software data, thereby greatly improving the testing efficiency, and realizing the full data inspection and testing of the source data, which is beneficial to improving the reliability of the software.
[0060] Embodiment 2
[0061] This embodiment relates to a storage medium, which stores at least one computer program compiled based on the software data comparison method of the first embodiment. By loading and executing the computer program through a processor, the DIFF-based software data comparison method of the first embodiment can be implemented.
[0062] In the specific implementation, the entire software testing process includes the following steps: test design->BVT test->security test->performance test->regression test->DIFF comparison test->continuous integration->result notification->analysis and adjustment, among which the DIFF comparison test can adopt the software data comparison method of the first embodiment.
[0063] In this way, the entire testing process is automated to the greatest extent possible. Compared with manual comparison methods, it can greatly shorten the testing cycle and reduce testing costs.
[0064] The above software data comparison method improves the efficiency and accuracy of data comparison by optimizing algorithms for different data types and sizes. By preprocessing and cleaning the data, noise and invalid data can be eliminated, thus improving the accuracy of data comparison.
[0065] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A software data comparison method based on DIFF, characterized in that: include: Obtain the required data through the database interface to generate a data dictionary and convert it into target data; The fields that need to be compared by DIFF in the source data of the software are intercepted and reorganized to generate data to be compared, and the data to be compared and the target data are compared by using the DIFF method to obtain a DIFF comparison result.
2. The DIFF-based software data comparison method according to claim 1, characterized in that: The database adopts VINBOM database, and the target data is target JSON data in JSON format.
3. The DIFF-based software data comparison method according to claim 2, characterized in that: The step of obtaining the required data by calling the database interface to generate a data dictionary and converting the data into target data includes: The interface data of the VINBOM database is called to generate string set data, the json_load function of Python is used to convert the string set data into the data dictionary, and then the data dictionary is converted to generate target JSON data.
4. The DIFF-based software data comparison method according to claim 3, characterized in that: The data dictionary is converted into target JSON data using Python's json_dump function.
5. The DIFF-based software data comparison method according to claim 1, characterized in that: The intercepting and reorganizing the fields in the source data of the software that need to be DIFF compared to generate the data to be compared includes: The source data is formatted into standard format data, and the fields that need to be DIFF compared in the standard format data are intercepted and reorganized to form the data to be compared.
6. The DIFF-based software data comparison method according to claim 5, characterized in that: The source data, the standard format data and the data to be compared are all in JSON format.
7. The DIFF-based software data comparison method according to any one of claims 1 to 6, characterized in that: The use of the DIFF method to compare the data to be compared and the target data includes: When there are multiple nested references in the data to be compared and the fields to be DIFF compared in the target data, all key-value pairs in the data to be compared are traversed to generate first intermediate source data, all key-value pairs in the target data are traversed to generate first intermediate target data, and DIFF comparison is performed on each of the key-value pairs in the first intermediate source data and the first intermediate target data to obtain the DIFF comparison result; Otherwise, only the first group of key-value pairs in the data to be compared is traversed to generate the second intermediate source data, only the first group of key-value pairs in the target data is traversed to generate the second intermediate target data, and a DIFF comparison is performed on each of the key-value pairs in the second intermediate source data and the second intermediate target data to obtain the DIFF comparison result.
8. The DIFF-based software data comparison method according to claim 7, characterized in that: The use of the DIFF method to compare the data to be compared and the target data also includes: When performing a DIFF comparison on each of the key-value pairs in the first intermediate source data and the first intermediate target data, and when performing a DIFF comparison on each of the key-value pairs in the second intermediate source data and the second intermediate target data, the cases where each of the key-value pairs passes the DIFF comparison are counted separately, and the counting results are displayed in the final file of the DIFF comparison results.
9. The DIFF-based software data comparison method according to claim 8, characterized in that: The count results are displayed in the final file of the DIFF comparison result, including: The total number of key-value pairs compared in this DIFF, the number of successful matches, and the number of failed matches.
10. A storage medium, characterized in that: At least one computer program is stored in the storage medium, and the DIFF-based software data comparison method according to any one of claims 1 to 9 can be implemented by loading and executing the computer program by the processor.