CN112363945A - Version testing method and device - Google Patents

Version testing method and device Download PDF

Info

Publication number
CN112363945A
CN112363945A CN202011321052.0A CN202011321052A CN112363945A CN 112363945 A CN112363945 A CN 112363945A CN 202011321052 A CN202011321052 A CN 202011321052A CN 112363945 A CN112363945 A CN 112363945A
Authority
CN
China
Prior art keywords
version
code
subprogram
coverage information
tested
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011321052.0A
Other languages
Chinese (zh)
Inventor
程寅捷
李雨泽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sankuai Online Technology Co Ltd
Original Assignee
Beijing Sankuai Online Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sankuai Online Technology Co Ltd filed Critical Beijing Sankuai Online Technology Co Ltd
Priority to CN202011321052.0A priority Critical patent/CN112363945A/en
Publication of CN112363945A publication Critical patent/CN112363945A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present specification discloses a method and an apparatus for testing a version, which determine an incremental code included in a first version compared with a second version as a code to be tested, wherein the first version is a code version to be tested, and the second version is a code version online before the first version. Then, for each transition version between the second version and the first version, determining the incremental code of the program code in the transition version compared with the program code of the second version as the target code corresponding to the transition version, and determining the code coverage information for historically testing the target code corresponding to the transition version. And then, according to the code coverage information of the target code corresponding to each transition version, determining the code coverage information corresponding to the code to be tested, and testing the first version according to the code coverage information corresponding to the code to be tested, thereby improving the testing efficiency aiming at the first version.

Description

Version testing method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for version testing.
Background
Currently, in order to ensure the accuracy of software functions and enable software to provide users with good business experience, the program codes of the software are often required to be tested.
In practical application, after the program code is tested, the condition that the program code is covered in the test process can be determined. The test platform can determine code coverage information for testing the program code, the code coverage information can show a code line of the program code which is run in the test process, and the test platform can determine the code coverage rate according to the code coverage information so as to ensure the integrity of the test of the program code and improve the test efficiency of the test of the program code.
Disclosure of Invention
The present specification provides a version testing method and apparatus for determining a code coverage condition for testing a first version of incremental code as compared to a second version of incremental code.
The technical scheme adopted by the specification is as follows:
the present specification provides a method of version testing, comprising:
determining an incremental code contained in a first version compared with a second version as a code to be tested, wherein the first version is a code version needing to be tested, and the second version is a code version on line before the first version;
for each transition version between the second version and the first version, determining an incremental code included in the program code of the transition version compared with the program code of the second version as a target code corresponding to the transition version, and determining code coverage information for historically testing the target code corresponding to the transition version;
and determining code coverage information corresponding to the code to be tested according to the code coverage information of the target code corresponding to each transition version, and testing the first version according to the code coverage information corresponding to the code to be tested.
Optionally, determining code coverage information of the target code corresponding to the transition version specifically includes:
inquiring code coverage information corresponding to each subprogram in the target code corresponding to the transition version;
and determining the code coverage information of the target code corresponding to the transition version according to the code coverage information corresponding to each subprogram in the target code corresponding to the transition version.
Optionally, determining code coverage information corresponding to the code to be tested according to the code coverage information of the target code corresponding to each transition version, which specifically includes:
determining at least one subprogram matched with the subprogram to be tested in the target code corresponding to each transition version as a target subprogram aiming at each subprogram to be tested in the codes to be tested;
determining code coverage information corresponding to the subprogram to be tested according to the code coverage information corresponding to the at least one target subprogram;
and determining code coverage information corresponding to the code to be tested according to the code coverage information corresponding to each subprogram to be tested in the code to be tested.
Optionally, determining at least one subprogram matched with the subprogram to be tested in the target code corresponding to each transition version, as a target subprogram, specifically including:
determining subprogram abstract information corresponding to the subprogram to be tested;
inquiring subprogram abstract information corresponding to each subprogram in target codes corresponding to each transition version which are stored in advance;
and taking the subprogram with consistent subprogram abstract information corresponding to the subprogram to be tested in each transition version as a target subprogram.
Optionally, the storing the sub program summary information corresponding to each sub program in the object code corresponding to each transition version specifically includes:
determining subprogram summary information corresponding to each subprogram in the target code corresponding to each transition version aiming at each transition version;
determining code coverage information of each subprogram in the test task corresponding to the transition version aiming at each subprogram contained in the target code corresponding to the transition version;
if the subprogram abstract information corresponding to the subprogram is determined not to be stored, correspondingly storing the subprogram abstract information corresponding to the subprogram and the code coverage information corresponding to the subprogram;
and if the subprogram abstract information corresponding to the subprogram is determined to be stored, aggregating the code coverage information corresponding to the subprogram into the code coverage information matched with the subprogram abstract information corresponding to the subprogram.
Optionally, determining an incremental code included in the first version compared with the second version as a code to be tested specifically includes:
and determining the incremental code contained in the first version compared with the second version as the code to be tested according to the subprogram of the change between the first version and the second version.
Optionally, the method further comprises:
and if the first version is determined to meet the preset condition, deleting the stored code coverage information corresponding to each target subprogram in each transition version.
This specification provides an apparatus for version testing, comprising:
the code determination module is used for determining an incremental code contained in a first version compared with a second version as a code to be tested, wherein the first version is a code version needing to be tested, and the second version is an online code version before the first version;
the version determining module is used for determining, for each transition version between the second version and the first version, an incremental code included in the program code in the transition version compared with the program code in the second version as a target code corresponding to the transition version, and determining code coverage information for historically testing the target code corresponding to the transition version;
and the testing module is used for determining the code coverage information corresponding to the code to be tested according to the code coverage information of the target code corresponding to each transition version, and testing the first version according to the code coverage information corresponding to the code to be tested.
The present specification provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the above-described method of versioning.
The present specification provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the above-mentioned versioning test method when executing the program.
The technical scheme adopted by the specification can achieve the following beneficial effects:
in the version testing method provided in the present specification, a first version is determined as a code to be tested, compared with a second version, which is a code version on line before the first version, to be an incremental code included in the first version. Then, for each transition version between the second version and the first version, determining the incremental code of the program code in the transition version compared with the program code of the second version as the target code corresponding to the transition version, and determining the code coverage information for historically testing the target code corresponding to the transition version. And then, according to the code coverage information of the target code corresponding to each transition version, determining the code coverage information corresponding to the code to be tested, and testing the first version according to the code coverage information corresponding to the code to be tested.
It can be seen from the above method that the method can determine complete code coverage information of the code to be tested in the first version, so as to test the first version. Compared with the prior art, the method can integrally consider the coverage condition of the test aiming at the first version, and can improve the test efficiency of the test aiming at the first version.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification and are incorporated in and constitute a part of this specification, illustrate embodiments of the specification and together with the description serve to explain the specification and not to limit the specification in a non-limiting sense. In the drawings:
FIG. 1 is a flow chart of a method for version testing in the present specification;
fig. 2 is a schematic diagram provided in this specification, illustrating that code coverage information corresponding to a code to be tested is determined according to code coverage information of a target code corresponding to each transitional version;
FIG. 3 is a schematic diagram of a version testing apparatus provided herein;
fig. 4 is a schematic diagram of an electronic device corresponding to fig. 1 provided in the present specification.
Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present disclosure, and not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present specification without any creative effort belong to the protection scope of the present specification.
The technical solutions provided by the embodiments of the present description are described in detail below with reference to the accompanying drawings.
In practical application, software development can be performed in an iterative development mode, during the development process, software codes can be modified for multiple times from a current online version to a next online version (referred to as an online version), and the modified software code version after each time can be referred to as a transition version. Each time a transitional version is developed, the tester needs to test this transitional version. In the prior art, after testing the transition version each time, the code coverage information corresponding to the transition version in the test can be determined, so that the condition that the program code of the transition version in the test is covered is obtained. The code coverage information can indicate a proportion of the code lines of the transitional version that are run in the test process to the total code lines.
In the prior art, the online version may be tested, and the code coverage information corresponding to the online version is determined, so as to determine whether the test performed on the online version is complete through the code coverage information. However, there may be some code in the online version that is exactly the same as the previous transitional version, and that has not been tested in the testing task of the online version, but has been tested in the previous transitional version. For such a situation, the code coverage information corresponding to the online version cannot effectively reflect the test condition of each code in the online version, that is, multiple lines of codes in the online version may not be arranged in the test task, so that the developer may need to retest the online version, and the test efficiency of the online version is further reduced.
In order to solve the above problem, a method of version testing is provided in the present specification, in which a test platform may take a version of a next upper line as a first version. The test platform can determine code coverage information corresponding to the code to be tested in the first version according to the code coverage information corresponding to each transition version, and tests the first version according to the code coverage information, and the code coverage information can more completely represent the tested condition of the first version, so that the test efficiency for the first version is improved.
Fig. 1 is a schematic flow chart of a version testing method in this specification, which specifically includes the following steps:
s101: and determining the incremental code contained in the first version compared with the second version as the code to be tested.
In practical application, a test platform needs to test software before the software is online, so as to ensure that the service function corresponding to the software is correctly executed after the software is online. Therefore, the test platform may take the code version of the software to be brought online as the first version. Of course, the test platform may also determine the version to be tested as the first version according to actual requirements.
Based on this, the test platform may determine that the first version contains delta code as compared to the second version as the code to be tested. The second version referred to herein may refer to the version of the code that was online before the first version. Reference herein to delta code may refer to code in a first version of code that is either added or modified compared to a second version of code, the second version of program code being tested since the second version is an already online version of code. That is, the non-incremental code of the first version compared to the non-incremental code of the second version has already been tested, and the incremental code included in the first version compared to the incremental code included in the second version is the code to be tested, and the test platform needs to use the incremental code as the code to be tested. The second version mentioned here may refer to the code version that is listed one time before the first version, or may be the code version that is listed several times before the first version.
The version test method provided in this specification may be specifically executed by a server or a terminal device such as a computer in a test platform, and for convenience of description, the version test method provided in this specification will be described below with only the test platform as an execution subject.
S102: for each transition version between the second version and the first version, determining an incremental code included in the program code of the transition version compared with the program code of the second version as a target code corresponding to the transition version, and determining code coverage information for historically testing the target code corresponding to the transition version.
After the test platform determines the first version and the codes to be tested, for each transition version between the second version and the first version, an incremental code between the program code in the transition version and the program code in the first version may be determined as a target code corresponding to the transition version. The test platform may determine code coverage information for historically testing the target code corresponding to the transitional version, where the target code is the code that needs to be tested in the transitional version, and the code coverage information may be determined by a tool such as Jacoco, EMMA, or the like. The transitional version mentioned here may refer to a code version that iterates between the first version and the second version, and the transitional version is not online but is an intermediate version generated in the development process. The first version is a code version which needs to be online after a plurality of transitional versions. Reference herein to delta code included in the program code in the transitional version as compared to the program code in the second version may refer to program code that is added or modified from the transitional version as compared to the second version. The code coverage information of the object code may be used to represent lines of code in the object code that were run during the test.
In this specification, the object code contains several subroutines, and the subroutines referred to herein may refer to functions (or methods in JAVA). After the test platform tests the target code historically, the code coverage information corresponding to each subprogram in the target code may be saved in advance. Therefore, when the code coverage information of the code to be tested needs to be determined according to the code coverage information of the target code, the test platform may query the code coverage information corresponding to each subprogram in the target code, and then the test platform may determine the code coverage information of the target code corresponding to the transition version according to the code coverage information corresponding to each subprogram in the target code.
S103: and determining code coverage information corresponding to the code to be tested according to the code coverage information of the target code corresponding to each transition version, and testing the first version according to the code coverage information corresponding to the code to be tested.
After the test platform determines the code coverage information of the target code corresponding to each transition version, the test platform can determine the code coverage information corresponding to the code to be tested according to the code coverage information, and test the first version according to the code coverage information corresponding to the code to be tested. The test platform may determine the code coverage information corresponding to the code to be tested according to the code coverage information of the target code corresponding to each transition version.
For example, the test platform may combine the code coverage information of the target code corresponding to each transition version according to the code lines, and determine the coverage condition of each code line of the code to be tested according to the combined code coverage information, thereby determining the code coverage information corresponding to the code to be tested.
Suppose that the code to be tested includes code lines a, b, and c, the target code corresponding to the transition version 1 includes only code lines a and b, and the target code corresponding to the transition version 2 includes code lines a, b, c, and d. The code to be tested comprises code lines a, b and c. Assume that 1 in the code coverage information indicates that the code line is covered, 0 indicates that the code line is not covered, 011 (indicating that the code line a is not covered and the code lines b and c are covered during the test) in the code coverage information of transition version 1, and 0011 (indicating that the code lines a and b are not covered and the code lines c and d are covered during the test) in the code coverage information of transition version 2. The test platform may merge the code coverage information of the transition version 1 and the code coverage information of the transition version 2 to obtain that the merged code coverage information is 0111 (indicating that the code line a is not covered and the code lines b, c, and d are covered), and the test platform may determine that the code coverage information of the code to be tested is 011 (indicating that the code line a in the code to be tested is not covered and the code lines b and c are covered).
For another example, each subprogram (referred to as a subprogram to be tested in this specification) is included in the code to be tested, and the test platform may determine, as the target subprogram, at least one subprogram that matches the subprogram to be tested in the target code corresponding to each transition version for each subprogram to be tested in the code to be tested. Then, the test platform can determine the code coverage information corresponding to the subprogram to be tested according to the code coverage information corresponding to at least one target subprogram, and determine the code coverage information corresponding to the code to be tested according to the code coverage information corresponding to each subprogram to be tested.
Wherein, the target subprogram may refer to a subprogram which is the same as the program code of the subprogram to be tested. The testing platform can determine the subprogram in each transition version, which is consistent with the subprogram code to be tested, as the target subprogram. Since the program code corresponding to the target subprogram is consistent with the program code corresponding to the subprogram to be tested, the code coverage information corresponding to the subprogram to be tested can be determined by the code coverage information corresponding to the target subprogram. And if the subprogram matched with the program code of the subprogram to be tested does not exist in each transition version, the subprogram to be tested does not correspond to the matched target subprogram.
Assume that the code to be tested contains the subprogram to be tested A, B, C, the transition version 1 contains the target subprogram E matched with the subprogram to be tested a, the transition version 2 contains the target subprogram F matched with the subprogram to be tested a, the target subprogram G matched with the subprogram to be tested B, and neither the transition version 1 nor the transition version 2 contains the subprogram matched with the subprogram to be tested C. The test platform can determine the code coverage information corresponding to the subprogram A to be tested according to the target subprograms E and F, and determine the code coverage information corresponding to the subprogram B to be tested according to the target subprogram G. Correspondingly, the first version can be tested to obtain the code coverage information corresponding to the subprogram C to be tested. Finally, the code coverage information corresponding to the code to be tested is the code coverage information corresponding to the determined subprogram to be tested A and the subprogram to be tested B, and the code coverage information corresponding to the subprogram to be tested C.
It should be noted that the test platform may determine the target subprogram in various ways. For example, the testing platform may determine the subprogram summary information corresponding to the subprogram to be tested, and query the subprogram summary information corresponding to each subprogram in the target code corresponding to each transition version stored in advance. Then, the testing platform can take the subprogram in each transition version, which is consistent with the subprogram abstract information corresponding to the subprogram to be tested, as the target subprogram. The sub-program digest information mentioned herein may be calculated from the program code (e.g., bytecode) of the sub-program by a digest algorithm such as MD5, SHA, or the like.
For example, assuming that a subroutine includes 11 lines of program code from line 10 to line 20, the subroutine digest information corresponding to the subroutine may be determined by calculating all the program code from line 10 to line 20 by a digest algorithm. If the subprogram abstract information of the two subprograms is the same, the corresponding program codes of the two subprograms are the same, so that the test platform can determine the target subprogram matched with the subprogram to be tested through the subprogram abstract information in the process. Of course, in addition to the above manner, the test platform may also determine the subprogram matched with the subprogram to be tested by comparing the program codes one by one. Specifically, the test platform may determine, from the transition version, a subroutine completely consistent with the program code of the subroutine to be tested, as the target subroutine.
In this specification, the test platform may store, in advance, the sub-program summary information and the code coverage information corresponding to each sub-program in the target code corresponding to each transition version, so that, in the process of determining the code coverage information of each sub-program to be tested in the code to be tested, the code coverage information of each target sub-program may be directly queried.
Specifically, the test platform may determine, for each transition version, after historically testing the transition version, the subprogram summary information corresponding to each subprogram in the target code corresponding to the transition version, and then, for each subprogram included in the target code corresponding to the transition version, the test platform may determine the code coverage information of the subprogram in the test task corresponding to the transition version. If the test platform determines that the sub-program abstract information corresponding to the sub-program is not stored, the sub-program abstract information corresponding to the sub-program and the code coverage information corresponding to the sub-program can be correspondingly stored.
That is, when the test platform determines that the sub-program abstract information corresponding to the sub-program is not stored, it indicates that there is no sub-program in which the program code completely conforms to the sub-program in the previous transition version, and the sub-program is tested for the first time in the test of the transition version, so that the test platform can directly store the sub-program abstract information corresponding to the sub-program and the code coverage information corresponding to the sub-program correspondingly. The test platform can correspondingly store the subprogram abstract information and the code coverage information through a Map type data structure. Of course, the test platform may also correspondingly store the sub-program abstract information and the code coverage information corresponding to the sub-program in other manners, which is not limited herein.
If the test platform determines that the sub-program abstract information corresponding to the sub-program is stored, the code coverage information corresponding to the sub-program can be aggregated into the code coverage information matched with the sub-program abstract information corresponding to the sub-program. The fact that the sub program summary information corresponding to the sub program already exists indicates that the sub program identical to the program code of the sub program has been tested in other transition versions historically, and in order to reduce the instances of repeated testing, the code coverage information of the sub programs identical to the sub program summary information may be aggregated.
For example, the transition version 1 includes a sub-program a, the transition version 2 includes a sub-program b having the same sub-program digest information as the sub-program a (which may indicate that the program code of the sub-program a is identical to the program code of the sub-program b), and further includes a new sub-program c. The test platform may store the code coverage information of the transition version 1 first, and then store the code coverage information of the transition version 2. The test platform can directly correspondingly store the subprogram abstract information and the subprogram coverage information of the subprogram a. Then, when the test platform saves the code coverage information of the transitional version 2, since the sub-program abstract information of the sub-program b is saved, the code coverage information of the sub-program b can be directly aggregated into the code coverage information of the sub-program a which is already saved. And since the subprogram abstract information of the subprogram c is not stored, the test platform can directly store the subprogram abstract information and the code coverage information of the subprogram c correspondingly.
Further, it is assumed that each of the sub-programs a and b includes three lines of codes, and in the test of the transition version 1, the code coverage information of the sub-program a is 1, 0, and 0 (indicating that the first line of codes of the sub-program a is covered and neither the second line of codes nor the third line of codes is covered), and in the test of the transition version 2, the code coverage information of the sub-program b is 1, and 0 (the first line of codes and the second line of codes of the sub-program b are covered and the third line of codes is uncovered). And the test platform correspondingly stores the subprogram abstract information and the code coverage information of the subprogram a. Then, the code coverage information of the subroutine b can be directly aggregated into the code coverage information already corresponding to the subroutine a, that is, the code coverage information corresponding to the subroutine a after the aggregation of the code coverage information corresponding to the subroutine b is 1, 0 (indicating that the first line of code and the second line of code are covered, and the third line of code is not covered).
The code coverage information only indicates whether a code line is covered, and in practical application, the code coverage information may be in various forms. For example, the code coverage information may indicate the number of times a code line is covered. Assuming that the code coverage information of the subroutine a is 4, 0, and 0, it indicates that the first line code of the subroutine a is cumulatively tested 4 times in the conventional transition version and transition version 1, and the second line code and the third line code are not covered. And the code coverage information of the subroutine b in the test of the transitional version 2 is 1, 1 and 0, which indicates that the subroutine b has 1 time covered by the first line code, 1 time covered by the second line code and no covered by the third line code in the test of the transitional version 2. The code coverage information of the subroutine b is directly aggregated to the code coverage information of the saved subroutine a, and then the code coverage information is changed to 5, 2, 0 (indicating that the first row of code accumulation is tested 5 times, the second row of code accumulation is tested 2 times, and the third row of code is not tested).
It should be further noted that the incremental code (i.e., the code to be tested) included in the first version may be determined according to the subroutine in which the first version is changed from the second version. That is to say, the code to be tested is the program code related to each subprogram that changes between the first version and the second version, and the changed subprogram mentioned here can be understood as the subprogram that has changed and the added subprogram from the second version to the first version. Of course, the code in which the difference exists between the program codes of the transitional version and the second version, that is, the target code corresponding to the transitional version may also be determined by the subroutine in which the change occurs between the transitional version and the second version. Similarly, the target code is a program code related to a subprogram of which the program code is changed between the transition version and the second version and a newly added subprogram.
In this specification, after the test platform determines the code coverage information corresponding to the code to be tested, if it is determined that the first version meets the preset condition, the code coverage information corresponding to each target subprogram in each saved transition version may be deleted. The preset condition mentioned here may be various, for example, the preset condition may refer to that the first version is online, that is, after the testing platform determines that the first version is online, the testing platform does not need to test the first version any more, so that the code coverage information corresponding to each target subprogram may be deleted. For another example, the preset condition may be that the code coverage of the first version is not less than the set coverage, and the set coverage mentioned herein may be set according to actual requirements. The code coverage mentioned here may be included in the code coverage information corresponding to the code to be tested. The code coverage rate may represent a proportion of the code lines covered in the test procedure of the code to be tested in the first version to the total code lines. When the test platform determines that the code coverage rate is not less than the set coverage rate, the test platform can determine that the first version does not need to be tested any more, so that the test platform can delete the code coverage information corresponding to each target subprogram.
It can be seen from the above method that, in the version testing method provided in this specification, the coverage condition of the code to be tested in the first version can be determined through the code coverage information of each transition version, that is, the method determines the test coverage condition of the whole from the second version to the first version, whereas the prior art can determine the code coverage information of the first version through the code coverage information in one test. Therefore, the method can integrally consider the coverage condition tested aiming at the first version and can improve the testing efficiency aiming at the first version.
In this specification, in addition to determining the code coverage information of the whole code to be tested in the first version, the test platform may also determine the code coverage information of the target code corresponding to each transition version in each test type, and determine the code coverage information of the code to be tested in each test type according to the code coverage information of the target code corresponding to each transition version in each test type by the method, so that a coverage information page showing the test coverage condition of the first version in each test type may be generated. Each test type referred to herein may include unit testing, automated testing, and the like. For example, after the test platform determines the code coverage information and the coverage information page corresponding to the unit test and the automatic test respectively by the method, the coverage information page corresponding to the unit test can be displayed to the developer, and the coverage information page corresponding to the automatic test can be displayed to the tester.
It should be noted that, the process of determining the code coverage information corresponding to the code to be tested according to the code coverage information of the target code corresponding to each transition version may be a loop process, as shown in fig. 2.
Fig. 2 is a schematic diagram provided in this specification, which is used for determining code coverage information corresponding to a code to be tested according to code coverage information of a target code corresponding to each transitional version.
Assuming that there are n transition versions between the first version and the second version, starting from the second version, a developer first develops the transition version 1, then the test platform tests the transition version 1 to obtain code coverage information of the transition version 1, stores the code coverage information, then the developer modifies the transition version 1 and enters a new development to obtain the transition version 2, and after the test platform tests the transition version 2, the code coverage information of the transition version 2 is obtained, and the code coverage information of the transition version 2 needs to be merged into the code coverage information of the transition version 1 for storage according to a certain mode. Then, from the next transitional version to the nth transitional version, which are the same as the transitional version 2, the test platform needs to merge the code coverage information of each transitional version into the stored code coverage information. And then, the test platform can determine the code coverage information corresponding to the code to be tested according to the stored code coverage information.
It should be further noted that the code coverage information corresponding to the first version may also not only depend on the code coverage information corresponding to the transitional version, but also the test platform may test the first version to obtain the code coverage information and aggregate the code coverage information with the code coverage information corresponding to each transitional version to obtain the final complete code coverage information of the first version.
Based on the same idea, the present specification further provides a corresponding version test apparatus, as shown in fig. 3, for the method for version test provided above for one or more embodiments of the present specification.
Fig. 3 is a schematic diagram of a version test apparatus provided in this specification, which specifically includes:
a code determining module 301, configured to determine, as a code to be tested, an incremental code included in a first version compared with a second version, where the first version is a code version to be tested, and the second version is a code version online before the first version;
a version determining module 302, configured to determine, for each transition version between the second version and the first version, an incremental code included in the program code in the transition version compared with the program code in the second version as a target code corresponding to the transition version, and determine code coverage information for historically testing the target code corresponding to the transition version;
the testing module 303 is configured to determine code coverage information corresponding to the code to be tested according to the code coverage information of the target code corresponding to each transition version, and test the first version according to the code coverage information corresponding to the code to be tested.
Optionally, the version determining module 302 is specifically configured to, for each subprogram in the target code corresponding to the transition version, query code coverage information corresponding to the subprogram; and determining the code coverage information of the target code corresponding to the transition version according to the code coverage information corresponding to each subprogram in the target code corresponding to the transition version.
Optionally, the testing module 303 is specifically configured to, for each subprogram to be tested in the code to be tested, determine at least one subprogram matched with the subprogram to be tested in the target code corresponding to each transition version, as a target subprogram; determining code coverage information corresponding to the subprogram to be tested according to the code coverage information corresponding to the at least one target subprogram; and determining code coverage information corresponding to the code to be tested according to the code coverage information corresponding to each subprogram to be tested in the code to be tested.
Optionally, the testing module 303 is specifically configured to determine subroutine summary information corresponding to the subroutine to be tested; inquiring subprogram abstract information corresponding to each subprogram in target codes corresponding to each transition version which are stored in advance; and taking the subprogram with consistent subprogram abstract information corresponding to the subprogram to be tested in each transition version as a target subprogram.
Optionally, the apparatus further comprises:
a saving module 304, configured to determine, for each transition version, subprogram summary information corresponding to each subprogram in the target code corresponding to the transition version; determining code coverage information of each subprogram in the test task corresponding to the transition version aiming at each subprogram contained in the target code corresponding to the transition version; if the subprogram abstract information corresponding to the subprogram is determined not to be stored, correspondingly storing the subprogram abstract information corresponding to the subprogram and the code coverage information corresponding to the subprogram; and if the subprogram abstract information corresponding to the subprogram is determined to be stored, aggregating the code coverage information corresponding to the subprogram into the code coverage information matched with the subprogram abstract information corresponding to the subprogram.
Optionally, the code determining module 301 is specifically configured to determine, according to a subroutine in which a change occurs between the first version and the second version, an incremental code included in the first version compared to the second version as a code to be tested.
Optionally, the apparatus further comprises:
a deleting module 305, configured to delete the stored code coverage information corresponding to each target subprogram in each transition version if it is determined that the first version meets the preset condition.
The present specification also provides a computer-readable storage medium storing a computer program, which is operable to execute the method of version testing shown in fig. 1 described above.
This specification also provides a schematic block diagram of the electronic device shown in fig. 4. As shown in fig. 4, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs the computer program to implement the version testing method described in fig. 1. Of course, besides the software implementation, the present specification does not exclude other implementations, such as logic devices or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may be hardware or logic devices.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functions of the various elements may be implemented in the same one or more software and/or hardware implementations of the present description.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that 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 an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
This description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present specification, and is not intended to limit the present specification. Various modifications and alterations to this description will become apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification should be included in the scope of the claims of the present specification.

Claims (10)

1. A method of version testing, comprising:
determining an incremental code contained in a first version compared with a second version as a code to be tested, wherein the first version is a code version needing to be tested, and the second version is a code version on line before the first version;
for each transition version between the second version and the first version, determining an incremental code included in the program code of the transition version compared with the program code of the second version as a target code corresponding to the transition version, and determining code coverage information for historically testing the target code corresponding to the transition version;
and determining code coverage information corresponding to the code to be tested according to the code coverage information of the target code corresponding to each transition version, and testing the first version according to the code coverage information corresponding to the code to be tested.
2. The method of claim 1, wherein determining code coverage information for the object code corresponding to the transitional version comprises:
inquiring code coverage information corresponding to each subprogram in the target code corresponding to the transition version;
and determining the code coverage information of the target code corresponding to the transition version according to the code coverage information corresponding to each subprogram in the target code corresponding to the transition version.
3. The method of claim 2, wherein determining code coverage information corresponding to the code to be tested according to the code coverage information of the target code corresponding to each transitional version specifically comprises:
determining at least one subprogram matched with the subprogram to be tested in the target code corresponding to each transition version as a target subprogram aiming at each subprogram to be tested in the codes to be tested;
determining code coverage information corresponding to the subprogram to be tested according to the code coverage information corresponding to the at least one target subprogram;
and determining code coverage information corresponding to the code to be tested according to the code coverage information corresponding to each subprogram to be tested in the code to be tested.
4. The method of claim 3, wherein determining at least one subprogram matching the subprogram to be tested in the object code corresponding to each transitional version as the target subprogram specifically comprises:
determining subprogram abstract information corresponding to the subprogram to be tested;
inquiring subprogram abstract information corresponding to each subprogram in target codes corresponding to each transition version which are stored in advance;
and taking the subprogram with consistent subprogram abstract information corresponding to the subprogram to be tested in each transition version as a target subprogram.
5. The method of claim 4, wherein storing the sub-program summary information corresponding to each sub-program in the object code corresponding to each transitional version comprises:
determining subprogram summary information corresponding to each subprogram in the target code corresponding to each transition version aiming at each transition version;
determining code coverage information of each subprogram in the test task corresponding to the transition version aiming at each subprogram contained in the target code corresponding to the transition version;
if the subprogram abstract information corresponding to the subprogram is determined not to be stored, correspondingly storing the subprogram abstract information corresponding to the subprogram and the code coverage information corresponding to the subprogram;
and if the subprogram abstract information corresponding to the subprogram is determined to be stored, aggregating the code coverage information corresponding to the subprogram into the code coverage information matched with the subprogram abstract information corresponding to the subprogram.
6. The method of claim 1, wherein determining the incremental code included in the first version as compared to the second version as the code to be tested specifically comprises:
and determining the incremental code contained in the first version compared with the second version as the code to be tested according to the subprogram of the change between the first version and the second version.
7. The method of claim 4, wherein the method further comprises:
and if the first version is determined to meet the preset condition, deleting the stored code coverage information corresponding to each target subprogram in each transition version.
8. An apparatus for version testing, comprising:
the code determination module is used for determining an incremental code contained in a first version compared with a second version as a code to be tested, wherein the first version is a code version needing to be tested, and the second version is an online code version before the first version;
the version determining module is used for determining, for each transition version between the second version and the first version, an incremental code included in the program code in the transition version compared with the program code in the second version as a target code corresponding to the transition version, and determining code coverage information for historically testing the target code corresponding to the transition version;
and the testing module is used for determining the code coverage information corresponding to the code to be tested according to the code coverage information of the target code corresponding to each transition version, and testing the first version according to the code coverage information corresponding to the code to be tested.
9. A computer-readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, implements the method of any of the preceding claims 1 to 7.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any of claims 1 to 7 when executing the program.
CN202011321052.0A 2020-11-23 2020-11-23 Version testing method and device Pending CN112363945A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011321052.0A CN112363945A (en) 2020-11-23 2020-11-23 Version testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011321052.0A CN112363945A (en) 2020-11-23 2020-11-23 Version testing method and device

Publications (1)

Publication Number Publication Date
CN112363945A true CN112363945A (en) 2021-02-12

Family

ID=74532691

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011321052.0A Pending CN112363945A (en) 2020-11-23 2020-11-23 Version testing method and device

Country Status (1)

Country Link
CN (1) CN112363945A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100058295A1 (en) * 2008-09-02 2010-03-04 International Business Machines Corporation Dynamic Test Coverage
US20130091490A1 (en) * 2011-10-06 2013-04-11 Saggi Yehuda Mizrahi Method to automatically discover whether new code is covered by tests
CN108170610A (en) * 2018-01-17 2018-06-15 北京网信云服信息科技有限公司 The method and apparatus for determining test coverage
CN110209568A (en) * 2018-04-24 2019-09-06 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage equipment
CN110532174A (en) * 2019-07-24 2019-12-03 平安科技(深圳)有限公司 Calculate method, apparatus, computer equipment and the storage medium of incremental code coverage rate
CN110597710A (en) * 2019-08-13 2019-12-20 平安证券股份有限公司 Test coverage rate statistical method and device, computer equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100058295A1 (en) * 2008-09-02 2010-03-04 International Business Machines Corporation Dynamic Test Coverage
US20130091490A1 (en) * 2011-10-06 2013-04-11 Saggi Yehuda Mizrahi Method to automatically discover whether new code is covered by tests
CN108170610A (en) * 2018-01-17 2018-06-15 北京网信云服信息科技有限公司 The method and apparatus for determining test coverage
CN110209568A (en) * 2018-04-24 2019-09-06 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage equipment
CN110532174A (en) * 2019-07-24 2019-12-03 平安科技(深圳)有限公司 Calculate method, apparatus, computer equipment and the storage medium of incremental code coverage rate
CN110597710A (en) * 2019-08-13 2019-12-20 平安证券股份有限公司 Test coverage rate statistical method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN108845936B (en) AB testing method and system based on massive users
CN109213685B (en) Service logic test method and device
CN108320071B (en) Business risk management method, device and equipment
CN111273965B (en) Container application starting method, system and device and electronic equipment
CN109284222B (en) Software unit, project testing method, device and equipment in data processing system
CN112035341A (en) Automatic testing method and device
CN114840427A (en) Code testing and test case generating method and device
CN112181812A (en) Version testing method and device
CN111399849B (en) Method and system for determining application program installation package
CN114840426A (en) Code testing method and device
CN111240987A (en) Migration program detection method and device, electronic equipment and computer readable storage medium
CN107562533B (en) Data loading processing method and device
CN116010419A (en) Method and device for creating unique index and optimizing logic deletion
CN112363945A (en) Version testing method and device
CN115391337A (en) Database partitioning method and device, storage medium and electronic equipment
CN114817212A (en) Database optimization method and optimization device
CN110704742B (en) Feature extraction method and device
CN112286572A (en) Configuration method and device of business process
CN110688430B (en) Method and device for obtaining data bypass and electronic equipment
CN110633321B (en) Data synchronization method, device and equipment
CN108733564B (en) Browser performance testing method, device and equipment
CN109903165B (en) Model merging method and device
CN107391223B (en) File processing method and device
CN107645541B (en) Data storage method and device and server
CN112711539A (en) Data processing method and device and data detection system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination