Coverage testing method and device in Android software integration testing

By combining the sub-test coverage data and the difference log, only the diff method of the publishing branch was tested for the integration coverage, which solved the problem that the unchanged part of the code was not changed after the code was merged, and improved the efficiency of Android software integration testing.

CN112463620BActive Publication Date: 2024-09-17GUANGZHOU PINWEI SOFTWARE CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202011406234.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-03
Publication Date
2024-09-17
Estimated Expiration
2040-12-03

AI Technical Summary

Technical Problem

In Android software integration test, some codes that have not been changed after the code is merged still need to be tested repeatedly, resulting in inefficient testing.

Method used

By obtaining the sub-test coverage data of all version branches of the software to be tested and the difference log of the publishing branch, combining the sub-test coverage data, detecting diff methods and non-diff methods, only the integrated coverage test of the diff methods is carried out to generate the final Integrated coverage report, reuses individually tested code coverage data.

Benefits of technology

Improve the testing efficiency of publishing branch code, avoid repeated testing of unchanged code, and improve testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112463620B
    Figure CN112463620B
Patent Text Reader

Abstract

The present application relates to a coverage test method, device, computer equipment and storage medium in an Android software integration test. The method includes: obtaining the sub-test coverage data of all version branches of the software to be tested in the current version; obtaining the difference log of the release branch of the software to be tested in the current version, merging the sub-test coverage data of all version branches according to the difference log to obtain the merged sub-test coverage data; detecting all diff methods and all non-diff methods of the release branch according to the difference log, and performing an integrated coverage test on the code corresponding to all diff methods in the release branch code to obtain the initial integrated test coverage data; merging the initial integrated test coverage data with the merged sub-test coverage data to obtain the final integrated test coverage data, and generating a coverage report based on it. When the present application performs coverage testing on the release branch code, it is able to reuse the coverage data of the code that has been tested separately, thereby improving the testing efficiency of the release branch code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing technology, and in particular to a coverage testing method, apparatus, computer equipment and storage medium in Android software integration testing. Background Art

[0002] In software testing, it is usually necessary to count the code coverage of the software testing process. Code coverage indicates the degree to which the code can be covered during testing. Generally, software testers decide whether to repeat the software testing based on the code coverage.

[0003] A version of an application may have multiple requirements (for example, dozens of requirements). During development, a branch will be established for each requirement. The code of each developed branch needs to be covered by the test one by one. If no bugs are found in the test of each branch code and the code coverage meets the standard, the code of each branch needs to be merged into the release branch, and then the code of the release branch (that is, the code obtained by merging the code of all branches) is covered. Test.

[0004] However, only part of the code in each branch will be changed after being merged into the release branch. However, the part of the code in each branch that has not been changed after being merged into the release branch also needs to be tested again after the merge, which makes the testing efficiency low. Summary of the invention

[0005] In view of the shortcomings of the prior art, the present invention provides a coverage testing method, apparatus, computer equipment and storage medium in Android software integration testing. The embodiments of the present invention can improve the testing efficiency of released branch codes.

[0006] According to a first aspect, the present invention provides a coverage testing method in Android software integration testing. In one embodiment, the method includes:

[0007] Obtain the sub-test coverage data corresponding to all version branches of the current version of the software to be tested;

[0008] Obtain the difference log corresponding to the release branch of the current version of the software under test. The difference log is generated by diffing the release branch code of the release branch with the original version branch code of all version branches;

[0009] Merge the sub-test coverage data corresponding to all version branches according to the difference log to obtain the merged sub-test coverage data;

[0010] Detect all diff methods and non-diff methods corresponding to the release branch based on the difference log, perform integrated coverage testing on the code corresponding to all diff methods in the release branch code, and obtain the initial integrated coverage data of the release branch;

[0011] Combine the initial centralized test coverage data of the release branch with the merged sub-test coverage data to obtain the final centralized test coverage data;

[0012] Generate the coverage report corresponding to the release branch in the integrated coverage test based on the final integrated test coverage data.

[0013] In one embodiment, the step of obtaining the sub-test coverage data corresponding to all version branches of the current version of the software to be tested includes:

[0014] Obtain multiple branch coverage files uploaded by a test device, the number of test devices is several, and each branch coverage file is generated by a test device performing a branch coverage test on a version branch code of a version branch;

[0015] Generate the sub-test coverage data of each version branch according to the branch coverage file corresponding to each version, and obtain the sub-test coverage data of all version branch codes.

[0016] In one embodiment, the release version code is obtained by merging the original version branch codes of all version branches. The release version code includes the merged version branch code of each version branch. The merged version branch code of each version branch includes class codes of multiple classes. The class code of each class includes method codes of multiple methods.

[0017] In one embodiment, the method further comprises:

[0018] Perform a diff comparison between the merged version branch code of each version branch included in the release branch code and the original version branch code of the version branch, and determine all the difference code lines between the merged version branch code of each version branch and the original version branch code of the version branch;

[0019] Obtain the corresponding position information of all difference code lines in the merged version branch code of each version branch, and generate key-value pair information corresponding to the version branch according to the position information;

[0020] Generate the difference log corresponding to the release branch based on the key-value pair information corresponding to each version branch generated.

[0021] In one embodiment, the key-value pair information corresponding to each version branch includes key name information and key value information;

[0022] The steps of merging the sub-test coverage data corresponding to all version branches according to the difference logs to obtain the merged sub-test coverage data include:

[0023] The sub-test coverage data corresponding to each version branch is merged with the key-value information in the key-value pair information corresponding to the version branch in the difference log to obtain the merged sub-test coverage data.

[0024] In one embodiment, the step of detecting all diff methods and all non-diff methods corresponding to the release branch according to the difference log includes:

[0025] Traverse each method of the release branch, and when traversing to a method, query the difference log. If the diff line information corresponding to the method is queried from the difference log, the method is determined to be a diff method; if the diff line information corresponding to the method is not queried from the difference log, the method is determined to be a non-diff method.

[0026] In one embodiment, the step of merging the initial integrated test coverage data of the release branch with the merged sub-test coverage data to obtain the final integrated test coverage data includes:

[0027] The integrated test coverage data corresponding to each diff method in the initial integrated test coverage data of the release branch is used to replace the diff line information corresponding to the diff method in the merged sub-test coverage data to obtain the final integrated test coverage data.

[0028] In one embodiment, the step of generating a coverage report corresponding to a release branch in an integrated coverage test according to the final integrated coverage data includes:

[0029] For the collection test coverage data corresponding to each non-diff method in the final collection test coverage data, a preset identifier corresponding to the version branch corresponding to the non-diff method is set to obtain the marked collection test coverage data;

[0030] A coverage report in HTML format is generated according to the marked integrated test coverage data. When generating the coverage report, a mark for distinguishing display is added to the integrated test coverage data with a preset mark.

[0031] According to a second aspect, the present invention provides a coverage testing device in an Android software integration test. In one embodiment, the device includes:

[0032] The sub-test data acquisition module is used to obtain the sub-test coverage data corresponding to all version branches of the current version of the software to be tested;

[0033] The difference log acquisition module is used to obtain the difference log corresponding to the release branch of the current version of the software under test. The difference log is generated by diffing the release branch code of the release branch with the original version branch code of all version branches;

[0034] The first data merging module is used to merge the sub-test coverage data corresponding to all version branches according to the difference log to obtain the merged sub-test coverage data;

[0035] The integrated coverage test module is used to detect all diff methods and all non-diff methods corresponding to the release branch according to the difference log, perform integrated coverage testing on the code corresponding to all diff methods in the release branch code, and obtain the initial integrated coverage data of the release branch;

[0036] The second data merging module is used to merge the initial centralized test coverage data of the release branch with the merged sub-test coverage data to obtain the final centralized test coverage data;

[0037] The coverage report generation module is used to generate the coverage report corresponding to the release branch in the integrated coverage test based on the final integrated test coverage data.

[0038] According to a third aspect, the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above method embodiments when executing the computer program.

[0039] According to a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any of the above method embodiments are implemented.

[0040] In an embodiment of the present invention, the sub-test coverage data corresponding to all version branches of the software to be tested in the current version and the difference log corresponding to the release branch of the software to be tested in the current version are obtained, and then the sub-test coverage data corresponding to all version branches are merged according to the difference log to obtain the merged sub-test coverage data, and then all diff methods and all non-diff methods corresponding to the release branch are detected according to the difference log, and the code corresponding to all the diff methods in the release branch code is subjected to an integrated coverage test to obtain the initial integrated test coverage data of the release branch, and then the initial integrated test coverage data of the release branch is merged with the merged sub-test coverage data to obtain the final integrated test coverage data, and finally the coverage report corresponding to the release branch in the integrated coverage test is generated according to the final integrated test coverage data. In this embodiment, when performing coverage testing on the release branch code of the release branch, the coverage data of the code that has been tested separately is reused, so that there is no need to test the code that has been tested separately again, thereby improving the test efficiency of code coverage testing on the release branch code. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 An application environment diagram of a coverage testing method in an Android software integration test in an embodiment;

[0042] Figure 2 A schematic diagram of a flow chart of a coverage testing method in an Android software integration test in one embodiment;

[0043] Figure 3 It is a structural block diagram of a coverage testing device in an Android software integration test in an embodiment;

[0044] Figure 4 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0046] like Figure 1 The figure shows the application environment of the coverage testing method in Android software integration testing in one embodiment of the present invention.

[0047] The test server 10 is connected to multiple test devices (such as Figure 121 / 22 / 23 shown), communicate through the network. In one embodiment, the test server 10 can send a development kit of one or more version branches of the software to be tested to each test device, so that the test device can perform software testing on the development kit it receives, and after completing the test, upload the test data (such as ec file) to the test server 10. The test server 10 will store the data returned by the test device in the database for backup, so that the test server 10 can perform subsequent integration testing based on the data returned by the test device. It should be noted that each test device can be used to test apk packages of one or more version branches. The test device can be but is not limited to various smart phones, tablet computers, etc. The test server 10 can be implemented with an independent server or a server cluster consisting of multiple servers.

[0048] The present invention provides a coverage test method in Android software integration test. Figure 1 The test server in FIG. 1 is used as an example to illustrate. In one embodiment, Figure 2 As shown, the method comprises the following steps:

[0049] S110: Obtain sub-test coverage data corresponding to all version branches of the current version of the software to be tested.

[0050] In this embodiment, a version of an application may have multiple requirements (such as dozens of requirements). During development, a branch will be established for each requirement for separate development. The code of each developed branch needs to be tested one by one (for the convenience of distinction, the coverage test of the branch code is called branch coverage test). If the code of each branch passes the test, that is, no bugs are found in the test and the code coverage meets the standard, the code of each branch needs to be merged into the release branch, and then the code of the release branch (that is, the code obtained by merging the codes of all branches) is integrated (for the convenience of distinction, the coverage test of the release branch code in the integration test is called integration coverage test). When the release branch code (that is, the code of the release branch) of the current version of the software to be tested is integrated, the sub-test coverage data corresponding to all version branches of the software to be tested in the current version is obtained. The sub-test coverage data corresponding to the version branch is obtained by performing branch coverage test on the code of the version branch (that is, the version branch code).

[0051] In one embodiment, the step of obtaining the sub-test coverage data corresponding to all version branches of the software to be tested in the current version includes: obtaining multiple branch coverage files uploaded by a test device, the number of test devices is several, and each branch coverage file is generated by a test device performing a branch coverage test on the version branch code of a version branch; generating the sub-test coverage data for each version branch according to the branch coverage file corresponding to each version, and obtaining the sub-test coverage data for all version branch codes.

[0052] In this embodiment, for the original version branch code (the original version branch code refers to the code of the version branch before it is merged into the release branch) of each version branch (different version branches can be distinguished by assigning different commitids), the test server uses static insertion to package the original version branch code into an apk package (wherein a mark bit is inserted for each line of code during insertion, such as the mark bit is set to false by default to indicate that the code has not been executed), and backs up the compilation process file classes file, and then sends the apk package to the test device. After receiving the apk package, the test device runs the apk package and executes the test case. The test device will modify the mark bit corresponding to the executed code in the apk package, such as changing false to true (indicating that the code has been executed). After executing the test case, the test device saves the mark bit information of all the code in the apk package as a ec file and upload it to the test server. The test device will test the apk package multiple times, and upload the generated ec file to the test server after each test. Therefore, the test server will receive multiple ec files related to an apk. After the test device completes all tests on an apk package, the test server will merge the multiple ec files related to the apk package to obtain a merged ec file, and then use the jacoco command line tool (an open source coverage testing tool) to load the previously backed up classes file and the merged ec file to generate a coverage report, that is, the sub-test coverage data of the original version branch code (referring to the coverage data measured by the original version branch code in the branch coverage test), which may include which code lines in the original version branch code have been executed during branch testing, which have not been executed, and the proportion of executed code in this part of the code.

[0053] S120: Obtain the difference log corresponding to the release branch of the current version of the software to be tested.

[0054] In this embodiment, the difference log is generated by performing a diff comparison between the release branch code of the release branch and the original version branch code of all version branches. The release version code is obtained by merging the original version branch code of all version branches, and the release version code includes the merged version branch code of each version branch, and the merged version branch code of each version branch includes the class code of multiple classes, and the class code of each class includes the method code of multiple methods.

[0055] It can be seen from the above description that after the code of each version branch (i.e., the original version branch code) is merged into the release branch, the code of each version branch may be changed, such as a method in a class is changed, etc., so the code before the merge (i.e., the original version branch code) corresponding to each version branch is not completely the same as the code after the merge (i.e., the merged version branch code). Through the difference log of the release branch, it is possible to detect the part of the code that has not been changed after the merge and the part of the code that has been changed contained in the merged branch code of each version branch in the release branch code. For the part of the code that has not been changed after the merge of each version branch, this embodiment does not perform coverage testing on it in the integration test, but reuses the corresponding coverage data (which may include which lines of code in the part of the code have been executed during the branch test, which have not been executed, and the proportion of the executed code in the part of the code) in the part of the code.

[0056] The difference log corresponding to the release branch of the current version of the software to be tested can be pre-generated and stored in the database, and then obtained from the database when needed for integrated coverage testing, or it can be regenerated during integrated coverage testing.

[0057] In one embodiment, the process of the test server generating the above-mentioned difference log can be as follows: diff the merged version branch code of each version branch included in the release branch code with the original version branch code of the version branch, and determine all the difference code lines that exist in the merged version branch code of each version branch relative to the original version branch code of the version branch; obtain the corresponding position information of all the difference code lines existing in the merged version branch code of each version branch, and generate key-value pair information corresponding to the version branch according to the position information; generate the difference log corresponding to the release branch according to the generated key-value pair information corresponding to each version branch.

[0058] Specifically, the diff command of the git tool can be used to compare the difference code lines of each version branch's merged branch code relative to the original version branch code. The position information of the difference code line in the merged branch code is used to determine which merged branch code the difference code line belongs to, which class in the code, which method in the class, and which line in the method. Exemplarily, it may include file names such as version branch identifiers, class names and method names, and the number of lines corresponding to the difference code line. Each version branch corresponds to a key-value pair information, and the key-value pair information (i.e., key-value) corresponding to each version branch includes key name information (i.e., key) and key value information (i.e., value). Exemplarily, the storage format may be as follows:

[0059]

[0060] The key name information of the version branch can be the branch identifier of the version branch, or it can be the file name (such as "Filename" in the above example), and the key value information can be the information of all classes included in the version branch. The information of each class is also stored in the form of a key-value pair. The class name (such as "classA" in the above example) can be used as the key name (i.e. key) of the key-value pair, and the information of all methods in the class can be used as the key value (i.e. value) corresponding to the key name. The information of each method can also be stored in the form of a key-value pair, with the method name (such as "methodA-1" in the above example) as the key name (i.e. key), and the difference in code lines in the method, i.e. the number of diff lines (or line numbers) as the key value (i.e. value) corresponding to the key name. For example, the number of diff lines corresponding to "methodA-1" in the above example is 1 and 2, which means that the first and second lines of code in the method "methodA-1" belong to the diff lines.

[0061] S130: Merge the sub-test coverage data corresponding to all version branches according to the difference log to obtain merged sub-test coverage data.

[0062] In this embodiment, when merging the sub-test coverage data of each version branch, the test server merges the sub-test coverage data corresponding to each version branch with the key value information in the key value pair information corresponding to the version branch in the difference log to obtain the merged sub-test coverage data.

[0063] Specifically, the test server can traverse each method in each class of each version branch in the order of file-class-method, and then determine whether the method is a diff method or a non-diff method based on the diff line information corresponding to the method in the difference log. If the traversed method is a non-diff method, then the sub-test coverage data corresponding to the non-diff method is merged into the difference log. For example, "classA" in the above example contains non-diff methods "methodA-3" and "methodA-4", and the sub-test coverage data corresponding to these two methods are full coverage and 1 / 2 / 5 line coverage respectively. Then the merged sub-test coverage data of "classA" can be:

[0064] "classA":{

[0065] "methodA-3":[-1],"methodA-4":[1,2,5]

[0066] };

[0067] Among them, "-1" means full coverage.

[0068] After the sub-test coverage data of each non-diff method of each version branch is merged into the difference log using the above-mentioned method of merging coverage data, the merged sub-test coverage data is obtained.

[0069] S140: Detect all diff methods and all non-diff methods corresponding to the release branch according to the difference log, perform integrated coverage testing on the code corresponding to all the diff methods in the release branch code, and obtain initial integrated coverage data of the release branch.

[0070] In this embodiment, when the test server detects all diff methods and all non-diff methods corresponding to the release branch according to the difference log, it traverses each method (method) of the release branch, and specifically can traverse in the order of file-class-method. When traversing to a method, it queries the difference log. If the diff line information corresponding to the method is obtained from the difference log (for example, "methodA-1": [1,2] in the above example, the diff line information refers to [1,2]), the method is determined to be a diff method. Specifically, a method usually contains multiple lines of code. As long as there is a line of code that belongs to the diff line (that is, it belongs to the difference code line), it is determined that the method belongs to the diff method. If the diff line information corresponding to the method cannot be found from the difference log, the method is determined to be a non-diff method.

[0071] The test server obtains the code corresponding to all diff methods corresponding to the release branch (that is, the code corresponding to the diff method in the merged branch code of all version branches) through the difference log for integrated coverage testing, thereby obtaining the initial integrated test coverage data of the release branch.

[0072] S150: Merge the initial integrated test coverage data of the release branch with the merged sub-test coverage data to obtain the final integrated test coverage data.

[0073] In this embodiment, the test server needs to merge the initial integrated test coverage data obtained with the merged sub-test coverage data to obtain the final integrated test coverage data. Among them, the test server can replace the diff line information corresponding to the diff method in the merged sub-test coverage data with the integrated test coverage data corresponding to each diff method in the initial integrated test coverage data of the release branch, thereby obtaining the final integrated test coverage data.

[0074] For example, in the above example, since "methodA-1" and "methodA-2" in the class "classA" both have corresponding diff line information, both belong to diff methods. After testing them, the corresponding integrated test coverage data of these two diff methods can be obtained from the initial integrated test coverage data as the 2nd / 4th / 6th line coverage and full coverage. Then the combined sub-test coverage data of "classA" can be:

[0075]

[0076] By using the above-mentioned method of merging integrated test coverage data and diff line information to combine the integrated test coverage data of each diff method of each version branch with its corresponding diff line information in the merged sub-test coverage data, the final integrated test coverage data is obtained.

[0077] S160: Generate a coverage report corresponding to the release branch in the integrated coverage test according to the final integrated test coverage data.

[0078] In this embodiment, the test server may continue to use the jacoco tool to load the final set test coverage data and generate a coverage report.

[0079] In one embodiment, the step of generating a coverage report corresponding to the release branch in the integrated coverage test according to the final integrated coverage data includes:

[0080] For the collection test coverage data corresponding to each non-diff method in the final collection test coverage data, a preset identifier corresponding to the version branch corresponding to the non-diff method is set to obtain the marked collection test coverage data;

[0081] A coverage report in HTML format is generated according to the marked integrated test coverage data. When generating the coverage report, a mark for distinguishing display is added to the integrated test coverage data with a preset mark.

[0082] Specifically, the test server will mark the merged coverage data (referring to the reused sub-test coverage data) in the final integrated test coverage data with a preset mark, so that when generating a coverage report, the coverage data with the preset mark in the marked integrated test coverage data can be specially marked in the UI for distinguishing display (for example, adding marks such as @@ or ## in front of the code line), so that people who read the coverage report can intuitively see which coverage data is reused.

[0083] The embodiment of the present invention obtains the sub-test coverage data corresponding to all version branches of the software to be tested in the current version and the difference log corresponding to the release branch of the software to be tested in the current version through a test server, then merges the sub-test coverage data corresponding to all version branches according to the difference log to obtain the merged sub-test coverage data, then detects all diff methods and all non-diff methods corresponding to the release branch according to the difference log, and performs integrated coverage test on the code corresponding to all the diff methods in the release branch code to obtain the initial integrated test coverage data of the release branch, then merges the initial integrated test coverage data of the release branch with the merged sub-test coverage data to obtain the final integrated test coverage data, and finally generates the coverage report corresponding to the release branch in the integrated coverage test according to the final integrated test coverage data. Since the test server can reuse the coverage data of the code that has been tested separately when performing coverage test on the release branch code of the release branch, it is not necessary to test the code that has been tested separately, thereby improving the test efficiency of the code coverage test on the release branch code.

[0084] It should be noted that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0085] Based on the same inventive concept, the present invention also provides a coverage test device in Android software integration test. Figure 3 As shown, the coverage test device in the Android software integration test includes the following modules:

[0086] The sub-test data acquisition module 110 is used to obtain sub-test coverage data corresponding to all version branches of the current version of the software to be tested;

[0087] The difference log acquisition module 120 is used to obtain the difference log corresponding to the release branch of the current version of the software under test. The difference log is generated by performing a diff comparison between the release branch code of the release branch and the original version branch code of all version branches;

[0088] The first data merging module 130 is used to merge the sub-test coverage data corresponding to all version branches according to the difference log to obtain merged sub-test coverage data;

[0089] The integrated coverage test module 140 is used to detect all diff methods and all non-diff methods corresponding to the release branch according to the difference log, perform integrated coverage test on the code corresponding to all diff methods in the release branch code, and obtain the initial integrated coverage data of the release branch;

[0090] The second data merging module 150 is used to merge the initial centralized test coverage data of the release branch with the merged sub-test coverage data to obtain the final centralized test coverage data;

[0091] The coverage report generation module 160 is used to generate a coverage report corresponding to the release branch in the integrated coverage test according to the final integrated test coverage data.

[0092] In one embodiment, the release version code is obtained by merging the original version branch codes of all version branches. The release version code includes the merged version branch code of each version branch. The merged version branch code of each version branch includes class codes of multiple classes. The class code of each class includes method codes of multiple methods.

[0093] In one embodiment, the sub-measurement data acquisition module includes:

[0094] The branch file acquisition submodule is used to acquire multiple branch coverage files uploaded by the test device. The number of test devices is several. Each branch coverage file is generated by a test device performing branch coverage testing on the version branch code of a version branch.

[0095] The sub-module for generating sub-test data is used to generate sub-test coverage data for each version branch according to the branch coverage file corresponding to each version, and obtain sub-test coverage data for all version branch codes.

[0096] In one embodiment, the apparatus further comprises:

[0097] A comparison module is used to perform a diff comparison between the merged version branch code of each version branch included in the release branch code and the original version branch code of the version branch, and determine all the difference code lines between the merged version branch code of each version branch and the original version branch code of the version branch;

[0098] A key-value pair information generation module is used to obtain the corresponding position information of all the difference code lines in the merged version branch code of each version branch, and generate the key-value pair information corresponding to the version branch according to the position information;

[0099] The difference log generation module is used to generate a difference log corresponding to the release branch based on the key-value pair information corresponding to each generated version branch.

[0100] In one embodiment, the key-value pair information corresponding to each version branch includes key name information and key value information. In this embodiment, the first data merging module is also used to merge the sub-test coverage data corresponding to each version branch with the key value information in the key-value pair information corresponding to the version branch in the difference log to obtain the merged sub-test coverage data.

[0101] In one embodiment, the integrated coverage test module is also used to traverse each method of the release branch. When traversing to a method, the difference log is queried. If the diff line information corresponding to the method is obtained from the difference log, the method is determined to be a diff method; if the diff line information corresponding to the method is not found from the difference log, the method is determined to be a non-diff method.

[0102] In one embodiment, the second data merging module is also used to replace the diff line information corresponding to the diff method in the merged sub-test coverage data with the integrated test coverage data corresponding to each diff method in the initial integrated test coverage data of the release branch to obtain the final integrated test coverage data.

[0103] In one embodiment, the coverage report generation module includes:

[0104] A preset mark setting submodule is used to set a preset mark corresponding to the version branch corresponding to the non-diff method for the final set test coverage data corresponding to each non-diff method, so as to obtain the marked set test coverage data;

[0105] The coverage report generation submodule is used to generate a coverage report in HTML format based on the marked integrated test coverage data. When generating the coverage report, a mark for distinguishing display is added to the integrated test coverage data with a preset mark.

[0106] For the specific definition of the coverage testing device in the Android software integration test, please refer to the definition of the coverage testing method in the Android software integration test in the above text, which will not be repeated here. Each module in the above-mentioned coverage testing device in the Android software integration test can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0107] In one embodiment, a computer device is provided, whose internal structure diagram can be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as sub-test coverage data and sub-test coverage files. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a coverage testing method in an Android software integration test is implemented.

[0108] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0109] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0110] Obtain the sub-test coverage data corresponding to all version branches of the software under test in the current version; obtain the difference log corresponding to the release branch of the software under test in the current version, the difference log is generated by diffing the release branch code of the release branch with the original version branch code of all version branches; merge the sub-test coverage data corresponding to all version branches according to the difference log to obtain the merged sub-test coverage data; detect all diff methods and all non-diff methods corresponding to the release branch according to the difference log, perform integrated coverage test on the code corresponding to all diff methods in the release branch code, and obtain the initial integrated test coverage data of the release branch; merge the initial integrated test coverage data of the release branch with the merged sub-test coverage data to obtain the final integrated test coverage data; generate the coverage report corresponding to the release branch in the integrated coverage test according to the final integrated test coverage data.

[0111] In one embodiment, when the processor executes the computer program to obtain the sub-test coverage data corresponding to all version branches of the current version of the software to be tested, the processor also implements the following steps:

[0112] Get multiple branch coverage files uploaded by the test device, the number of test devices is several, each branch coverage file is generated by a test device performing branch coverage testing on the version branch code of a version branch; generate separate test coverage data for each version branch according to the branch coverage file corresponding to each version, and obtain separate test coverage data for all version branch codes.

[0113] In one embodiment, the release version code is obtained by merging the original version branch codes of all version branches, and the release version code includes the merged version branch code of each version branch, and the merged version branch code of each version branch includes the class codes of multiple classes, and the class code of each class includes the method codes of multiple methods. The processor executes the computer program and further implements the following steps:

[0114] Diff the merged version branch code of each version branch included in the release branch code with the original version branch code of the version branch to determine all the difference code lines in the merged version branch code of each version branch relative to the original version branch code of the version branch; obtain the corresponding position information of all the difference code lines in the merged version branch code of each version branch, and generate the key-value pair information corresponding to the version branch according to the position information; generate the difference log corresponding to the release branch according to the generated key-value pair information corresponding to each version branch.

[0115] In one embodiment, the key-value pair information corresponding to each version branch includes key name information and key value information; the processor executes a computer program to merge the sub-test coverage data corresponding to all version branches according to the difference log, and when the merged sub-test coverage data is obtained, the following steps are also implemented:

[0116] The sub-test coverage data corresponding to each version branch is merged with the key-value information in the key-value pair information corresponding to the version branch in the difference log to obtain the merged sub-test coverage data.

[0117] In one embodiment, when the processor executes the computer program to detect all diff methods and all non-diff methods corresponding to the release branch according to the difference log, the processor also implements the following steps:

[0118] Traverse each method of the release branch, and when traversing to a method, query the difference log. If the diff line information corresponding to the method is queried from the difference log, the method is determined to be a diff method; if the diff line information corresponding to the method is not queried from the difference log, the method is determined to be a non-diff method.

[0119] In one embodiment, when the processor executes the computer program to merge the initial integrated test coverage data of the release branch with the merged sub-test coverage data to obtain the final integrated test coverage data, the following steps are also implemented:

[0120] The integrated test coverage data corresponding to each diff method in the initial integrated test coverage data of the release branch is used to replace the diff line information corresponding to the diff method in the merged sub-test coverage data to obtain the final integrated test coverage data.

[0121] In one embodiment, when the processor executes the computer program, when generating a coverage report corresponding to the release branch in the integrated coverage test according to the final integrated test coverage data, the following steps are also implemented:

[0122] For the final integrated test coverage data corresponding to each non-diff method, a preset identifier corresponding to the version branch corresponding to the non-diff method is set to obtain the marked integrated test coverage data; a coverage report in HTML format is generated according to the marked integrated test coverage data, and when generating the coverage report, a mark for distinguishing display is added to the integrated test coverage data set with the preset identifier.

[0123] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0124] Obtain the sub-test coverage data corresponding to all version branches of the software under test in the current version; obtain the difference log corresponding to the release branch of the software under test in the current version, the difference log is generated by diffing the release branch code of the release branch with the original version branch code of all version branches; merge the sub-test coverage data corresponding to all version branches according to the difference log to obtain the merged sub-test coverage data; detect all diff methods and all non-diff methods corresponding to the release branch according to the difference log, perform integrated coverage test on the code corresponding to all diff methods in the release branch code, and obtain the initial integrated test coverage data of the release branch; merge the initial integrated test coverage data of the release branch with the merged sub-test coverage data to obtain the final integrated test coverage data; generate the coverage report corresponding to the release branch in the integrated coverage test according to the final integrated test coverage data.

[0125] In one embodiment, the computer program is executed by a processor to obtain the sub-test coverage data corresponding to all version branches of the current version of the software to be tested, and further implement the following steps:

[0126] Get multiple branch coverage files uploaded by the test device, the number of test devices is several, each branch coverage file is generated by a test device performing branch coverage testing on the version branch code of a version branch; generate separate test coverage data for each version branch according to the branch coverage file corresponding to each version, and obtain separate test coverage data for all version branch codes.

[0127] In one embodiment, the release version code is obtained by merging the original version branch codes of all version branches, and the release version code includes the merged version branch code of each version branch, and the merged version branch code of each version branch includes the class code of multiple classes, and the class code of each class includes the method code of multiple methods. The computer program is executed by the processor, and the following steps are also implemented:

[0128] Diff the merged version branch code of each version branch included in the release branch code with the original version branch code of the version branch to determine all the difference code lines in the merged version branch code of each version branch relative to the original version branch code of the version branch; obtain the corresponding position information of all the difference code lines in the merged version branch code of each version branch, and generate the key-value pair information corresponding to the version branch according to the position information; generate the difference log corresponding to the release branch according to the generated key-value pair information corresponding to each version branch.

[0129] In one embodiment, the key-value pair information corresponding to each version branch includes key name information and key value information; the computer program is executed by a processor, and when the sub-test coverage data corresponding to all version branches are merged according to the difference log, the merged sub-test coverage data is obtained, and the following steps are further implemented:

[0130] The sub-test coverage data corresponding to each version branch is merged with the key-value information in the key-value pair information corresponding to the version branch in the difference log to obtain the merged sub-test coverage data.

[0131] In one embodiment, when the computer program is executed by a processor and all diff methods and all non-diff methods corresponding to a release branch are detected according to the difference log, the following steps are further implemented:

[0132] Traverse each method of the release branch, and when traversing to a method, query the difference log. If the diff line information corresponding to the method is queried from the difference log, the method is determined to be a diff method; if the diff line information corresponding to the method is not queried from the difference log, the method is determined to be a non-diff method.

[0133] In one embodiment, the computer program is executed by a processor to merge the initial integrated test coverage data of the release branch with the merged sub-test coverage data to obtain the final integrated test coverage data, and further implement the following steps:

[0134] The integrated test coverage data corresponding to each diff method in the initial integrated test coverage data of the release branch is used to replace the diff line information corresponding to the diff method in the merged sub-test coverage data to obtain the final integrated test coverage data.

[0135] In one embodiment, when the computer program is executed by a processor, when generating a coverage report corresponding to a release branch in an integrated coverage test according to the final integrated coverage data, the following steps are further implemented:

[0136] For the final integrated test coverage data corresponding to each non-diff method, a preset identifier corresponding to the version branch corresponding to the non-diff method is set to obtain the marked integrated test coverage data; a coverage report in HTML format is generated according to the marked integrated test coverage data, and when generating the coverage report, a mark for distinguishing display is added to the integrated test coverage data set with the preset identifier.

[0137] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0138] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0139] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A coverage testing method in Android software integration testing, characterized in that: include: Obtain the sub-test coverage data corresponding to all version branches of the current version of the software to be tested; Obtaining a difference log corresponding to a release branch of the current version of the software to be tested, wherein the difference log is generated by performing a diff comparison between the release branch code of the release branch and the original version branch code of all the version branches; Merge the sub-test coverage data corresponding to all the version branches according to the difference log to obtain merged sub-test coverage data; According to the difference log, all diff methods and all non-diff methods corresponding to the release branch are detected, and the code corresponding to all the diff methods in the release branch code is subjected to an integrated coverage test to obtain the initial integrated test coverage data of the release branch; wherein the code corresponding to all the non-diff methods in the release branch code is not subjected to the integrated coverage test; Merging the initial centralized test coverage data of the release branch with the merged sub-test coverage data to obtain final centralized test coverage data; Generate a coverage report corresponding to the release branch in the integrated coverage test according to the final integrated coverage data; The release branch code is obtained by merging the original version branch codes of all version branches, and the release branch code includes the merged version branch code of each version branch, and the merged version branch code of each version branch includes the class code of multiple classes, and the class code of each class includes the method code of multiple methods; the method also includes: performing a diff comparison between the merged version branch code of each version branch included in the release branch code and the original version branch code of the version branch, and determining all the difference code lines existing in the merged version branch code of each version branch relative to the original version branch code of the version branch; obtaining the corresponding position information of all the difference code lines existing in the merged version branch code of each version branch, and generating the key-value pair information corresponding to the version branch according to the position information; generating the difference log corresponding to the release branch according to the generated key-value pair information corresponding to each version branch; The key-value pair information corresponding to each of the version branches includes key name information and key value information; the step of merging the sub-test coverage data corresponding to all the version branches according to the difference log to obtain the merged sub-test coverage data includes: merging the sub-test coverage data corresponding to each of the version branches with the key value information in the key-value pair information corresponding to the version branch in the difference log to obtain the merged sub-test coverage data.

2. The coverage testing method in Android software integration testing as claimed in claim 1, characterized in that: The step of obtaining the sub-test coverage data corresponding to all version branches of the current version of the software to be tested includes: Acquire multiple branch coverage files uploaded by a test device, where the number of the test devices is several, and each branch coverage file is generated by one of the test devices performing a branch coverage test on a version branch code of the version branch; Generate the sub-test coverage data of each version branch according to the branch coverage file corresponding to each version, and obtain the sub-test coverage data of all version branch codes.

3. The coverage testing method in Android software integration testing as claimed in claim 1, characterized in that: The step of detecting all diff methods and all non-diff methods corresponding to the release branch according to the difference log includes: Traverse each method of the release branch, and when traversing to a method, query the difference log. If diff line information corresponding to the method is obtained from the difference log, the method is determined to be a diff method; if diff line information corresponding to the method is not found from the difference log, the method is determined to be a non-diff method.

4. The coverage testing method in Android software integration testing as claimed in claim 1, characterized in that: The step of merging the initial centralized test coverage data of the release branch with the merged sub-test coverage data to obtain final centralized test coverage data includes: The centralized test coverage data corresponding to each diff method in the initial centralized test coverage data of the release branch is used to replace the diff line information corresponding to the diff method in the merged sub-test coverage data to obtain the final centralized test coverage data.

5. The coverage testing method in Android software integration testing as claimed in claim 1, characterized in that: The step of generating a coverage report corresponding to the release branch in the integrated coverage test according to the final integrated coverage data includes: For the collection test coverage data corresponding to each of the non-diff methods in the final collection test coverage data, a preset identifier corresponding to the version branch corresponding to the non-diff method is set to obtain the marked collection test coverage data; A coverage report in HTML format is generated according to the marked integrated test coverage data. When generating the coverage report, a mark for distinguishing display is added to the integrated test coverage data with a preset mark.

6. A device for implementing the coverage testing method in Android software integration testing as claimed in claim 1, characterized in that: include: The sub-test data acquisition module is used to obtain the sub-test coverage data corresponding to all version branches of the current version of the software to be tested; A difference log acquisition module is used to obtain the difference log corresponding to the release branch of the current version of the software under test, wherein the difference log is generated by performing a diff comparison between the release branch code of the release branch and the original version branch code of all the version branches; A first data merging module is used to merge the sub-test coverage data corresponding to all the version branches according to the difference log to obtain the merged sub-test coverage data; An integrated coverage test module is used to detect all diff methods and all non-diff methods corresponding to the release branch according to the difference log, perform integrated coverage test on the code corresponding to all diff methods in the release branch code, and obtain the initial integrated coverage data of the release branch; wherein the code corresponding to all non-diff methods in the release branch code is not subjected to the integrated coverage test; A second data merging module is used to merge the initial centralized test coverage data of the release branch with the merged sub-test coverage data to obtain final centralized test coverage data; A coverage report generating module is used to generate a coverage report corresponding to the release branch in the integrated coverage test according to the final integrated coverage data.

7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Method and device for processing multi-version test data

    CN105988926A

  • Regression testing method and device of application software and electronic equipment

    CN106326120A

  • Testing method and device of software difference coverage rate and readable storage medium

    CN107957956A

  • Coverage rate testing method and device and storage equipment

    CN108519945A

  • Code coverage rate computing analysis method and device, equipment and storage medium

    CN108829593A